test: improvements to Report Schema tests #431
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
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI with Maven | |
on: | |
push: | |
branches: | |
- master | |
- "release/**" | |
pull_request: | |
branches: | |
- master | |
- "release/**" | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
jobs: | |
integration-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "11" | |
distribution: "adopt" | |
- name: Install and run linter over tests | |
run: | | |
npm install google-java-format | |
npx google-java-format --set-exit-if-changed -i $(git ls-files src/test/\*.java) | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml -Dmaven.test.skip | |
- name: Run integration tests with Maven | |
if: ${{ github.repository_owner == 'onfido' }} | |
run: mvn test | |
env: | |
ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }} | |
ONFIDO_SAMPLE_APPLICANT_ID: ${{ secrets.ONFIDO_SAMPLE_APPLICANT_ID }} | |
ONFIDO_SAMPLE_VIDEO_ID_1: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_1 }} | |
ONFIDO_SAMPLE_VIDEO_ID_2: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_2 }} | |
ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }} | |
ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: integration-tests | |
environment: delivery | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_ACTION_ACCESS_TOKEN }} | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "11" | |
distribution: "adopt" | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Install gpg secret key | |
run: | | |
echo "$GPG_KEY" > key.asc | |
gpg --import --no-tty --batch --yes key.asc | |
shell: bash | |
env: | |
GPG_KEY: ${{ secrets.GPG_SECRET_KEY }} | |
- name: Publish package | |
run: | | |
export GPG_TTY=$(tty) | |
mvn --settings .maven.xml -Dmaven.test.skip \ | |
-P release,sign-and-deliver clean deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Update CHANGELOG.md | |
run: | | |
TMP_FILE=$(mktemp) | |
RELEASE_VERSION=$(jq -r '.release' .release.json) | |
RELEASE_DATE=`date +'%dth %B %Y' | sed -E 's/^0//;s/^([2,3]?)1th/\11st/;s/^([2]?)2th/\12nd/;s/^([2]?)3th/\13rd/'` | |
SPEC_COMMIT_SHA=$(jq -r '.source.short_sha' .release.json) | |
SPEC_COMMIT_URL=$(jq -r '.source.repo_url + "/commit/" + .source.long_sha' .release.json) | |
SPEC_RELEASE_VERSION=$(jq -r '.source.version' .release.json) | |
SPEC_RELEASE_URL=$(jq -r '.source.repo_url + "/releases/tag/" + .source.version' .release.json) | |
echo -e "# Changelog\n\n## $RELEASE_VERSION $RELEASE_DATE\n\n" >| $TMP_FILE | |
echo -en "${{ github.event.release.body }}\nBased on Onfido OpenAPI spec " >> $TMP_FILE | |
if [ -z $SPEC_RELEASE_VERSION ]; then | |
echo "up to commit [$SPEC_COMMIT_SHA](${SPEC_COMMIT_URL})." >> $TMP_FILE | |
else | |
echo "version [$SPEC_RELEASE_VERSION](${SPEC_RELEASE_URL})." >> $TMP_FILE | |
fi | |
grep -v "^# Changelog" CHANGELOG.md >> $TMP_FILE | |
mv $TMP_FILE CHANGELOG.md | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git commit -m "Update CHANGELOG.md after library release" CHANGELOG.md | |
git push |