PLT-189 github actions workflow for unit & integration testing #23
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
maven-version: '3.6.3' | |
- 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: Remove Maven Directory | |
run: | | |
if [ -d "/opt/maven/apache-maven-3.6.3" ]; then | |
sudo rm -rf /opt/maven/apache-maven-3.6.3 | |
echo "Maven directory removed." | |
else | |
echo "Maven directory does not exist." | |
fi | |
- name: Install Maven 3.6.3 | |
run: | | |
wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | |
tar xzvf apache-maven-3.6.3-bin.tar.gz | |
sudo mv apache-maven-3.6.3 /opt/maven | |
echo "PATH=$PATH:/opt/maven/bin" >> $GITHUB_ENV | |
- name: Create ab2d workspace directory and copy in keystore | |
run: sudo mkdir -p "$WORKSPACE/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: | | |
sudo chmod -R 777 /opt/actions-runner/_work/ab2d/ab2d/common/ | |
# Add other commands if necessary | |
- name: Clean maven | |
run: | | |
mvn --version | |
echo $WORKSPACE | |
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 | |
working-directory: ${{ github.workspace }} | |
- name: Cleanup - | |
run: | | |
sudo rm -rf /opt/actions-runner/_work/ab2d/ab2d/opt/ab2d |