Fix sqlserver linux regression: Migrate to sqlserver 2019 #603
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
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 | |
#avoids duplicate execution of pr from local repo, but allows pr from forked repos and dependabot | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/'))) | |
strategy: | |
matrix: | |
scope: [UT, Postgres, Sqlserver, Oracle] | |
fail-fast: false | |
permissions: | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
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:2019-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 --user root 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:21.3.0-slim | |
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-oracle "DATABASE IS READY TO USE!" | |
# Uses the trick: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache | |
# to simulate an updatable cache. If eventually we need to clear the cache, increase the V* number | |
- name: Rules cache | |
id: rules-cache | |
uses: actions/[email protected] | |
with: | |
path: qacover-core/.tdrules-cache | |
key: tdrules-cache-${{ matrix.scope }}-v1-${{ github.run_id }} | |
restore-keys: tdrules-cache-${{ matrix.scope }}-v1- | |
# Run the tests UT and those that require database server | |
- name: Test unit and aggregate surefire report - ${{ matrix.scope }} | |
if: ${{ matrix.scope == 'UT' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
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' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
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 | |
# Reporting | |
- name: Additional aggregated junit report | |
if: always() | |
uses: javiertuya/[email protected] | |
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/[email protected] | |
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@v4 | |
with: | |
name: "test-report-files-${{ matrix.scope }}" | |
path: | | |
target/site | |
*/target/site/jacoco/jacoco*.xml | |
*/target/surefire-reports | |
*/target/failsafe-reports | |
*/target/qacover-report | |
*/target/*.html | |
*/target/*.log | |
test-IT: | |
runs-on: ubuntu-latest | |
#if: ${{ false }} # disable for now | |
#avoids duplicate execution of pr from local repo, but allows pr from forked repos and dependabot | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/'))) | |
permissions: | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
# Can't use the setup-java cache because the poms of ITs are changed inside the job. | |
# Uses the same trick that in other jobs top simulate a writable cache | |
- name: Custom cache for IT | |
id: rules-cache | |
uses: actions/[email protected] | |
with: | |
path: /home/runner/.m2/repository #can't pass $HOME | |
key: setup-java-IT-maven-v1-${{ github.run_id }} | |
restore-keys: setup-java-IT-maven-v1- | |
# IT requires first running the tests outside of maven, then a test case compares results | |
# runs with surefire also | |
- name: Integration test execution - IT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd it | |
ant test-parallel | |
- run: ls -la $HOME/.m2/repository | |
- name: Integration test results comparison - ${{ matrix.scope }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: > | |
mvn test surefire-report:report -Daggregate=true -Dsurefire.failIfNoSpecifiedTests=false | |
-Dtest=IT* | |
-Dmaven.test.failure.ignore=true -U --no-transfer-progress | |
- name: Additional aggregated junit report | |
if: always() | |
uses: javiertuya/[email protected] | |
with: | |
surefire-files: "*/target/surefire-reports/TEST-*.xml" | |
report-dir: target/site | |
report-title: "Test Report: IT - Branch: ${{ github.ref_name }}" | |
- name: Generate report checks | |
if: always() | |
uses: mikepenz/[email protected] | |
with: | |
check_name: "test-result-IT" | |
report_paths: "*/target/surefire-reports/TEST-*.xml" | |
fail_on_failure: 'true' | |
- name: Publish test report files | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "test-report-files-IT" | |
path: | | |
target/site | |
it/index.html | |
**/target/qacover | |
*/target/surefire-reports | |
*/target/failsafe-reports | |
*/target/*.html | |
*/target/*.log | |
test-net: | |
runs-on: ubuntu-latest | |
#if: ${{ false }} # disable for now | |
#avoids duplicate execution of pr from local repo, but allows pr from forked repos and dependabot | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/'))) | |
permissions: | |
checks: write | |
defaults: | |
run: | |
working-directory: net | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
dotnet-version: '8.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:2019-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 --user root test-sqlserver bash -c "chmod u+x setup.d/sqlserver-setup.sh && ./setup.d/sqlserver-setup.sh" | |
- name: Rules cache | |
id: rules-cache | |
uses: actions/[email protected] | |
with: | |
path: net/.tdrules-cache | |
key: tdrules-cache-Net-v1-${{ github.run_id }} | |
restore-keys: tdrules-cache-Net-v1- | |
#- name: Enable snapshots | |
# run: dotnet nuget add source https://apiint.nugettest.org/v3/index.json -n int.nugettest.org | |
- name: Run test - ADO.NET | |
run: dotnet test --logger "trx;LogFileName=../../reports/qacover-report.trx" QACoverTest/QACoverTest.csproj | |
- name: Run test - Entity Framework | |
if: always() | |
run: dotnet test --logger "trx;LogFileName=../../reports/qacover-report-ef.trx" QACoverTestEf/QACoverTestEf.csproj | |
- name: Junit html report | |
if: always() | |
uses: javiertuya/[email protected] | |
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/[email protected] | |
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@v4 | |
with: | |
name: "test-report-files-Net" | |
path: | | |
net/target/site | |
net/target/surefire-reports | |
net/reports/qacover-report | |
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 | |
#if: ${{ false }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
cache: 'maven' | |
- name: Validate Sharpen Conversion - Preprocess | |
#if: ${{ false }} | |
run: | | |
mvn -f ../pom.xml generate-sources -am | |
ant clean sharpen.preprocess | |
- name: Validate Sharpen Conversion - Sharpen | |
#if: ${{ false }} | |
uses: javiertuya/[email protected] | |
with: | |
working-dir: net | |
project-dir: sharpen-temp/java | |
sharpen-args: '@sharpen-all-options.txt' | |
- name: Validate Sharpen Conversion - Postprocess | |
#if: ${{ false }} | |
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-IT, 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@v4 | |
if: always() | |
with: | |
name: "test-report-files-UT" | |
- uses: actions/download-artifact@v4 | |
if: always() | |
with: | |
name: "test-report-files-Postgres" | |
- uses: actions/download-artifact@v4 | |
if: always() | |
with: | |
name: "test-report-files-Sqlserver" | |
- uses: actions/download-artifact@v4 | |
if: always() | |
with: | |
name: "test-report-files-Oracle" | |
- uses: actions/download-artifact@v4 | |
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@v4 | |
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/[email protected] | |
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@v4 | |
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 [email protected], permissions must be set explicitly | |
# to 0755 (as indicated in warnings produced by v1.0.8) | |
- name: Fix permissions to actions/[email protected] | |
run: sudo chmod -c -R 0755 target-ALL/site | |
- name: Upload artifact | |
if: always() | |
uses: actions/[email protected] | |
with: | |
path: 'target-ALL/site' | |
- name: Deploy to GitHub Pages | |
if: always() | |
id: deployment | |
uses: actions/[email protected] | |
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/[email protected] | |
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' && !startsWith(github.ref, 'refs/heads/dependabot/') && !startsWith(github.ref, 'refs/heads/dashgit/combined/') }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: javiertuya/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
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$" |