From c6d05c08ba6644941cad4f8ef73310b6754c31ad Mon Sep 17 00:00:00 2001 From: "Mark S. Lewis" Date: Thu, 12 Jan 2023 11:39:57 +0000 Subject: [PATCH] Refactor CI pipeline - Split tests to callable workflow to enable multi-release scheduled builds - Automatic cancel of in-progress pull request builds on a new push Signed-off-by: Mark S. Lewis --- .github/workflows/pull_request.yml | 14 ++++++++++++++ .github/workflows/push.yml | 10 ++++++++++ .github/workflows/{build.yml => test.yml} | 20 +++++++++++++------- scripts/pull-fabric-images.sh | 2 +- 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/push.yml rename .github/workflows/{build.yml => test.yml} (65%) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..9c3d71b1 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,14 @@ +name: Pull request + +on: + pull_request: + branches: + - release-2.2 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..c9065ac8 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,10 @@ +name: Push + +on: + push: + branches: + - release-2.2 + +jobs: + build: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/test.yml similarity index 65% rename from .github/workflows/build.yml rename to .github/workflows/test.yml index 71e8d4af..804dd629 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/test.yml @@ -1,15 +1,19 @@ name: Build on: - push: - branches: - - release-2.2 - pull_request: - branches: - - release-2.2 + workflow_call: + inputs: + fabric-version: + default: '2.2' + required: false + type: string + checkout-ref: + default: '' + required: false + type: string env: - FABRIC_VERSION: "2.2" + FABRIC_VERSION: ${{ inputs.fabric-version }} GOPATH: ${{ github.workspace }}/src/test/fixture jobs: @@ -24,6 +28,8 @@ jobs: - "17" steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.checkout-ref }} - name: Set up JDK ${{ matrix.java-version }} uses: actions/setup-java@v3 with: diff --git a/scripts/pull-fabric-images.sh b/scripts/pull-fabric-images.sh index ab8253ca..d91db05c 100755 --- a/scripts/pull-fabric-images.sh +++ b/scripts/pull-fabric-images.sh @@ -1,7 +1,7 @@ #!/bin/bash -e set -euo pipefail -# FABRIC_VERSION is set in .github/workflows/build.yml +# FABRIC_VERSION is set overridden by CI pipeline VERSION=${FABRIC_VERSION:-2.2} STABLE_TAG=amd64-${VERSION}-stable