From c6bc88dc34fb6fe2c91281ac0958db4fba9fc78d Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Fri, 6 Aug 2021 22:46:50 -0400 Subject: [PATCH] CI (Buildbot): As soon as a PR is created or updated, create pending (yellow) commit statuses for all Buildbot jobs (#41811) (cherry picked from commit 6fce8d50da57631e33ffc316c57a99bf5597d765) --- .github/CODEOWNERS | 6 ++- .github/workflows/statuses.yml | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/statuses.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6cab5b68b11e9..5fc00a73b47d2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,5 @@ -CODEOWNERS @JuliaLang/github-actions -/.github/ @JuliaLang/github-actions +CODEOWNERS @JuliaLang/github-actions +/.github/ @JuliaLang/github-actions /.buildkite/ @JuliaLang/github-actions + +/.github/workflows/statuses.yml @DilumAluthge diff --git a/.github/workflows/statuses.yml b/.github/workflows/statuses.yml new file mode 100644 index 0000000000000..27422b4e69345 --- /dev/null +++ b/.github/workflows/statuses.yml @@ -0,0 +1,97 @@ +# Please ping @DilumAluthge when making any changes to this file. + +# This is just a short-term solution until we have migrated all of CI to Buildkite. +# +# 1. TODO: delete this file once we have migrated all of CI to Buildkite. +# +# 2. TODO: disable GitHub Actions on the `JuliaLang/julia` repository once we have migrated all +# of CI to Buildkite. + +# Here are some steps that we take in this workflow file for security reasons: +# 1. We do not checkout any code. +# 2. We do not run any external actions. + +name: Statuses + +on: + push: + branches: + - 'master' + - 'release-*' + # When using the `pull_request_target` event, all PRs will get a `GITHUB_TOKEN` that has + # write permissions, even if the PR is from a fork. + # Therefore, for security reasons, we do not checkout any code in this workflow. + pull_request: + branches: + - 'master' + - 'release-*' + +# These are the permissions for the `GITHUB_TOKEN` token. +# We should only give the token the minimum necessary set of permissions. +permissions: + statuses: write + actions: none + checks: none + contents: none + deployments: none + issues: none + discussions: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + +jobs: + statuses: + name: statuses + runs-on: ubuntu-latest + if: github.repository == 'JuliaLang/julia' + strategy: + fail-fast: false + steps: + - run: echo "SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + if: github.event_name == 'pull_request' + + - run: echo "SHA=${{ env.GITHUB_SHA }}" >> $GITHUB_ENV + if: github.event_name != 'pull_request' + + - run: echo "The SHA is ${{ env.SHA }}" + + # As we incrementally migrate individual jobs from Buildbot to Buildkite, we should + # remove them from the `context_list`. + - run: | + declare -a CONTEXT_LIST=( + "buildbot/package_freebsd64" + "buildbot/package_linux32" + "buildbot/package_linuxaarch64" + "buildbot/package_linuxarmv7l" + "buildbot/package_linuxppc64le" + "buildbot/package_macos64" + "buildbot/package_macosaarch64" + "buildbot/package_musl64" + "buildbot/package_win32" + "buildbot/package_win64" + "buildbot/tester_freebsd64" + "buildbot/tester_linux32" + "buildbot/tester_linux64" + "buildbot/tester_linuxaarch64" + "buildbot/tester_linuxarmv7l" + "buildbot/tester_linuxppc64le" + "buildbot/tester_macos64" + "buildbot/tester_macosaarch64" + "buildbot/tester_musl64" + "buildbot/tester_win32" + "buildbot/tester_win64" + ) + for CONTEXT in "${CONTEXT_LIST[@]}" + do + curl \ + -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + -d "{\"context\": \"$CONTEXT\", \"state\": \"$STATE\"}" \ + https://api.github.com/repos/JuliaLang/julia/statuses/${{ env.SHA }} + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + STATE: "pending"