From cc4fbafe5a5f94f02f2acf9b60f051ee80e77abd Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 2 Dec 2024 20:01:31 -0800 Subject: [PATCH] ci: Send email if the reproducible build process fails Changelog-None. --- .github/workflows/repro.yml | 121 ++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 25 deletions(-) diff --git a/.github/workflows/repro.yml b/.github/workflows/repro.yml index f21dbcb6cf20..67549d334ebe 100644 --- a/.github/workflows/repro.yml +++ b/.github/workflows/repro.yml @@ -17,44 +17,80 @@ jobs: version: ['focal', 'jammy', 'noble'] steps: - name: Git checkout + id: repo_chackout uses: actions/checkout@v4 - - name: Build environment setup + - name: Build environment setup - ${{ matrix.version }} + id: environment_setup + shell: bash run: | echo "Building base image for ${{ matrix.version }}" - sudo docker run --rm -v $(pwd):/build ubuntu:${{ matrix.version }} bash -c "\ - apt-get update && \ - apt-get install -y debootstrap && \ - debootstrap ${{ matrix.version }} /build/${{ matrix.version }}" - sudo tar -C ${{ matrix.version }} -c . | docker import - ${{ matrix.version }} + { + echo "STEP=Build environment setup" >> "$GITHUB_ENV" + sudo docker run --rm -v $(pwd):/build ubuntu:${{ matrix.version }} bash -c "\ + apt-get update && \ + apt-get install -y debootstrap && \ + debootstrap ${{ matrix.version }} /build/${{ matrix.version }}" + sudo tar -C ${{ matrix.version }} -c . | docker import - ${{ matrix.version }} + } > command.log 2>&1 || { + echo "ERROR<> "$GITHUB_ENV" + echo "$(cat command.log)" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + exit 1 + } - - name: Builder image setup - run: docker build -t cl-repro-${{ matrix.version }} - < contrib/reprobuild/Dockerfile.${{ matrix.version }} + - name: Builder image setup - ${{ matrix.version }} + id: builder_image_setup + shell: bash + run: | + { + echo "STEP=Builder image setup" >> "$GITHUB_ENV" + docker build -t cl-repro-${{ matrix.version }} - < contrib/reprobuild/Dockerfile.${{ matrix.version }} + } > command.log 2>&1 || { + echo "ERROR<> "$GITHUB_ENV" + echo "$(cat command.log)" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + exit 1 + } - - name: Build using the builder image and store Git state + - name: Build reproducible image and store Git state - ${{ matrix.version }} + id: repro_image_setup + shell: bash run: | - # Create release directory. - mkdir $GITHUB_WORKSPACE/release + { + echo "STEP=Build reproducible image and store Git state" >> "$GITHUB_ENV" - # Perform the repro build. - docker run --name cl-build -v $GITHUB_WORKSPACE:/repo -e FORCE_MTIME=$(date +%F) -t cl-repro-${{ matrix.version }} + # Create release directory. + mkdir $GITHUB_WORKSPACE/release - # Commit the image in order to inspect the build later. - docker commit cl-build cl-release + # Perform the repro build. + docker run --name cl-build -v $GITHUB_WORKSPACE:/repo -e FORCE_MTIME=$(date +%F) -t cl-repro-${{ matrix.version }} - # Inspect the version. - docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-release bash -c "make version > /repo/release/version.txt" + # Commit the image in order to inspect the build later. + docker commit cl-build cl-repro - # Inspect the Git tree state. - docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-release bash -c "\ - git --no-pager status > /repo/release/git.log && \ - git --no-pager diff >> /repo/release/git.log" + # Inspect the version. + docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "make version > /repo/release/version.txt" - # Change permissions on the release files for access by the runner environment. - sudo chown -R runner $GITHUB_WORKSPACE/release + # Inspect the Git tree state. + docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "\ + git --no-pager status > /repo/release/git.log && \ + git --no-pager diff >> /repo/release/git.log" - - name: Assert clean version and release + # Change permissions on the release files for access by the runner environment. + sudo chown -R runner $GITHUB_WORKSPACE/release + } > command.log 2>&1 || { + echo "ERROR<> "$GITHUB_ENV" + echo "$(cat command.log)" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + exit 1 + } + + - name: Assert clean version - ${{ matrix.version }} + id: assert_version + shell: bash run: | + echo "STEP=Assert clean version" >> "$GITHUB_ENV" echo 'Version:' cat release/version.txt echo -e @@ -65,7 +101,7 @@ jobs: echo -e if [ -n "$(cat release/version.txt | sed -n '/-modded/p')" ] || \ - [ -n "$(echo $releasefile | sed -n '/-modded/p')" ] + [ -n "$(echo $releasefile | sed -n '/-modded/p')" ] then echo "Git Status and Diff:" cat release/git.log @@ -76,3 +112,38 @@ jobs: else echo 'Success! Clean release.' fi + + - name: Upload release artifact - ${{ matrix.version }} + uses: actions/upload-artifact@v3 + with: + name: release-${{ matrix.version }} + path: release + + - name: Send email on failure + id: send_email + if: ${{ failure() }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.gmail.com + server_port: 587 + username: ${{ secrets.EMAIL_USERNAME }} + password: ${{ secrets.EMAIL_PASSWORD }} + from: ${{ secrets.EMAIL_USERNAME }} + to: ${{ vars.DISTRIBUTION_LIST }} + subject: "CI Failure: Step ${{ env.STEP }} failed for distro ${{ matrix.version }}" + convert_markdown: true + html_body: | + + +

Failure Details:

+ + +