Skip to content

Commit

Permalink
PLT-311 Add unit test workflow for opt-out-import (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsf authored Jan 31, 2024
1 parent 6561223 commit 614a608
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 44 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/opt-out-import-deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and deploy opt-out-import to dev
name: opt-out-import dev deploy

on:
workflow_dispatch:
Expand All @@ -7,37 +7,30 @@ jobs:
deploy:
runs-on: self-hosted
environment: dev

defaults:
run:
working-directory: ./optout
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
- uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
- name: Build opt-out-import zip file
run: ./gradlew buildZip -b optout/build.gradle --console=plain

- name: Assume role in target account
uses: aws-actions/configure-aws-credentials@v3
run: ../gradlew buildZip
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.ACCOUNT_ROLE }}

- name: Upload and reload
run: |
aws s3 cp --no-progress optout/build/distributions/optout.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
aws s3 cp --no-progress build/distributions/optout.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
aws lambda update-function-code --function-name ab2d-dev-opt-out-import --s3-bucket ${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }} --s3-key function.zip
7 changes: 2 additions & 5 deletions .github/workflows/opt-out-import-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy opt-out-import to prod
name: opt-out-import prod deploy

on:
workflow_dispatch:
Expand All @@ -10,14 +10,11 @@ jobs:
id-token: write
runs-on: ubuntu-latest
environment: prod

steps:
- name: Assume role in target account
uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.ACCOUNT_ROLE }}

- name: Promote lambda code from test to prod
run: |
aws s3 cp --no-progress s3://${{ vars.OPT_OUT_IMPORT_TEST_ZIP_BUCKET }}/function.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/opt-out-import-deploy-sbx.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy opt-out-import to sbx (sandbox)
name: opt-out-import sbx (sandbox) deploy

on:
workflow_dispatch:
Expand All @@ -10,14 +10,11 @@ jobs:
id-token: write
runs-on: ubuntu-latest
environment: sbx

steps:
- name: Assume role in target account
uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.ACCOUNT_ROLE }}

- name: Promote lambda code from test to sbx
run: |
aws s3 cp --no-progress s3://${{ vars.OPT_OUT_IMPORT_TEST_ZIP_BUCKET }}/function.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
Expand Down
27 changes: 10 additions & 17 deletions .github/workflows/opt-out-import-deploy-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and deploy opt-out-import to test (impl)
name: opt-out-import test (impl) deploy

on:
push:
Expand All @@ -12,37 +12,30 @@ jobs:
deploy:
runs-on: self-hosted
environment: test

defaults:
run:
working-directory: ./optout
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
- uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
- name: Build opt-out-import zip file
run: ./gradlew buildZip -b optout/build.gradle --console=plain

- name: Assume role in target account
uses: aws-actions/configure-aws-credentials@v3
run: ../gradlew buildZip
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.ACCOUNT_ROLE }}

- name: Upload and reload
run: |
aws s3 cp --no-progress optout/build/distributions/optout.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
aws s3 cp --no-progress build/distributions/optout.zip s3://${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }}/function.zip
aws lambda update-function-code --function-name ab2d-test-opt-out-import --s3-bucket ${{ vars.OPT_OUT_IMPORT_ZIP_BUCKET }} --s3-key function.zip
33 changes: 33 additions & 0 deletions .github/workflows/opt-out-import-test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: opt-out-import unit tests

on:
pull_request:
paths:
- .github/workflows/opt-out-import-test-unit.yml
- optout/**
workflow_dispatch:

jobs:
test:
runs-on: self-hosted
defaults:
run:
working-directory: ./optout
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
SONAR_HOST_URL=/sonarqube/url
SONAR_TOKEN=/sonarqube/token
- name: Run unit tests for opt-out-import lambda
run: ../gradlew test

0 comments on commit 614a608

Please sign in to comment.