Skip to content

Run Tests

Run Tests #568

Workflow file for this run

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Run Tests
on:
workflow_dispatch: {}
push:
branches: [ master ]
paths-ignore: [ '**.md' ]
pull_request:
# Branch settings require status checks before merging, so don't add paths-ignore.
branches: [ master ]
env:
VAULT_ADDR: https://clotho.broadinstitute.org:8200
VAULT_SERVICE_ACCOUNT_PATH: secret/dsde/terra/kernel/integration/toolsalpha/crl_janitor/app-sa
VAULT_CLIENT_SERVICE_ACCOUNT_PATH: secret/dsde/terra/kernel/integration/toolsalpha/crl_janitor/client-sa
VAULT_CLOUD_ACCESS_ACCOUNT_PATH: secret/dsde/terra/janitor-test/default/cloud-access-sa
# Where to store the retrieved service accounts credentials for Google integration tests.
SERVICE_ACCOUNT_FILE: src/test/resources/rendered/sa-account.json
SERVICE_ACCOUNT_CLIENT_FILE: src/test/resources/rendered/client-sa-account.json
SERVICE_ACCOUNT_CLOUD_ACCESS_FILE: src/test/resources/rendered/cloud-access-sa-account.json
jobs:
unit-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12.3
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: Skip version bump merges
id: skiptest
uses: ./.github/actions/bump-skip
with:
event-name: ${{ github.event_name }}
- name: Pull Vault image
if: steps.skiptest.outputs.is-bump == 'no'
run: docker pull vault:1.1.0
# Currently, there's no way to add capabilities to Docker actions on Git, and Vault needs IPC_LOCK to run.
- name: Get Vault token
if: steps.skiptest.outputs.is-bump == 'no'
id: vault-token-step
run: |
VAULT_TOKEN=$(docker run --rm --cap-add IPC_LOCK \
-e "VAULT_ADDR=${VAULT_ADDR}" \
vault:1.1.0 \
vault write -field token \
auth/approle/login role_id=${{ secrets.VAULT_APPROLE_ROLE_ID }} \
secret_id=${{ secrets.VAULT_APPROLE_SECRET_ID }})
echo ::add-mask::$VAULT_TOKEN
echo vault-token=$VAULT_TOKEN >> $GITHUB_OUTPUT
- name: Grant execute permission for render-config
if: steps.skiptest.outputs.is-bump == 'no'
run: chmod +x local-dev/render-config.sh
- name: Render configuration for tests
if: steps.skiptest.outputs.is-bump == 'no'
run: local-dev/render-config.sh ${{ steps.vault-token-step.outputs.vault-token }}
- name: Initialize Postgres DB
if: steps.skiptest.outputs.is-bump == 'no'
env:
PGPASSWORD: postgres
run: psql -h 127.0.0.1 -U postgres -f ./local-dev/local-postgres-init.sql
- name: Set up JDK 17
if: steps.skiptest.outputs.is-bump == 'no'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Cache Gradle packages
if: steps.skiptest.outputs.is-bump == 'no'
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: v1-${{ runner.os }}-gradle-${{ hashfiles('**/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle') }}
restore-keys: v1-${{ runner.os }}-gradle-${{ hashfiles('**/gradle-wrapper.properties') }}
- name: Grant execute permission for gradlew
if: steps.skiptest.outputs.is-bump == 'no'
run: chmod +x gradlew
- name: Check Javadoc
if: steps.skiptest.outputs.is-bump == 'no'
run: ./gradlew javadoc --scan
- name: Run unit tests
if: steps.skiptest.outputs.is-bump == 'no'
id: unit-test
run: ./gradlew unitTest --scan
- name: Run integration tests
if: steps.skiptest.outputs.is-bump == 'no'
id: integration-test
run: ./gradlew integrationTest --scan
- name: Upload Test Reports
if: always() && steps.skiptest.outputs.is-bump == 'no'
uses: actions/upload-artifact@v3
with:
name: Test Reports
path: build/reports/tests