Add a testing framwork for backend: unit and integration testing (#11) #1
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: Build and Test with Maven | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
AU_BACKEND_HOST: "http://localhost:8900" | |
AU_FRONTEND_HOST: "http://localhost:3000" | |
AU_APP_API: "http://localhost:8900" | |
AU_APP_WEBSOCKET: "http://localhost:8900/portfolio" | |
AU_DB_PORT: "3306" | |
AU_DB_USER: "ioopm" | |
AU_DB_PASSWORD: "ioopm" | |
AU_GITHUB_ORG: "CHANGE_ME" | |
AU_GITHUB_USER: "CHANGE_ME" | |
AU_GITHUB_USER_SECRET: "CHANGE_ME" | |
AU_GITHUB_CLIENT_ID: "CHANGE_ME" | |
AU_GITHUB_CLIENT_SECRET: "CHANGE_ME" | |
AU_KEY_ALIAS: "tomcat" | |
AU_KEY_STORE: "${{ github.workspace }}/keystore/keystore.p12" | |
AU_KEY_STORE_PASSWORD: "password" | |
AU_KEY_STORE_TYPE: "PKCS12" | |
AU_PROFILE_PICTURE_DIR: "${{ github.workspace }}/profile_pictures/" | |
AU_BACKUP_DIR: "${{ github.workspace }}/au_backups/" | |
TERM: "xterm" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java 17 Temurin | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Project | |
run: mvn --batch-mode -DskipTests package | |
- name: Create Directories Needed for Tests | |
run: | | |
mkdir -p ./au_backups | |
mkdir -p ./profile_pictures | |
mkdir -p ./keystore | |
mkdir -p ./logs | |
working-directory: ${{ github.workspace }} | |
- name: Run Unit and Integration Tests | |
run: mvn --batch-mode -Dspring.profiles.active=test -Dmaven.test.failure.ignore=true verify | |
- name: Remove Directories after Testing | |
run: | | |
rm -rf ./au_backups | |
rm -rf ./profile_pictures | |
rm -rf ./keystore | |
rm -rf ./logs | |
working-directory: ${{ github.workspace }} | |
- name: Remove failsafe-summary.xml | |
run: rm -f target/failsafe-reports/failsafe-summary.xml | |
- name: Create Unit Tests Report | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: Unit Tests Report | |
path: target/surefire-reports/*.xml | |
reporter: java-junit | |
fail-on-error: true | |
- name: Create Integration Tests Report | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: Integration Tests Report | |
path: target/failsafe-reports/*.xml | |
reporter: java-junit | |
fail-on-error: true |