From d16b887745b83afee8498c97b9bd56046d8003d7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 5 Sep 2023 16:45:08 +0200 Subject: [PATCH 1/2] action: support GitHub check in branch protection --- .github/workflows/ci-docs.yml | 26 ++++++++++++++++++++++++++ .github/workflows/ci.yml | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/ci-docs.yml diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml new file mode 100644 index 000000000..5b62adb43 --- /dev/null +++ b/.github/workflows/ci-docs.yml @@ -0,0 +1,26 @@ +# This workflow sets the test / all status check to success in case it's a docs only PR and test.yml is not triggered +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks +name: ci # The name must be the same as in ci.yml + +on: + pull_request: + paths-ignore: # This expression needs to match the paths ignored on ci.yml. + - '**' + - '!**/*.md' + - '!**/*.asciidoc' + +permissions: + contents: read + +## Concurrency only allowed in the main branch. +## So old builds running for old commits within the same Pull Request are cancelled +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + # dummy steps that allow to bypass those mandatory checks for tests + ci: + runs-on: ubuntu-latest + steps: + - run: 'echo "Not required for docs"' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70f67fe7c..8b2583572 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,3 +101,21 @@ jobs: cache-dependency-path: '**/go.sum' - name: Unit tests run: make test + + # Very last job to create a GitHub check with the status. This is handy to centralise the + # GitHub check validation in the Branch protection and to support the ci-docs.yml + ci: + if: always() + runs-on: ubuntu-latest + needs: + - check-update-modules + - precheck + - test + - test-macos + - test-windows + steps: + - id: check + uses: elastic/apm-pipeline-library/.github/actions/check-dependent-jobs@current + with: + needs: ${{ toJSON(needs) }} + - run: ${{ steps.check.outputs.isSuccess }} From 0f1caf572a04a989e866277f293b69b32798a213 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 5 Sep 2023 16:45:31 +0200 Subject: [PATCH 2/2] cancel old builds --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b2583572..3d3bee443 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,12 @@ on: permissions: contents: read +## Concurrency only allowed in the main branch. +## So old builds running for old commits within the same Pull Request are cancelled +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: precheck: runs-on: ubuntu-latest