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

refactor: decouple terraform with integration test #73

Merged
merged 13 commits into from
Jun 28, 2022
15 changes: 4 additions & 11 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ concurrency:
jobs:
integration:
env:
# project: jvs-ci
PROJECT_NUMBER: '1039479707997'
# TODO: change it to jvs-test later
capri-xiyue marked this conversation as resolved.
Show resolved Hide resolved
# project: xiyue-jvs-test-8
PROJECT_NUMBER: '597007824015'

permissions:
contents: 'read'
Expand Down Expand Up @@ -49,15 +50,7 @@ jobs:
uses: 'google-github-actions/auth@ceee102ec2387dd9e844e01b530ccd4ec87ce955' # ratchet:google-github-actions/auth@v0
with:
workload_identity_provider: 'projects/${{ env.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-pool/providers/github-provider'
service_account: 'gh-access-sa@jvs-ci.iam.gserviceaccount.com'
token_format: 'access_token' # Needed for Terraform workaround

# TODO: Workload Identity doesn't work with GCS Provider.
# https://github.com/google-github-actions/auth/issues/89
- name: 'Workaround Terraform issue'
shell: 'bash'
run: |-
echo "GOOGLE_OAUTH_ACCESS_TOKEN=${{ steps.auth.outputs.access_token }}" >> $GITHUB_ENV
service_account: 'gh-access-sa@xiyue-jvs-test-8.iam.gserviceaccount.com'

- name: 'Install and configure gcloud'
uses: 'google-github-actions/setup-gcloud@877d4953d2c70a0ba7ef3290ae968eb24af233bb' # ratchet:google-github-actions/setup-gcloud@v0
Expand Down
20 changes: 4 additions & 16 deletions scripts/integration_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,10 @@

ROOT="$(cd "$(dirname "$0")/.." &>/dev/null; pwd -P)"

JVS_SERVICE_ACCOUNT="jvs-service-sa@jvs-ci.iam.gserviceaccount.com"
ROTATOR_SERVICE_ACCOUNT="rotator-sa@jvs-ci.iam.gserviceaccount.com"
PUB_KEY_SERVICE_ACCOUNT="pubkey-sa@jvs-ci.iam.gserviceaccount.com"
PROJECT_ID="jvs-ci"

CI_DIR=${ROOT}/terraform/modules/ci-run

cd $CI_DIR
terraform init
terraform apply -auto-approve \
-var="project_id=${PROJECT_ID}" \
-var="jvs_service_account=${JVS_SERVICE_ACCOUNT}" \
-var="rotator_service_account=${ROTATOR_SERVICE_ACCOUNT}" \
-var="public_key_service_account=${PUB_KEY_SERVICE_ACCOUNT}"

export TEST_JVS_KMS_KEY_RING=$(terraform output key_ring)
# TODO: change it to jvs-test later
capri-xiyue marked this conversation as resolved.
Show resolved Hide resolved
PROJECT_ID="xiyue-jvs-test-8"
KEYRING_ID="ci-keyring"
capri-xiyue marked this conversation as resolved.
Show resolved Hide resolved
export TEST_JVS_KMS_KEY_RING="projects/${PROJECT_ID}/locations/global/keyRings/${KEYRING_ID}"
export TEST_JVS_INTEGRATION=true

cd ${ROOT}
Expand Down