From a4b302b664821d3503c803941be6d6ed35ccb7c8 Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Sun, 22 May 2022 19:32:52 +0200 Subject: [PATCH 1/3] Create an issue on nightly CI run failure --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30341e29..14254233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,32 @@ jobs: - name: Run tests run: sh ci/run.sh ${{ matrix.os }} + create_issue: + runs-on: ubuntu-latest + # the combination of these two lines seems to do the "if build_and_test failed, run this one" + needs: build_and_test + if: always() && github.event_name == 'schedule' && needs.build_and_test.result == 'failure' + + steps: + - name: Create an issue + shell: bash + run: | + readarray -t exists < <(gh issue list --state open --label nightly-CI-failed --json number --jq '.[].number') + if [ -n "${exists[@]}" ]; then + echo "Not opening another issue, already have ${#exists[@]} issue(s), latest at https://github.com/rust-lang/rust-semverver/issues/${exists[0]}." + else + cat << EOF | gh issue create \ + --label nightly-CI-failed \ + --title "Nightly CI run failed" \ + --body-file - + The nightly CI run on $(date +%F) seems to have failed. + + - Check the logs at https://github.com/rust-lang/rust-semverver/actions/runs/${{ github.run_id }} + - Update to the latest `rustc-nightly` if necessary + - Investigate test run failures if any + EOF + fi + # https://forge.rust-lang.org/infra/docs/bors.html#adding-a-new-repository-to-bors build_result: name: bors build finished From 9f54343c0e3e15d5cdcbe22e6995c6abd1adf96a Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Sat, 28 May 2022 16:05:59 +0200 Subject: [PATCH 2/3] Test #1: issue is created on failure --- .github/workflows/ci.yml | 3 ++- tests/cases/addition/stdout | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14254233..739a955b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,8 @@ jobs: runs-on: ubuntu-latest # the combination of these two lines seems to do the "if build_and_test failed, run this one" needs: build_and_test - if: always() && github.event_name == 'schedule' && needs.build_and_test.result == 'failure' + # TEST: remove the nightly trigger condition + if: always() && needs.build_and_test.result == 'failure' steps: - name: Create an issue diff --git a/tests/cases/addition/stdout b/tests/cases/addition/stdout index 3f8c0cbd..bb748815 100644 --- a/tests/cases/addition/stdout +++ b/tests/cases/addition/stdout @@ -56,3 +56,5 @@ warning: path changes to `Cde` warning: 6 warnings emitted + +ERROR From 9a499da5315aa200ffdfcd03edb856c50eed45e8 Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Sat, 28 May 2022 16:22:08 +0200 Subject: [PATCH 3/3] Fix syntax of workflow cmd --- .github/workflows/ci.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 739a955b..ae52cc7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: run: bash ci/setup-toolchain.sh if: github.event_name == 'schedule' - name: Run tests - run: sh ci/run.sh ${{ matrix.os }} + run: sh -c "exit 1" create_issue: runs-on: ubuntu-latest @@ -50,24 +50,31 @@ jobs: # TEST: remove the nightly trigger condition if: always() && needs.build_and_test.result == 'failure' + permissions: + issues: write + steps: - name: Create an issue shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - readarray -t exists < <(gh issue list --state open --label nightly-CI-failed --json number --jq '.[].number') - if [ -n "${exists[@]}" ]; then - echo "Not opening another issue, already have ${#exists[@]} issue(s), latest at https://github.com/rust-lang/rust-semverver/issues/${exists[0]}." + set -x + readarray -t exists < <(gh issue list --state open --label nightly-CI-failed --json number --jq '.[].number' --repo "$GITHUB_REPOSITORY") + if [[ -n "${exists[@]}" ]]; then + echo "Not opening another issue, already have ${#exists[@]} issue(s), latest at ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/issues/${exists[0]}." else cat << EOF | gh issue create \ --label nightly-CI-failed \ --title "Nightly CI run failed" \ + --repo "$GITHUB_REPOSITORY" \ --body-file - The nightly CI run on $(date +%F) seems to have failed. - - Check the logs at https://github.com/rust-lang/rust-semverver/actions/runs/${{ github.run_id }} - - Update to the latest `rustc-nightly` if necessary + - Check the logs at ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }} + - Update to the latest 'rustc-nightly' if necessary - Investigate test run failures if any - EOF + EOF fi # https://forge.rust-lang.org/infra/docs/bors.html#adding-a-new-repository-to-bors