Skip to content

Commit

Permalink
Reduce duplicate in integration tests
Browse files Browse the repository at this point in the history
As part of the 1.0 release, we removed service_account support from setup-gcloud, but many of the integration tests were actually duplicates now, since they used to test service_account. This updates the integration tests to run all the tests in a single job (reducing the number of times we install NPM packages and download gcloud).
  • Loading branch information
sethvargo committed Nov 10, 2022
1 parent d51b534 commit 4793f30
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 530 deletions.
161 changes: 161 additions & 0 deletions .github/workflows/integration.yml
@@ -0,0 +1,161 @@
name: 'Integration'

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:

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

jobs:
integration:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
runs-on: '${{ matrix.os }}'

permissions:
id-token: 'write'

steps:
- uses: 'actions/checkout@v3'
with:
node-version: '16.x'

- name: 'Build'
run: 'npm ci && npm run build'

# Default installation
- name: 'Install version'
uses: './'
with:
version: '374.0.0'

# Latest installation
- name: 'Install latest'
uses: './'
with:
version: 'latest'

# By default, there is no configuration
- name: 'Check defaults'
run: |-
./tests/expect-gcloud-config "$(cat << EOF
account: (unset)
project: (unset)
components:
EOF
)"
# Install components
- name: 'Install components'
uses: './'
with:
components: 'alpha,beta'

- name: 'Check components'
run: |-
./tests/expect-gcloud-config "$(cat << EOF
account: (unset)
project: (unset)
components: alpha,beta
EOF
)"
# Set a project ID
- name: 'Set project ID'
uses: './'
with:
project_id: '${{ secrets.SETUP_GCLOUD_IT_PROJECT_ID }}'

- name: 'Check project ID'
run: |-
./tests/expect-gcloud-config "$(cat << EOF
account: (unset)
project: ${{ secrets.SETUP_GCLOUD_IT_PROJECT_ID }}
components:
EOF
)"
# Authenticate via WIF
- name: 'Authenticate via WIF'
uses: 'google-github-actions/auth@main'
with:
workload_identity_provider: '${{ secrets.WIF_PROVIDER_NAME }}'
service_account: '${{ secrets.OIDC_AUTH_SA_EMAIL }}'

- name: 'Check WIF authentication'
run: |-
./tests/expect-gcloud-config "$(cat << EOF
account: ${{ secrets.OIDC_AUTH_SA_EMAIL }}
project: ${{ secrets.SETUP_GCLOUD_IT_PROJECT_ID }}
components:
EOF
)"
# Authenticate via SAKE
- name: 'Authenticate via SAKE'
uses: 'google-github-actions/auth@main'
with:
credentials_json: '${{ secrets.SETUP_GCLOUD_IT_KEY }}'

- name: 'Check WIF authentication'
run: |-
./tests/expect-gcloud-config "$(cat << EOF
account: ${{ secrets.OIDC_AUTH_SA_EMAIL }}
project: ${{ secrets.SETUP_GCLOUD_IT_PROJECT_ID }}
components:
EOF
)"
# This test ensures that the GOOGLE_APPLICATION_CREDENTIALS environment
# variable is shared with the container and that the path of the file is on
# the shared filesystem with the container and that the USER for the container
# has permissions to read the file.
docker:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
name: 'setup-gcloud with docker-based steps'
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false

permissions:
id-token: 'write'

steps:
- uses: 'actions/checkout@v3'

- uses: 'actions/setup-node@v3'
with:
node-version: '16.x'

- name: 'npm ci'
run: 'npm ci'

- name: 'npm build'
run: 'npm run build'

- uses: google-github-actions/auth@main
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER_NAME }}
service_account: ${{ secrets.OIDC_AUTH_SA_EMAIL }}

- name: 'setup-gcloud'
uses: './'

- name: 'docker'
uses: 'docker://alpine:3'
with:
entrypoint: '/bin/sh'
args: '-euc "test -n "${GOOGLE_APPLICATION_CREDENTIALS}" && test -r "${GOOGLE_APPLICATION_CREDENTIALS}"'

0 comments on commit 4793f30

Please sign in to comment.