From 6981eba031bdf0867d4139b3fe74008a36543f23 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Fri, 1 Jul 2022 11:58:08 +0100 Subject: [PATCH] build: split GitHub workflows By splitting workflows we can get the overall time for all the checks to be decreased. Signed-off-by: Paulo Gomes --- .github/workflows/e2e.yaml | 41 ------------------ .github/workflows/tests.yaml | 80 +++++++++++++++++++++++++++++++++++ .github/workflows/verify.yaml | 31 ++++++++++++++ 3 files changed, 111 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/tests.yaml create mode 100644 .github/workflows/verify.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 26a4c69e1..4871f0072 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -27,18 +27,11 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - name: Verify - run: make verify - name: Enable integration tests # Only run integration tests for main branch if: github.ref == 'refs/heads/main' run: | echo 'GO_TAGS=integration' >> $GITHUB_ENV - - name: Run tests - env: - TEST_AZURE_ACCOUNT_NAME: ${{ secrets.TEST_AZURE_ACCOUNT_NAME }} - TEST_AZURE_ACCOUNT_KEY: ${{ secrets.TEST_AZURE_ACCOUNT_KEY }} - run: make test - name: Setup Kubernetes uses: engineerd/setup-kind@v0.5.0 with: @@ -69,19 +62,6 @@ jobs: if: github.ref == 'refs/heads/main' run: | echo 'GO_TAGS=integration' >> $GITHUB_ENV - - name: Run tests - env: - TEST_AZURE_ACCOUNT_NAME: ${{ secrets.TEST_AZURE_ACCOUNT_NAME }} - TEST_AZURE_ACCOUNT_KEY: ${{ secrets.TEST_AZURE_ACCOUNT_KEY }} - - # Temporarily disabling -race for arm64 as our GitHub action - # runners don't seem to like it. The race detection was tested - # on both Apple M1 and Linux arm64 with successful results. - # - # We should reenable go test -race for arm64 runners once the - # current issue is resolved. - GO_TEST_ARGS: '' - run: make test - name: Prepare id: prep run: | @@ -103,24 +83,3 @@ jobs: run: | kind delete cluster --name ${{ steps.prep.outputs.CLUSTER }} rm /tmp/${{ steps.prep.outputs.CLUSTER }} - - # Runs 'make test' on macos-10.15 to assure development environment for - # contributors using MacOS. - darwin-amd64: - runs-on: macos-10.15 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.17.x - - name: Restore Go cache - uses: actions/cache@v3 - with: - path: /home/runner/work/_temp/_github_home/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Run tests - run: make test diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 000000000..6dd2847a9 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,80 @@ +name: tests + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read # for actions/checkout to fetch code + +jobs: + + test-linux-amd64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.17.x + - name: Restore Go cache + uses: actions/cache@v3 + with: + path: /home/runner/work/_temp/_github_home/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run tests + env: + TEST_AZURE_ACCOUNT_NAME: ${{ secrets.TEST_AZURE_ACCOUNT_NAME }} + TEST_AZURE_ACCOUNT_KEY: ${{ secrets.TEST_AZURE_ACCOUNT_KEY }} + run: make test + + test-linux-arm64: + # Hosted on Equinix + # Docs: https://github.com/fluxcd/flux2/tree/main/.github/runners + runs-on: [self-hosted, Linux, ARM64, equinix] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.17.x + - name: Run tests + env: + TEST_AZURE_ACCOUNT_NAME: ${{ secrets.TEST_AZURE_ACCOUNT_NAME }} + TEST_AZURE_ACCOUNT_KEY: ${{ secrets.TEST_AZURE_ACCOUNT_KEY }} + + # Temporarily disabling -race for arm64 as our GitHub action + # runners don't seem to like it. The race detection was tested + # on both Apple M1 and Linux arm64 with successful results. + # + # We should reenable go test -race for arm64 runners once the + # current issue is resolved. + GO_TEST_ARGS: '' + run: make test + + # Runs 'make test' on macos-10.15 to assure development environment for + # contributors using MacOS. + darwin-amd64: + runs-on: macos-10.15 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.17.x + - name: Restore Go cache + uses: actions/cache@v3 + with: + path: /home/runner/work/_temp/_github_home/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run tests + run: make test diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml new file mode 100644 index 000000000..82ecd108a --- /dev/null +++ b/.github/workflows/verify.yaml @@ -0,0 +1,31 @@ +name: verify + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read # for actions/checkout to fetch code + +jobs: + + verify-linux-amd64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.17.x + - name: Restore Go cache + uses: actions/cache@v3 + with: + path: /home/runner/work/_temp/_github_home/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Verify + run: make verify