Skip to content

Commit

Permalink
ci(test): proper concurrency support (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel authored Dec 18, 2023
1 parent d760a4f commit 844d0b7
Show file tree
Hide file tree
Showing 16 changed files with 466 additions and 14 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@ permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
acceptance_tests:
setup_aiven_project:
runs-on: ubuntu-latest
outputs:
project_name: ${{ steps.selproj.outputs.project_name }}
steps:
- uses: actions/checkout@v4

- id: selproj
run: echo "project_name=$(make ci-selproj)" >> $GITHUB_OUTPUT
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME_PREFIX: ${{ secrets.AIVEN_PROJECT_NAME_PREFIX }}

acceptance_tests:
needs: setup_aiven_project
runs-on: ubuntu-latest
strategy:
max-parallel: 5
fail-fast: false
Expand Down Expand Up @@ -70,18 +83,16 @@ jobs:
- run: make test-acc
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
AIVEN_PROJECT_NAME: ${{ needs.setup_aiven_project.outputs.project_name }}
AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
AIVEN_ACCOUNT_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
PKG: ${{ matrix.pkg }}

sweep:
if: always()
needs: acceptance_tests

needs: [acceptance_tests, setup_aiven_project]
runs-on: ubuntu-latest
steps:

- uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -112,6 +123,6 @@ jobs:
command: make sweep
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
AIVEN_PROJECT_NAME: ${{ needs.setup_aiven_project.outputs.project_name }}
AIVEN_ORGANIZATION_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
AIVEN_ACCOUNT_NAME: ${{ secrets.AIVEN_ORGANIZATION_NAME }}
18 changes: 16 additions & 2 deletions .github/workflows/examples-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
setup_aiven_project:
runs-on: ubuntu-latest
outputs:
project_name: ${{ steps.selproj.outputs.project_name }}
steps:
- uses: actions/checkout@v4

- id: selproj
run: echo "project_name=$(make ci-selproj)" >> $GITHUB_OUTPUT
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME_PREFIX: ${{ secrets.AIVEN_PROJECT_NAME_PREFIX }}

examples_tests:
needs: setup_aiven_project
runs-on: ubuntu-latest
steps:
- uses: softprops/turnstyle@v1
Expand Down Expand Up @@ -41,4 +55,4 @@ jobs:
- run: make test-examples
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
AIVEN_PROJECT_NAME: ${{ needs.setup_aiven_project.outputs.project_name }}
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build build-dev debug test test-unit test-acc test-examples lint lint-go lint-test lint-docs fmt fmt-test fmt-imports clean clean-tools clean-examples sweep generate gen-go docs
.PHONY: build build-dev debug test test-unit test-acc test-examples lint lint-go lint-test lint-docs fmt fmt-test fmt-imports clean clean-tools clean-examples sweep generate gen-go docs ci-selproj

#################################################
# Global
Expand Down Expand Up @@ -31,6 +31,12 @@ $(TERRAFMT): $(TOOLS_BIN_DIR) $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -o bin/terrafmt github.com/katbyte/terrafmt


SELPROJ := $(TOOLS_BIN_DIR)/selproj

$(SELPROJ): $(TOOLS_BIN_DIR) $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -tags tools -o bin/selproj github.com/aiven/terraform-provider-aiven/tools/selproj


# See https://github.com/hashicorp/terraform/blob/main/tools/protobuf-compile/protobuf-compile.go#L215
ARCH ?= $(shell $(GO) env GOOS GOARCH | tr '\n' '_' | sed '$$s/_$$//')
BUILD_DEV_DIR ?= ~/.terraform.d/plugins/registry.terraform.io/aiven-dev/aiven/0.0.0+dev/$(ARCH)
Expand Down Expand Up @@ -167,3 +173,10 @@ gen-go:

docs: $(TFPLUGINDOCS)
$(TFPLUGINDOCS) generate

#################################################
# CI
#################################################

ci-selproj: $(SELPROJ)
$(SELPROJ)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aiven/terraform-provider-aiven

go 1.21.1
go 1.21

require (
github.com/aiven/aiven-go-client/v2 v2.4.0
Expand Down
1 change: 0 additions & 1 deletion internal/schemautil/userconfig/userconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build userconfig
// +build userconfig

package userconfig

Expand Down
7 changes: 6 additions & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module github.com/aiven/terraform-provider-aiven/tools

go 1.19
go 1.21

require (
github.com/aiven/terraform-provider-aiven/tools/selproj v0.0.0-00010101000000-000000000000
github.com/golangci/golangci-lint v1.55.2
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/katbyte/terrafmt v0.5.2
Expand All @@ -26,6 +27,7 @@ require (
github.com/OpenPeeDeeP/depguard/v2 v2.1.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/aiven/aiven-go-client/v2 v2.4.0 // indirect
github.com/alecthomas/go-check-sumtype v0.1.3 // indirect
github.com/alexkohler/nakedret/v2 v2.0.2 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
Expand Down Expand Up @@ -94,6 +96,7 @@ require (
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.5.2 // indirect
Expand Down Expand Up @@ -223,3 +226,5 @@ require (
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20230312165513-e84e2d14e3b8 // indirect
)

replace github.com/aiven/terraform-provider-aiven/tools/selproj => ./selproj
Loading

0 comments on commit 844d0b7

Please sign in to comment.