Skip to content

PLT-189 github actions workflow for unit & integration testing #25

PLT-189 github actions workflow for unit & integration testing

PLT-189 github actions workflow for unit & integration testing #25

name: GitHub Actions Workflow
on:
pull_request:
workflow_dispatch: # Allow manual trigger
jobs:
build:
runs-on: self-hosted
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
E2E_ENVIRONMENT: 'CI'
AB2D_V2_ENABLED: 'true'
SEARCH_BENE_BATCH_SIZE: '10'
AWS_DEFAULT_REGION: "us-east-1"
WORKSPACE: ${{ github.workspace }}
AB2D_BFD_KEYSTORE_LOCATION: "${{ github.workspace }}/opt/ab2d/ab2d_bfd_keystore"
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
cache: maven
- name: Download bfd keystore
run: |
aws s3 cp s3://bcda-opensbx-access-logs/ab2d_sbx_keystore /tmp/ab2d_sbx_keystore
- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
ECR_REPO_ENV_AWS_ACCOUNT_NUMBER: ${{ vars.SBX_ACCOUNT_NUMBER }}
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
CC_TEST_REPORTER_ID=cc-test-reporter-id
- name: Assume role in target account
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::${{ vars.DEV_ACCOUNT_NUMBER }}:role/delegatedadmin/developer/github-actions-runner-role
- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
OKTA_CLIENT_ID=/okta/client-id
OKTA_CLIENT_PASSWORD=/okta/client-secret
SECONDARY_USER_OKTA_CLIENT_ID=/secondary-okta/client-id
SECONDARY_USER_OKTA_CLIENT_PASSWORD=/secondary-okta/client-secret
- name: Create ab2d workspace directory and copy in keystore
run: mkdir -p opt/ab2d
- name: Download Code Coverage
run: |
mkdir -p codeclimate
if [ ! -f ./codeclimate/cc-test-reporter ]; then
curl -L --no-progress-meter https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 \
> ./codeclimate/cc-test-reporter && chmod +x ./codeclimate/cc-test-reporter
fi
- name: Set directory permissions
run: |
chmod -R 777 /opt/actions-runner/_work/ab2d/ab2d/common/
# Add other commands if necessary
- name: Clean maven
run: |
mvn --version
mvn -U clean
- name: Run unit and integration tests
run: |
mvn -s settings.xml -X -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker