Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract shared test workflows and action #1037

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading
Loading