-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract shared test workflows and action
The "test" and "test examples" share most of their setup except for the actual test command to run so we can extract this into a "test-setup" composite action. Only the "run-acceptance-tests" workflow runs the example tests so we only call it from there. The main, prerelease and release workflows only call the main "test" workflow. Reorder the top-level workflow to be closer to the order of execution to make it easier to find the code when looking at an execution run. Remove explicit ref checkout during tests This ref isn't checked out for any other step so shouldn't be used here either. Remove left-over test-example condition We should be allowed to run this from other workflows. This condition is just needed within the run-acceptance-tests top-level workflow. Checkout before calling composite action The code has to be checked out to call a local action. Fix missing shells Add env for sub-workflows Fix secrets access in composite action Secrets are not available and must be passed as explicit inputs. This must also be fixed in any providers specifying arbitrary code in their actions.preTest ci-mgmt config. Always ensure upstream before tests This is hard-coded into lots of provider's preTest config. Fix missing token secret Only test examples if enabled Fix missing upstream shell Apply to nightly-test workflow
- Loading branch information
1 parent
fbbfeae
commit ee91ccb
Showing
30 changed files
with
1,015 additions
and
1,502 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
provider-ci/internal/pkg/templates/bridged-provider/.github/actions/test-setup/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: "Test Setup" | ||
description: Sets up repository, tools and SDK ready for running integration tests | ||
|
||
inputs: | ||
language: | ||
required: true | ||
description: The SDK language being used for tests | ||
token: | ||
required: false | ||
description: Optional GH_TOKEN. | ||
#{{- if .Config.aws }}# | ||
aws-access-key-id: | ||
required: false | ||
description: e.g. secrets.AWS_ACCESS_KEY_ID | ||
aws-region: | ||
required: false | ||
description: e.g. env.AWS_REGION | ||
aws-secret-access-key: | ||
required: false | ||
description: e.g. secrets.AWS_SECRET_ACCESS_KEY | ||
aws-role-to-assume: | ||
required: false | ||
description: e.g. secrets.AWS_CI_ROLE_ARN | ||
#{{- end }}# | ||
|
||
runs: | ||
using: "composite" | ||
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: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be | ||
with: | ||
tool-cache: false | ||
swap-storage: false | ||
#{{- end }}# | ||
- name: Setup tools | ||
uses: ./.github/actions/setup-tools | ||
with: | ||
tools: pulumictl, pulumicli, go, node, dotnet, python, java | ||
- name: Download bin | ||
uses: ./.github/actions/download-bin | ||
- name: Add local nuget source | ||
run: dotnet nuget add source ${{ github.workspace }}/nuget | ||
shell: bash | ||
- name: Download SDK | ||
uses: ./.github/actions/download-sdk | ||
with: | ||
language: ${{ inputs.language }} | ||
- name: Update path | ||
shell: bash | ||
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" | ||
- name: Install Python deps | ||
shell: bash | ||
run: |- | ||
pip3 install virtualenv==20.0.23 | ||
pip3 install pipenv | ||
#{{- if .Config.docker }}# | ||
- name: Run docker compose | ||
shell: bash | ||
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: ${{ inputs.aws-access-key-id }} | ||
aws-region: ${{ inputs.aws-region }} | ||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }} | ||
role-duration-seconds: 7200 | ||
role-session-name: #{{ .Config.provider }}#@githubActions | ||
role-to-assume: ${{ inputs.role-to-assume }} | ||
#{{- 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 | ||
shell: bash | ||
run: gcloud --quiet auth configure-docker | ||
#{{- end }}# | ||
#{{- if index .Config "setup-script" }}# | ||
- name: Run setup script | ||
shell: bash | ||
run: #{{ index .Config "setup-script" }}# | ||
#{{- end }}# | ||
- name: Install dependencies | ||
shell: bash | ||
run: make install_${{ matrix.language}}_sdk | ||
- name: Prepare upstream code | ||
shell: bash | ||
run: make upstream | ||
- name: Install gotestfmt | ||
uses: GoTestTools/gotestfmt-action@v2 | ||
with: | ||
token: ${{ inputs.token }} | ||
version: v2.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,16 @@ jobs: | |
with: | ||
version: ${{ needs.prerequisites.outputs.version }} | ||
|
||
test: | ||
name: Test | ||
needs: | ||
- prerequisites | ||
- build_sdk | ||
uses: ./.github/workflows/test.yml | ||
secrets: inherit | ||
with: | ||
version: ${{ needs.prerequisites.outputs.version }} | ||
|
||
generate_coverage_data: | ||
continue-on-error: true | ||
env: | ||
|
@@ -114,119 +124,6 @@ jobs: | |
RELEASE_BOT_KEY: ${{ secrets.RELEASE_BOT_KEY }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
test: | ||
name: test | ||
needs: | ||
- prerequisites | ||
- 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: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be | ||
with: | ||
tool-cache: false | ||
swap-storage: false | ||
#{{- end }}# | ||
- name: Checkout Repo | ||
uses: #{{ .Config.actionVersions.checkout }}# | ||
#{{- if .Config.checkoutSubmodules }}# | ||
with: | ||
submodules: #{{ .Config.checkoutSubmodules }}# | ||
#{{- end }}# | ||
- name: Setup tools | ||
uses: ./.github/actions/setup-tools | ||
with: | ||
tools: pulumictl, pulumicli, go, node, dotnet, python, java | ||
- name: Download bin | ||
uses: ./.github/actions/download-bin | ||
- run: dotnet nuget add source ${{ github.workspace }}/nuget | ||
- name: Download SDK | ||
uses: ./.github/actions/download-sdk | ||
with: | ||
language: ${{ matrix.language }} | ||
- name: Update path | ||
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" | ||
- name: Install Python deps | ||
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 .Config.sshPrivateKey }}# | ||
- name: Setup SSH key | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: #{{ .Config.sshPrivateKey }}# | ||
#{{- end }}# | ||
#{{- if .Config.integrationTestProvider }}# | ||
- name: Prepare upstream code | ||
run: make upstream | ||
#{{- end }}# | ||
#{{- if index .Config "setup-script" }}# | ||
- name: Run setup script | ||
run: #{{ index .Config "setup-script" }}# | ||
#{{- 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.integrationTestProvider }}# | ||
- name: Run provider tests | ||
working-directory: provider | ||
run: go test -v -json -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
#{{- end }}# | ||
- name: Run tests | ||
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: | ||
- nodejs | ||
- python | ||
- dotnet | ||
- go | ||
- java | ||
#{{- if .Config.extraTests }}# | ||
#{{ .Config.extraTests | toYaml | indent 2 }}# | ||
#{{ end }}# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,120 +28,15 @@ jobs: | |
version: ${{ needs.prerequisites.outputs.version }} | ||
|
||
test: | ||
name: test | ||
needs: | ||
name: Test | ||
needs: | ||
- prerequisites | ||
- 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: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be | ||
with: | ||
tool-cache: false | ||
swap-storage: false | ||
#{{- end }}# | ||
- name: Checkout Repo | ||
uses: #{{ .Config.actionVersions.checkout }}# | ||
#{{- if .Config.checkoutSubmodules }}# | ||
with: | ||
submodules: #{{ .Config.checkoutSubmodules }}# | ||
#{{- end }}# | ||
- name: Setup tools | ||
uses: ./.github/actions/setup-tools | ||
with: | ||
tools: pulumictl, pulumicli, go, node, dotnet, python, java | ||
- name: Download bin | ||
uses: ./.github/actions/download-bin | ||
- run: dotnet nuget add source ${{ github.workspace }}/nuget | ||
- name: Download SDK | ||
uses: ./.github/actions/download-sdk | ||
with: | ||
language: ${{ matrix.language }} | ||
- name: Update path | ||
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" | ||
- name: Install Python deps | ||
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 .Config.sshPrivateKey }}# | ||
- name: Setup SSH key | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: #{{ .Config.sshPrivateKey }}# | ||
#{{- end }}# | ||
#{{- if .Config.integrationTestProvider }}# | ||
- name: Prepare upstream code | ||
run: make upstream | ||
#{{- end }}# | ||
#{{- if index .Config "setup-script" }}# | ||
- name: Run setup script | ||
run: #{{ index .Config "setup-script" }}# | ||
#{{- 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.integrationTestProvider }}# | ||
- name: Run provider tests | ||
if: matrix.testTarget == 'local' | ||
working-directory: provider | ||
run: go test -v -json -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
#{{- end }}# | ||
- name: Run tests | ||
run: cd examples && go test -v -json -count=1 -cover -timeout 2h -tags=${{ | ||
matrix.language }} -parallel 4 . 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: | ||
- nodejs | ||
- python | ||
- dotnet | ||
- go | ||
- java | ||
uses: ./.github/workflows/test.yml | ||
secrets: inherit | ||
with: | ||
version: ${{ needs.prerequisites.outputs.version }} | ||
|
||
name: cron | ||
on: | ||
schedule: | ||
|
Oops, something went wrong.