Skip to content

Commit

Permalink
Merge pull request #615 from hmlanigan/parallel
Browse files Browse the repository at this point in the history
#615

After moving to self-hosted runners on PS6, the GitHub actions could take 1-2+ hours. Caused in part by how the runners were configured and how the GitHub actions were constructed. 

The PS6 self-hosted runners are optimized for larger jobs. Turn around time on recreating a runner could be 15-30 minutes.

Steps taken in the optimization:
- Move very quick jobs back to using GitHub runners. e.g. static analysis and clarity
- Tests requiring the build job, are moved to the same workflow to reduce the number of times we run the build job
- Remove the unit test job, this is being done by github-check-merge-juju-terraform-provider-juju
- Add a parallelization of 10 to the tests

The matrix for running the integration tests has also been reduced in size by 2/3rds. Old versions of the terraform client will no longer be tested, only the most recent. We have never seen a difference in test results caused by different client versions.

Only the x64 runners will be used until the acceptance tests can be updated with new tests which run on both architectures.
  • Loading branch information
jujubot authored Dec 6, 2024
2 parents 675d1a0 + e4efd92 commit 3e0ca8d
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 306 deletions.
114 changes: 0 additions & 114 deletions .github/workflows/build.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: [self-hosted, jammy]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
Expand All @@ -29,7 +29,7 @@ jobs:
name: Terraform Provider Acceptance Tests
needs:
- build
runs-on: [self-hosted, jammy]
runs-on: [self-hosted, jammy, x64]
timeout-minutes: 60
strategy:
fail-fast: false
Expand Down Expand Up @@ -85,4 +85,4 @@ jobs:
- env:
TF_ACC: "1"
TEST_CLOUD: ${{ matrix.cloud }}
run: go test -timeout 40m -v -cover ./internal/provider/
run: go test -parallel 10 -timeout 40m -v -cover ./internal/provider/
4 changes: 3 additions & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on: [pull_request, workflow_dispatch]
permissions:
contents: read

# This task runs solo has it doesn't need to be run as often.
jobs:
cla-check:
permissions:
pull-requests: write # for canonical/has-signed-canonical-cla to create & update comments
runs-on: [self-hosted, jammy]
runs-on: ubuntu-latest
steps:
- name: Check if CLA signed
uses: canonical/[email protected]
with:
accept-existing-contributors: true

4 changes: 2 additions & 2 deletions .github/workflows/k8s_tunnel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: [self-hosted, jammy]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
Expand All @@ -34,7 +34,7 @@ jobs:
add-machine-test:
name: Add Machine
needs: build
runs-on: [self-hosted, jammy]
runs-on: [self-hosted, jammy, x64]
env:
ACTIONS_ALLOW_IPV6: false
strategy:
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,93 @@ on:
permissions:
contents: read

# These jobs are small independent tasks which are required, but do not
# gate any integration or unit tests.
jobs:
# Ensure convention commits guidelines have been followed.
conventional-commits:
name: Check conventional commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v6

# Ensure the generated docs are up-to-date
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.*"
terraform_wrapper: false
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
# Ensure the go code is formatted properly
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- run: gofmt -w -l -s .
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after go fmt. Run 'gofmt -w -l -s .' command and commit."; exit 1)
# This runs golangci-lint against the codebase
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Determine which tests to run
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
go:
- '**.go'
- 'go.mod'
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.0
args: --print-issued-lines=true

# This runs copyright-check against the codebase
copyright-check:
name: copyright-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false
- run: |
OUT=$(find . -name '*.go' | sort | xargs grep -L -E '// (Copyright|Code generated)' || true)
LINES=$(echo "${OUT}" | wc -w)
if [ "$LINES" != 0 ]; then
echo ""
echo "$(red 'Found some issues:')"
echo -e '\nThe following files are missing copyright headers'
echo "${OUT}"
exit 1
fi
126 changes: 0 additions & 126 deletions .github/workflows/test_add_machine.yml

This file was deleted.

Loading

0 comments on commit 3e0ca8d

Please sign in to comment.