Run unit and integration tests #373
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: Run unit and integration tests | |
on: | |
workflow_call: | |
workflow_dispatch: # Allow manual trigger | |
jobs: | |
test: | |
runs-on: self-hosted | |
env: | |
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Get entire history for SonarQube | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: temurin | |
cache: maven | |
- 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: | | |
ARTIFACTORY_URL=/artifactory/url | |
ARTIFACTORY_USER=/artifactory/user | |
ARTIFACTORY_PASSWORD=/artifactory/password | |
SONAR_HOST_URL=/sonarqube/url | |
SONAR_TOKEN=/sonarqube/token | |
- name: Assume role in AB2D dev account | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-region: ${{ vars.AWS_REGION }} | |
role-to-assume: ${{ vars.AB2D_DEV_ROLE }} | |
- name: Install Maven 3.6.3 | |
run: | | |
export PATH="$PATH:/opt/maven/bin" | |
echo "PATH=$PATH" >> $GITHUB_ENV | |
if mvn -v; then echo "Maven already installed" && exit 0; else echo "Installing Maven"; fi | |
tmpdir="$(mktemp -d)" | |
curl -LsS https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xzf - -C "$tmpdir" | |
sudo rm -rf /opt/maven | |
sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven | |
- name: Clean maven | |
run: | | |
mvn -ntp -U clean | |
- name: Run unit and integration tests | |
run: | | |
mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker | |
- name: SonarQube analysis | |
run: | | |
mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} package sonar:sonar -Dsonar.projectKey=ab2d-project -Dsonar.qualitygate.wait=true -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} |