Skip to content

Documentation review #88

Documentation review

Documentation review #88

Workflow file for this run

name: test-all
on:
push:
branches-ignore:
- 'dependabot/**' #avoid duplicates: only run the PR, not the commit
- 'gh-pages' #github pages do not trigger all tests
tags-ignore:
- 'v*' #avoid rerun existing commit on release
pull_request:
branches:
- 'main'
env:
TEST_POSTGRES_PWD: ${RANDOM}${RANDOM}${RANDOM}
#sqlserver must comply with password requirements (upper, lower, digit, symbol)
TEST_SQLSERVER_PWD: ${RANDOM}Ax.${RANDOM}${RANDOM}
TEST_ORACLE_PWD: ${RANDOM}${RANDOM}${RANDOM}
TEST_SQLITE_PWD: ""
TEST_H2_PWD: ""
jobs:
test-java:
runs-on: ubuntu-latest
#if: ${{ false }} # disable for now
strategy:
matrix:
scope: [UT, IT, Postgres, Sqlserver, Oracle]
fail-fast: false
permissions:
checks: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
# Starts the DBMS containers when applicable
- name: Launch Postgres
if: ${{ matrix.scope == 'Postgres' }}
run: |
docker run -d -p 5432:5432 --name test-postgres --restart unless-stopped \
-e POSTGRES_PASSWORD="$TEST_POSTGRES_PWD" \
-e TEST_POSTGRES_PWD="$TEST_POSTGRES_PWD" \
-v ${GITHUB_WORKSPACE}/setup/postgres:/docker-entrypoint-initdb.d \
postgres:14
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-postgres "END SETUP!"
- name: Launch Sqlserver
if: ${{ matrix.scope == 'Sqlserver' }}
run: |
docker stop test-sqlserver && docker rm test-sqlserver
docker run -d -p 1433:1433 --name test-sqlserver --restart unless-stopped \
-e SA_PASSWORD="$TEST_SQLSERVER_PWD" \
-e TEST_SQLSERVER_PWD="$TEST_SQLSERVER_PWD" \
-e "ACCEPT_EULA=Y" -e "MSSQL_PID=Developer" \
-v ${GITHUB_WORKSPACE}/setup/sqlserver:/setup.d \
mcr.microsoft.com/mssql/server:2017-latest
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-sqlserver "SQL Server is now ready for client connections"
# SQLServer does not have an on startup script, run it now
docker exec test-sqlserver bash -c "chmod u+x setup.d/sqlserver-setup.sh && ./setup.d/sqlserver-setup.sh"
- name: Launch Oracle
if: ${{ matrix.scope == 'Oracle' }}
run: |
docker run -d -p 1521:1521 --name test-oracle --restart unless-stopped \
-e ORACLE_PASSWORD=$TEST_ORACLE_PWD \
-e TEST_ORACLE_PWD="$TEST_ORACLE_PWD" \
-v ${GITHUB_WORKSPACE}/setup/oracle:/container-entrypoint-initdb.d \
gvenzl/oracle-xe:11.2.0.2-slim-faststart
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-oracle "DATABASE IS READY TO USE!"
# Run the tests UT, IT and those that require database server
- name: Test unit and aggregate surefire report - ${{ matrix.scope }}
if: ${{ matrix.scope == 'UT' }}
run: >
mvn test surefire-report:report -Daggregate=true -Dsurefire.failIfNoSpecifiedTests=false
-Dtest=!TestPostgres*,!TestSqlserver*,!TestOracle*,!IT*
-Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: Test with databases and aggregate surefire report - ${{ matrix.scope }}
if: ${{ matrix.scope != 'UT' && matrix.scope != 'IT' }}
run: >
mvn test surefire-report:report -Daggregate=true -Dsurefire.failIfNoSpecifiedTests=false
-Dtest=Test${{ matrix.scope }}*
-Dmaven.test.failure.ignore=true -U --no-transfer-progress
-Duser.timezone=Europe/Madrid
# NOTE: must specify a timezone to avoid oracle error ORA-01882: timezone region not found
# IT requires first running the tests outside of maven, then a test case compares results
# runs with surefire also
- name: Integration test execution - ${{ matrix.scope }}
if: ${{ matrix.scope == 'IT' }}
run: |
cd it
ant install
ant spring-petclinic
ant qacover-api
ant install-uber
ant qacover-uber
- name: Integration test results comparison - ${{ matrix.scope }}
if: ${{ matrix.scope == 'IT' }}
run: >
mvn test surefire-report:report -Daggregate=true -Dsurefire.failIfNoSpecifiedTests=false
-Dtest=IT*
-Dmaven.test.failure.ignore=true -U --no-transfer-progress
# Reporting
- name: Additional aggregated junit report
if: always()
uses: javiertuya/junit-report-action@v1.2.0
with:
surefire-files: "*/target/surefire-reports/TEST-*.xml"
report-dir: target/site
report-title: "Test Report: ${{ matrix.scope }} - Branch: ${{ github.ref_name }}"
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v3.8.0
with:
check_name: "test-result-${{ matrix.scope }}"
report_paths: "*/target/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: always()
name: Set unique jacoco.xml file names for each scope
#if not sonarqube will overwrite al jacoco files generated for the same module but different scopes
run: |
for file in */target/site/jacoco/jacoco.xml ; do mv $file ${file//jacoco.xml/jacoco-${{ matrix.scope }}.xml} ; done
ls -la */target/site/jacoco/*.xml
- name: Publish test report files
if: always()
uses: actions/upload-artifact@v3
with:
name: "test-report-files-${{ matrix.scope }}"
path: |
target/site
*/target/site/jacoco/jacoco*.xml
*/target/surefire-reports
*/target/failsafe-reports
*/target/*.html
*/target/*.log
- name: Publish additional test report files from IT artifacts
if: always() && matrix.scope == 'IT'
uses: actions/upload-artifact@v3
with:
name: "test-report-files-IT-artifacts"
path: |
it/*/target/surefire-reports
it/*/target/qacover
test-net:
runs-on: ubuntu-latest
permissions:
checks: write
defaults:
run:
working-directory: net
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: '6.0.x'
- name: Launch Sqlserver
run: |
docker stop test-sqlserver && docker rm test-sqlserver
docker run -d -p 1433:1433 --name test-sqlserver --restart unless-stopped \
-e SA_PASSWORD="$TEST_SQLSERVER_PWD" \
-e TEST_SQLSERVER_PWD="$TEST_SQLSERVER_PWD" \
-e "ACCEPT_EULA=Y" -e "MSSQL_PID=Developer" \
-v ${GITHUB_WORKSPACE}/setup/sqlserver:/setup.d \
mcr.microsoft.com/mssql/server:2017-latest
chmod u+x ../setup/wait-container-ready.sh && ../setup/wait-container-ready.sh test-sqlserver "SQL Server is now ready for client connections"
# SQLServer does not have an on startup script, run it now
docker exec test-sqlserver bash -c "chmod u+x setup.d/sqlserver-setup.sh && ./setup.d/sqlserver-setup.sh"
- name: Run test - ADO.NET
run: dotnet test --logger "trx;LogFileName=../../reports/qacover-report.trx" QACoverTest/QACoverTest.csproj
- name: Run test - Entity Framework
run: dotnet test --logger "trx;LogFileName=../../reports/qacover-report-ef.trx" QACoverTestEf/QACoverTestEf.csproj
- name: Junit html report
if: always()
uses: javiertuya/junit-report-action@v1.2.0
with:
net-trx-report: "net/reports/qacover-report.trx,net/reports/qacover-report-ef.trx"
net-surefire-folder: "net/target/surefire-reports"
surefire-files: "net/target/surefire-reports/TEST-*.xml"
report-dir: net/target/site
report-title: "Test Report: Net - Branch: ${{ github.ref_name }}"
- name: Generate report checks
if: always()
uses: mikepenz/action-junit-report@v3.8.0
with:
check_name: "test-result-Net"
report_paths: "net/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- name: Publish test report files
if: always()
uses: actions/upload-artifact@v3
with:
name: "test-report-files-Net"
path: |
net/target/site
net/target/surefire-reports
net/reports/qacover-report*.trx
net/reports/*.html
net/reports/*.log
# As a last step, checks that conversion works to detect potential incompatible changes in the java side.
# Note that updates on the java side are still made in the develop environment and pushed.
- name: Validate Sharpen Conversion - Prepare Java envrionment
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Validate Sharpen Conversion - Preprocess
if: always()
run: |
mvn -f ../pom.xml generate-sources -am
ant clean sharpen.preprocess
- name: Validate Sharpen Conversion - Sharpen
if: always()
uses: javiertuya/sharpen-action@v1.1.0
with:
working-dir: net
project-dir: sharpen-temp/java
sharpen-args: '@sharpen-all-options.txt'
- name: Validate Sharpen Conversion - Postprocess
if: always()
run: |
ls -la sharpen-temp/sharpen-temp.net
sudo chown -R $(id -u):$(id -g) sharpen-temp/sharpen-temp.net
ant sharpen.postprocess
dotnet build
test-report:
needs: [test-java, test-net]
#if: ${{ false }} # disable for now
#avoid publishing to Github pages PRs and dependabot branches
if: ${{ always() && github.event_name != 'pull_request' && !contains('/head/refs/dependabot/', github.ref) }}
runs-on: ubuntu-latest
# Configuration to deploy at github pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Downloads java test report files
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-UT"
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-Postgres"
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-Sqlserver"
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-Oracle"
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-IT"
# Net reports were zipped under a different root, specifies the path.
# Modifies the namespaces to allow differentiate from the java test results
- uses: actions/download-artifact@v3
if: always()
with:
name: "test-report-files-Net"
path: "net"
- if: always()
run: sed -i 's/Test4giis/Test4NET/g' net/target/surefire-reports/*
# Generates and uploads the html reports and the individual surefire reports for further reference
- name: Aggregated junit html report
if: always()
uses: javiertuya/junit-report-action@v1.2.0
with:
surefire-files: "**/target/surefire-reports/TEST-*.xml"
report-dir: target-ALL/site
report-title: "Test Report: ALL - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}"
- name: Index file to html reports
run: |
echo "<html><head><title>Latest Test Reports</title></head><body>" > target-ALL/site/index.html
echo "<h2>Latest Test Reports - Branch: ${{ github.ref_name }} - Run #${{ github.run_number }}</h2>" >> target-ALL/site/index.html
echo "<p><a href=\"junit-noframes/junit-noframes.html\">Single page reports</a></p>" >> target-ALL/site/index.html
echo "<p><a href=\"junit-frames/index.html\">Multiple page reports with frames</a></p>" >> target-ALL/site/index.html
echo "</body></html>" >> target-ALL/site/index.html
- if: always()
name: Publish test report files
uses: actions/upload-artifact@v3.1.2
with:
name: "test-report-ALL"
path: |
target-ALL/site
**/target/surefire-reports
**/target/*.html
**/target/*.log
**/reports/*.html
**/reports/*.log
# Deploy to GitHub Pages
# Some files (e.g. junit reports) have 600 permissions.
# As of upload-pages-artifact@v1.0.9, permissions must be set explicitly
# to 0755 (as indicated in warnings produced by v1.0.8)
- name: Fix permissions to actions/upload-pages-artifact@v2.0.0
run: sudo chmod -c -R 0755 target-ALL/site
- name: Upload artifact
if: always()
uses: actions/upload-pages-artifact@v2.0.0
with:
path: 'target-ALL/site'
- name: Deploy to GitHub Pages
if: always()
id: deployment
uses: actions/deploy-pages@v2.0.3
sonarqube:
needs: [test-java]
#if: ${{ false }} # disable for now
#This job fails when comming from a dependabot PR (can't read the sonarqube token for security reasons).
#Links to discussions and workaround at: https://github.com/giis-uniovi/samples-giis-template/issues/4
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: javiertuya/sonarqube-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
restore-artifact-name1: "test-report-files-UT"
restore-artifact-name2: "test-report-files-Postgres"
restore-artifact-name3: "test-report-files-Sqlserver"
restore-artifact-name4: "test-report-files-Oracle"
publish-java-snapshot:
#if: ${{ false }} # disable for now
#avoid publishing PRs and dependabot branches
if: ${{ github.event_name != 'pull_request' && !contains('/head/refs/dependabot/', github.ref) }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: javiertuya/branch-snapshots-action@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
java-version: '8'
mvn-deploy-args: '-P publish-github,uber -DskipTests=true -DskipITs=true -Dmaven.test.failure.ignore=false -Dsurefire.failIfNoSpecifiedTests=false -U --no-transfer-progress'
delete-old-snapshots: true
min-snapshots-to-keep: 8
always-keep-regex: "\\d*\\.\\d*\\.\\d*-main-SNAPSHOT$"