Skip to content

Commit

Permalink
Consolidate test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Dec 11, 2024
1 parent 6bd2b2f commit b980af1
Show file tree
Hide file tree
Showing 28 changed files with 908 additions and 2,605 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ jobs:
- build_provider
- test
- license_check
#{{- range $action, $_ := .Config.ExtraTests }}#
- #{{ $action }}#
#{{- end }}#
uses: ./.github/workflows/publish.yml
secrets: inherit
with:
Expand Down Expand Up @@ -120,117 +117,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test:
name: test
uses: ./.github/workflows/test.yml
needs:
- prerequisites
- build_provider
- build_sdk
permissions:
contents: read
id-token: write
runs-on: #{{ if .Config.Runner.BuildSDK }}##{{- .Config.Runner.BuildSDK }}##{{ else }}##{{- .Config.Runner.Default }}##{{ end }}#
env:
PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }}
steps:
#{{- if .Config.FreeDiskSpaceBeforeTest }}#
# Run as first step so we don't delete things that have just been installed
- name: Free Disk Space (Ubuntu)
uses: #{{ .Config.ActionVersions.FreeDiskSpace }}#
with:
tool-cache: false
swap-storage: false
dotnet: false
#{{- end }}#
- name: Checkout Repo
uses: #{{ .Config.ActionVersions.Checkout }}#
with:
#{{- if .Config.CheckoutSubmodules }}#
submodules: #{{ .Config.CheckoutSubmodules }}#
#{{- end }}#
persist-credentials: false
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
tools: pulumictl, pulumicli, ${{ matrix.language }}
- name: Prepare local workspace
run: make prepare_local_workspace
- name: Download bin
uses: ./.github/actions/download-bin
- name: Download SDK
uses: ./.github/actions/download-sdk
with:
language: ${{ matrix.language }}
- name: Restore makefile progress
run: make --touch provider schema build_${{ matrix.language }}
- name: Update path
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Install Python deps
if: matrix.language == 'python'
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
#{{- if .Config.Docker }}#
- name: Run docker compose
run: docker compose -f testing/docker-compose.yml up --build -d
#{{- end }}#
#{{- if .Config.AWS }}#
- name: Configure AWS Credentials
uses: #{{ .Config.ActionVersions.ConfigureAwsCredentials }}#
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ env.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-duration-seconds: 7200
role-session-name: #{{ .Config.Provider }}#@githubActions
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}
#{{- end }}#
#{{- if .Config.GCP }}#
- name: Authenticate to Google Cloud
uses: #{{ .Config.ActionVersions.GoogleAuth }}#
with:
service_account: ${{ env.GOOGLE_CI_SERVICE_ACCOUNT_EMAIL }}
workload_identity_provider: projects/${{ env.GOOGLE_PROJECT_NUMBER
}}/locations/global/workloadIdentityPools/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_POOL }}/providers/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_PROVIDER }}
- name: Setup gcloud auth
uses: #{{ .Config.ActionVersions.SetupGcloud }}#
with:
install_components: gke-gcloud-auth-plugin
#{{- end }}#
#{{- if .Config.GCPRegistry }}#
- name: Login to Google Cloud Registry
run: gcloud --quiet auth configure-docker
#{{- end }}#
#{{- if index .Config.SetupScript }}#
- name: Run setup script
run: #{{ index .Config.SetupScript }}#
#{{- end }}#
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
#{{- if .Config.Actions.PreTest }}#
#{{ .Config.Actions.PreTest | toYaml | indent 4 }}#
#{{- end }}#
#{{- if .Config.IntegrationTestProvider }}#
- name: Run provider tests
working-directory: provider
run: go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4
#{{- end }}#
- name: Run tests
run: cd examples && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4
strategy:
fail-fast: false
matrix:
language:
#{{ .Config.Languages | toYaml | indent 8 }}#
#{{- if .Config.ExtraTests }}#
#{{ .Config.ExtraTests | toYaml | indent 2 }}#
#{{ end }}#
secrets: inherit
with:
version: ${{ needs.prerequisites.outputs.version }}

name: #{{ .Config.ProviderDefaultBranch }}#
on:
workflow_dispatch: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,115 +28,15 @@ jobs:
version: ${{ needs.prerequisites.outputs.version }}

test:
name: test
uses: ./.github/workflows/test.yml
needs:
- prerequisites
- build_provider
- build_sdk
permissions:
contents: read
id-token: write
runs-on: #{{ if .Config.Runner.BuildSDK }}##{{- .Config.Runner.BuildSDK }}##{{ else }}##{{- .Config.Runner.Default }}##{{ end }}#
env:
PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }}
steps:
#{{- if .Config.FreeDiskSpaceBeforeTest }}#
# Run as first step so we don't delete things that have just been installed
- name: Free Disk Space (Ubuntu)
uses: #{{ .Config.ActionVersions.FreeDiskSpace }}#
with:
tool-cache: false
swap-storage: false
dotnet: false
#{{- end }}#
- name: Checkout Repo
uses: #{{ .Config.ActionVersions.Checkout }}#
with:
#{{- if .Config.CheckoutSubmodules }}#
submodules: #{{ .Config.CheckoutSubmodules }}#
#{{- end }}#
persist-credentials: false
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
tools: pulumictl, pulumicli, ${{ matrix.language}}
- name: Prepare local workspace
run: make prepare_local_workspace
- name: Download bin
uses: ./.github/actions/download-bin
- name: Download SDK
uses: ./.github/actions/download-sdk
with:
language: ${{ matrix.language }}
- name: Restore makefile progress
run: make --touch provider schema build_${{ matrix.language }}
- name: Update path
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Install Python deps
if: matrix.language == 'python'
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
#{{- if .Config.Docker }}#
- name: Run docker compose
run: docker compose -f testing/docker-compose.yml up --build -d
#{{- end }}#
#{{- if .Config.AWS }}#
- name: Configure AWS Credentials
uses: #{{ .Config.ActionVersions.ConfigureAwsCredentials }}#
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ env.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-duration-seconds: 7200
role-session-name: #{{ .Config.provider }}#@githubActions
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}
#{{- end }}#
#{{- if .Config.GCP }}#
- name: Authenticate to Google Cloud
uses: #{{ .Config.ActionVersions.GoogleAuth }}#
with:
service_account: ${{ env.GOOGLE_CI_SERVICE_ACCOUNT_EMAIL }}
workload_identity_provider: projects/${{ env.GOOGLE_PROJECT_NUMBER
}}/locations/global/workloadIdentityPools/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_POOL }}/providers/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_PROVIDER }}
- name: Setup gcloud auth
uses: #{{ .Config.ActionVersions.SetupGcloud }}#
with:
install_components: gke-gcloud-auth-plugin
#{{- end }}#
#{{- if .Config.GCPRegistry }}#
- name: Login to Google Cloud Registry
run: gcloud --quiet auth configure-docker
#{{- end }}#
#{{- if index .Config.SetupScript }}#
- name: Run setup script
run: #{{ index .Config.SetupScript }}#
#{{- end }}#
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
#{{- if .Config.Actions.PreTest }}#
#{{ .Config.Actions.PreTest | toYaml | indent 4 }}#
#{{- end }}#
#{{- if .Config.IntegrationTestProvider }}#
- name: Run provider tests
if: matrix.testTarget == 'local'
working-directory: provider
run: go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 .
#{{- end }}#
- name: Run tests
run: cd examples && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4
strategy:
fail-fast: false
matrix:
language:
#{{ .Config.Languages | toYaml | indent 10 }}#
secrets: inherit
with:
version: ${{ needs.prerequisites.outputs.version }}

name: cron
on:
schedule:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,127 +48,21 @@ jobs:
- build_provider
- test
- license_check
#{{- range $action, $_ := .Config.ExtraTests }}#
- #{{ $action }}#
#{{- end }}#
uses: ./.github/workflows/publish.yml
secrets: inherit
with:
version: ${{ needs.prerequisites.outputs.version }}
isPrerelease: true

test:
name: test
uses: ./.github/workflows/test.yml
needs:
- prerequisites
- build_provider
- build_sdk
permissions:
contents: read
id-token: write
runs-on: #{{ if .Config.Runner.BuildSDK }}##{{- .Config.Runner.BuildSDK }}##{{ else }}##{{- .Config.Runner.Default }}##{{ end }}#
env:
PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }}
steps:
#{{- if .Config.FreeDiskSpaceBeforeTest }}#
# Run as first step so we don't delete things that have just been installed
- name: Free Disk Space (Ubuntu)
uses: #{{ .Config.ActionVersions.FreeDiskSpace }}#
with:
tool-cache: false
swap-storage: false
dotnet: false
#{{- end }}#
- name: Checkout Repo
uses: #{{ .Config.ActionVersions.Checkout }}#
with:
#{{- if .Config.CheckoutSubmodules }}#
submodules: #{{ .Config.CheckoutSubmodules }}#
#{{- end }}#
persist-credentials: false
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
tools: pulumictl, pulumicli, #{{ range $index, $element := .Config.Languages }}##{{if $index}}#, #{{end}}##{{ $element }}##{{end}}#
- name: Prepare local workspace
run: make prepare_local_workspace
- name: Download bin
uses: ./.github/actions/download-bin
- name: Download SDK
uses: ./.github/actions/download-sdk
with:
language: ${{ matrix.language }}
- name: Restore makefile progress
run: make --touch provider schema build_${{ matrix.language }}
- name: Update path
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Install Python deps
if: matrix.language == 'python'
run: |-
pip3 install virtualenv==20.0.23
pip3 install pipenv
#{{- if .Config.Docker }}#
- name: Run docker compose
run: docker compose -f testing/docker-compose.yml up --build -d
#{{- end }}#
#{{- if .Config.AWS }}#
- name: Configure AWS Credentials
uses: #{{ .Config.ActionVersions.ConfigureAwsCredentials }}#
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ env.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-duration-seconds: 7200
role-session-name: #{{ .Config.Provider }}#@githubActions
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}
#{{- end }}#
#{{- if .Config.GCP }}#
- name: Authenticate to Google Cloud
uses: #{{ .Config.ActionVersions.GoogleAuth }}#
with:
service_account: ${{ env.GOOGLE_CI_SERVICE_ACCOUNT_EMAIL }}
workload_identity_provider: projects/${{ env.GOOGLE_PROJECT_NUMBER
}}/locations/global/workloadIdentityPools/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_POOL }}/providers/${{
env.GOOGLE_CI_WORKLOAD_IDENTITY_PROVIDER }}
- name: Setup gcloud auth
uses: #{{ .Config.ActionVersions.SetupGcloud }}#
with:
install_components: gke-gcloud-auth-plugin
#{{- end }}#
#{{- if .Config.GCPRegistry }}#
- name: Login to Google Cloud Registry
run: gcloud --quiet auth configure-docker
#{{- end }}#
#{{- if index .Config.SetupScript }}#
- name: Run setup script
run: #{{ index .Config.SetupScript }}#
#{{- end }}#
- name: Install dependencies
run: make install_${{ matrix.language}}_sdk
- name: Install gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
#{{- if .Config.Actions.PreTest }}#
#{{ .Config.Actions.PreTest | toYaml | indent 4 }}#
#{{- end }}#
#{{- if .Config.IntegrationTestProvider }}#
- name: Run provider tests
working-directory: provider
run: go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 .
#{{- end }}#
- name: Run tests
run: cd examples && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 .
strategy:
fail-fast: false
matrix:
language:
#{{ .Config.Languages | toYaml | indent 8 }}#
#{{- if .Config.ExtraTests }}#
#{{ .Config.ExtraTests | toYaml | indent 2 }}#
#{{ end }}#
secrets: inherit
with:
version: ${{ needs.prerequisites.outputs.version }}

name: prerelease
on:
Expand Down
Loading

0 comments on commit b980af1

Please sign in to comment.