@@ -20,28 +20,48 @@ jobs:
2020 # Build:
2121 #
2222 # - In order to save computation time the "app.catroweb" image is only build once during this build phase.
23- # Other jobs can download this image to reduce their build time. With several jobs + the matrix build total
23+ # Other jobs can re-use this image to reduce their build time. With several jobs + the matrix build total
2424 # computation time for this workflow can be highly reduced. This is important since we do not have unlimited
2525 # resources/machines to run the jobs.
2626 #
2727 build :
28- name : Build catroweb image
28+ name : Build Catroweb Image
2929 runs-on : ubuntu-latest
30+ outputs :
31+ image : ${{ steps.upload-artifact.outputs.artifact-path }}
3032 steps :
3133 - name : Checkout
3234 uses : actions/checkout@v4
3335
34- - name : Build catroweb app image
36+ - name : Set up Docker Buildx
37+ uses : docker/setup-buildx-action@v3
38+
39+ - name : Cache Docker layers
40+ uses : actions/cache@v3
41+ with :
42+ path : |
43+ ~/.docker/cache
44+ ~/.docker/buildx-cache
45+ key : ${{ runner.os }}-docker-${{ github.sha }}
46+ restore-keys : |
47+ ${{ runner.os }}-docker-
48+
49+ - name : Build Catroweb App Image
50+ run : |
51+ cd docker
52+ docker compose -f docker-compose.test.yaml build app.catroweb
53+
54+ - name : Save Docker Image
3555 run : |
3656 cd docker
37- docker-compose -f docker-compose.test.yaml build app.catroweb
38- docker save app.catroweb > catroweb-image.tar
57+ docker save app.catroweb | gzip > catroweb-image.tar.gz
3958
40- - name : Upload app.catroweb image
59+ - name : Upload Docker Image
4160 uses : actions/upload-artifact@v4
61+ id : upload-artifact
4262 with :
4363 name : catroweb-image
44- path : docker/catroweb-image.tar
64+ path : docker/catroweb-image.tar.gz
4565
4666 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4767 # PhpUnit:
@@ -54,48 +74,51 @@ jobs:
5474 # Keep in mind the report is not including the tests written for behat.
5575 #
5676 tests_phpunit :
57- name : PhpUnit
77+ name : PHPUnit
5878 needs : build
5979 runs-on : ubuntu-latest
6080 steps :
6181 - name : Checkout
6282 uses : actions/checkout@v4
6383
64- - name : Pull the latest images to build (Faster than caching)
65- run : |
66- cd docker
67- docker-compose -f docker-compose.test.yaml pull
68-
69- - name : Download app.catroweb image
84+ - name : Download Docker Image
7085 uses : actions/download-artifact@v4
7186 with :
7287 name : catroweb-image
7388 path : docker
7489
75- # artificial wait required for elastic services to be fully set-up
76- - name : Build
90+ - name : Load Docker Image
7791 run : |
7892 cd docker
79- docker load < catroweb-image.tar
80- docker-compose -f docker-compose.test.yaml up -d
93+ gunzip -c catroweb-image.tar.gz | docker load
94+
95+ - name : Build and Start Docker Containers
96+ run : |
97+ cd docker
98+ docker compose -f docker-compose.test.yaml up -d
8199 sleep 60
82100
83- - name : PhpUnit tests
84- run : docker exec app.catroweb bin/phpunit --coverage-html tests/TestReports/CoverageReports/PhpUnit --coverage-clover=tests/TestReports/CoverageReports/PhpUnit/coverage.xml
101+ - name : Run PHPUnit Tests
102+ run : |
103+ docker exec app.catroweb bin/phpunit --coverage-html tests/TestReports/CoverageReports/PhpUnit \
104+ --coverage-clover=tests/TestReports/CoverageReports/PhpUnit/coverage.xml
85105
86- - name : Upload code coverage report
106+ - name : Upload PHPUnit Code Coverage Report
87107 uses : actions/upload-artifact@v4
88108 if : always()
89109 with :
90110 name : PhpUnitTestReport
91111 path : tests/TestReports/CoverageReports/PhpUnit
92- - uses : codecov/codecov-action@v4
112+
113+ - name : Upload Coverage to Codecov
114+ uses : codecov/codecov-action@v4
93115 with :
94- # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
95116 file : tests/TestReports/CoverageReports/PhpUnit/coverage.xml
96117 flags : phpunit # optional
97118 name : codecov-umbrella # optional
98119
120+
121+
99122 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100123 # Behat:
101124 #
@@ -169,22 +192,21 @@ jobs:
169192 - name : Checkout
170193 uses : actions/checkout@v4
171194
172- - name : Pull the latest images to build (Faster than caching)
173- run : |
174- cd docker
175- docker-compose -f docker-compose.test.yaml pull
176-
177- - name : Download app.catroweb image
195+ - name : Download Docker Image
178196 uses : actions/download-artifact@v4
179197 with :
180198 name : catroweb-image
181199 path : docker
182200
183- - name : Build
201+ - name : Load Docker Image
184202 run : |
185203 cd docker
186- docker load < catroweb-image.tar
187- docker-compose -f docker-compose.test.yaml up -d
204+ gunzip -c catroweb-image.tar.gz | docker load
205+
206+ - name : Build and Start Docker Containers
207+ run : |
208+ cd docker
209+ docker compose -f docker-compose.test.yaml up -d
188210 sleep 30
189211
190212 # Test Run
@@ -198,10 +220,8 @@ jobs:
198220 run : |
199221 docker exec app.catroweb chmod -R 777 var
200222 docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} -f pretty \
201- |& tee tests/TestReports/Behat/${{ matrix.testSuite }}.log ; \
202- TEST_RUN_EXIT_CODE=${PIPESTATUS[0]}
203- echo "test-run-exit-code=$TEST_RUN_EXIT_CODE" > $GITHUB_ENV
204- ( exit $TEST_RUN_EXIT_CODE )
223+ |& tee tests/TestReports/Behat/${{ matrix.testSuite }}.log
224+ exit ${PIPESTATUS[0]}
205225
206226 # Missing steps are not rerun by behat, without this step they will be lost in the process
207227 # We must explicitly kill the pipeline if the log contains undefined steps
@@ -210,8 +230,8 @@ jobs:
210230 id : missing-check
211231 run : |
212232 if grep -q 'has missing steps. Define them with these snippets:' tests/TestReports/Behat/${{ matrix.testSuite }}.log; then
213- cat tests/TestReports/Behat/${{ matrix.testSuite }}.log;
214- false;
233+ cat tests/TestReports/Behat/${{ matrix.testSuite }}.log
234+ exit 1
215235 fi
216236
217237 # Pending steps are not rerun by behat, without this step they will be lost in the process
@@ -221,29 +241,37 @@ jobs:
221241 id : pending-check
222242 run : |
223243 if grep -q 'pending)' tests/TestReports/Behat/${{ matrix.testSuite }}.log; then
224- cat tests/TestReports/Behat/${{ matrix.testSuite }}.log;
225- false;
244+ cat tests/TestReports/Behat/${{ matrix.testSuite }}.log
245+ exit 1
226246 fi
227247
228248 # Chrome exception are problems that can't be fixed with a rerun. However, we can try to run the whole suite one more time
229- - name : Check that suite has NO chrome exceptions
249+ - name : Check for Chrome Exceptions
230250 if : always()
231251 id : chrome-exception-check
232252 run : |
233253 if grep -q '\[DMore\\ChromeDriver\\StreamReadException\]' tests/TestReports/Behat/${{ matrix.testSuite }}.log; then
234- cat tests/TestReports/Behat/${{ matrix.testSuite }}.log;
235- docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} -f pretty;
254+ cat tests/TestReports/Behat/${{ matrix.testSuite }}.log
255+ docker exec app.catroweb bin/behat -s ${{ matrix.testSuite }} -f pretty
236256 fi
237- - uses : codecov/codecov-action@v4
257+
258+ - name : Upload Behat Test Artifacts
259+ uses : actions/upload-artifact@v4
260+ with :
261+ name : logs_${{ matrix.testSuite }}
262+ path : |
263+ tests/TestReports/Behat/${{ matrix.testSuite }}.log
264+ tests/TestReports/TestScreenshots
265+
266+ - name : Upload Coverage to Codecov
267+ uses : codecov/codecov-action@v4
238268 with :
239- # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
240269 file : tests/TestReports/CoverageReports/Behat/coverage.xml
241270 flags : behat # optional
242271 name : codecov-umbrella # optional
243272 # fail_ci_if_error: true # optional (default = false)
244273
245- # Rerun #1
246- - name : 1st rerun for Behat ${{ matrix.testSuite }} tests
274+ - name : Rerun Behat Tests (1st Attempt)
247275 if : env.test-run-exit-code != '0'
248276 id : test-rerun-1
249277 continue-on-error : true
@@ -254,8 +282,7 @@ jobs:
254282 echo "test-run-exit-code=$TEST_RUN_EXIT_CODE" > $GITHUB_ENV
255283 ( exit $TEST_RUN_EXIT_CODE )
256284
257- # Rerun #2
258- - name : 2d rerun for Behat ${{ matrix.testSuite }} tests
285+ - name : Rerun Behat Tests (2nd Attempt)
259286 if : env.test-run-exit-code != '0'
260287 id : test-rerun-2
261288 continue-on-error : true
@@ -265,32 +292,20 @@ jobs:
265292 echo "test-run-exit-code=$TEST_RUN_EXIT_CODE" > $GITHUB_ENV
266293 ( exit $TEST_RUN_EXIT_CODE )
267294
268- # Rerun #3
269- - name : 3rd rerun for Behat ${{ matrix.testSuite }}
295+ - name : Rerun Behat Tests (3rd Attempt)
270296 if : env.test-run-exit-code != '0'
271297 id : test-rerun-3
272298 run : |
273299 docker exec app.catroweb bin/behat -f pretty -s ${{ matrix.testSuite }} --rerun
274300
275301 # # Failure debugging
276- - if : failure()
302+ - name : Debug Failure
303+ if : failure()
277304 run : |
278305 docker ps -a
279- echo "--- App ---"
306+ echo "--- App Logs ---"
280307 docker logs app.catroweb
281- echo "--- DB ---"
308+ echo "--- DB Logs ---"
282309 docker logs db.catroweb.test
283- echo "--- Chrome ---"
310+ echo "--- Chrome Logs ---"
284311 docker logs chrome.catroweb
285-
286- - uses : actions/upload-artifact@v4
287- if : failure()
288- with :
289- name : screenshots_${{ matrix.testSuite }}
290- path : tests/TestReports/TestScreenshots
291-
292- - uses : actions/upload-artifact@v4
293- if : failure()
294- with :
295- name : logs_${{ matrix.testSuite }}
296- path : var/log/test
0 commit comments