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
16 changes: 5 additions & 11 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ concurrency:
jobs:
integration:
env:
# project: jvs-ci
PROJECT_NUMBER: '1039479707997'
# project: jvs-ci-test
PROJECT_NUMBER: '1096923323432'
PROJECT_ID: 'jvs-ci-test'
KEYRING_ID: 'ci-keyring'

permissions:
contents: 'read'
Expand Down Expand Up @@ -49,15 +51,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@jvs-ci-test.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 @@ -12,25 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -u # -u makes bash error on undefined variables
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}"
printf "Argument project_id is %s\n" "${PROJECT_ID}"
printf "Argument keyring_id is %s\n" "${KEYRING_ID}"

export TEST_JVS_KMS_KEY_RING=$(terraform output key_ring)
export TEST_JVS_KMS_KEY_RING="projects/${PROJECT_ID}/locations/global/keyRings/${KEYRING_ID}"
export TEST_JVS_INTEGRATION=true

cd ${ROOT}
Expand Down
Loading