Skip to content

Commit

Permalink
Add initial opt-out-export workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gsf committed Mar 5, 2024
1 parent fc38139 commit 38bf901
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/opt-out-export-deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: opt-out-export dev deploy

on:
workflow_dispatch:

jobs:
deploy:
runs-on: self-hosted
environment: dev
defaults:
run:
working-directory: ./attribution-data-file-share
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
- name: Build opt-out-export zip file
run: ../gradlew buildZip
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-dev-github-actions
- name: Upload and reload
run: |
aws s3 cp --no-progress build/distributions/attributionDataShare.zip \
s3://ab2d-dev-opt-out-export-function/function-${{ github.sha }}.zip
aws lambda update-function-code --function-name ab2d-dev-opt-out-export \
--s3-bucket ab2d-dev-opt-out-export-function --s3-key function-${{ github.sha }}.zip
24 changes: 24 additions & 0 deletions .github/workflows/opt-out-export-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: opt-out-export prod deploy

on:
workflow_dispatch:

jobs:
deploy:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
environment: prod
steps:
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-prod-github-actions
- name: Promote lambda code from test to prod
run: |
aws s3 cp --no-progress \
s3://ab2d-test-opt-out-export-function/function-${{ github.sha }}.zip \
s3://ab2d-prod-opt-out-export-function/function-${{ github.sha }}.zip
aws lambda update-function-code --function-name ab2d-prod-opt-out-export \
--s3-bucket ab2d-prod-opt-out-export-function --s3-key function-${{ github.sha }}.zip
41 changes: 41 additions & 0 deletions .github/workflows/opt-out-export-deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: opt-out-export test (impl) deploy

on:
push:
paths:
- attribution-data-file-share/**
workflow_dispatch:

jobs:
deploy:
runs-on: self-hosted
environment: test
defaults:
run:
working-directory: ./attribution-data-file-share
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
- name: Build opt-out-export zip file
run: ../gradlew buildZip
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions
- name: Upload and reload
run: |
aws s3 cp --no-progress build/distributions/attributionDataShare.zip \
s3://ab2d-test-opt-out-export-function/function-${{ github.sha }}.zip
aws lambda update-function-code --function-name ab2d-test-opt-out-export \
--s3-bucket ab2d-test-opt-out-export-function --s3-key function-${{ github.sha }}.zip
26 changes: 26 additions & 0 deletions .github/workflows/opt-out-export-test-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: opt-out-export integration tests

on:
pull_request:
paths:
- .github/workflows/opt-out-export-test-integration.yml
- optout/**
workflow_call:
workflow_dispatch:

jobs:
# TODO Deploy first if triggered by push
trigger:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./attribution-data-file-share
steps:
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions
- name: Upload test file to the BFD bucket
run: |
aws events put-events --entries file://test/events.json # TODO Add events.json matching rule for lambda trigger
# TODO check bucket for export file
33 changes: 33 additions & 0 deletions .github/workflows/opt-out-export-test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: opt-out-export unit tests

on:
pull_request:
paths:
- .github/workflows/opt-out-export-test-unit.yml
- attribution-data-file-share/**
workflow_dispatch:

jobs:
test:
runs-on: self-hosted
defaults:
run:
working-directory: ./attribution-data-file-share
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-export lambda
run: ../gradlew test
2 changes: 1 addition & 1 deletion .github/workflows/opt-out-import-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/prodeloper/ab2d-prod-github-actions
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-prod-github-actions
- name: Promote lambda code from test to prod
run: |
aws s3 cp --no-progress \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/opt-out-import-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/testeloper/ab2d-test-github-actions
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions
- name: Upload and reload
run: |
aws s3 cp --no-progress build/distributions/optout.zip \
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/opt-out-import-test-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: opt-out-import integration tests

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

jobs:
# TODO Deploy first if triggered by push
upload:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./optout
steps:
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
# Note that we use the lambda role with access to the bucket
role-to-assume: arn:aws:iam::${{ secrets.TEST_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-opt-out-import-function
- name: Upload test file to the BFD bucket
run: |
aws s3 cp --no-progress src/test/resources/optOutDummy.txt \
s3://bfd-test-eft/bfdeft01/ab2d/in/testing.txt
# TODO Run another job to check database for update, then check bucket for response file

0 comments on commit 38bf901

Please sign in to comment.