-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (170 loc) · 8.01 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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/[email protected]
with:
dotnet-version: '8.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://github.community/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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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