Skip to content

Commit 002e477

Browse files
authored
Combine unit and e2e tests into a single GHA workflow + add e2e test reporter (#1281)
A recent pairing session with @longrunningprocess led us to want to try and combine all tests into a single workflow for efficiency and simplicity. Now that I know the status checks can still be separate for a single workflow, it makes sense to combine all tests into a single workflow and have separate reporters / checks.
1 parent 63fba00 commit 002e477

5 files changed

Lines changed: 62 additions & 59 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Unit Tests
1+
name: Tests
22

33
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
44
on:
@@ -9,6 +9,9 @@ defaults:
99
shell: bash
1010
working-directory: docker
1111

12+
env:
13+
DOCKER_BUILDKIT: 1
14+
1215
jobs:
1316
unit-tests:
1417
runs-on: ubuntu-latest
@@ -27,5 +30,24 @@ jobs:
2730
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
2831
if: always()
2932
with:
33+
check_name: Unit Test Results
3034
github_token: ${{ github.token }}
3135
files: docker/PhpUnitTests.xml
36+
37+
e2e-tests:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: satackey/action-docker-layer-caching@v0.0.11
43+
44+
- name: Run E2E Tests
45+
run: make e2e-tests-ci
46+
47+
- name: Publish Test Results
48+
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
49+
if: always()
50+
with:
51+
check_name: E2E Test Results
52+
github_token: ${{ github.token }}
53+
files: docker/e2e-results.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PhpUnitTests.xml
2+
docker/e2e-results.xml
23
src/assets/*
34
!src/assets/.gitkeep
45
src/cache/*

docker/Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@ dev: start
1212
.PHONY: e2e-tests
1313
e2e-tests: build
1414
docker-compose build app-for-e2e test-e2e
15-
ifeq ($(TEAMCITY_VERSION),$())
16-
# developer machine
1715
docker-compose restart app-for-e2e || docker-compose up -d app-for-e2e
1816
docker-compose run -e TEST_SPECS=$(TEST_SPECS) test-e2e
19-
else
20-
# teamcity CI
21-
docker-compose run -e TEAMCITY_VERSION=TEAMCITY_VERSION test-e2e
22-
endif
17+
18+
.PHONY: e2e-tests-ci
19+
e2e-tests-ci: build
20+
docker-compose build app-for-e2e test-e2e
21+
# "-" means continue running commands even if they error (failed tests)
22+
-docker-compose run -e GITHUB_ACTIONS=1 --name e2etests test-e2e
23+
docker cp e2etests:/data/e2e-output/junitresults.xml e2e-results.xml
24+
docker rm e2etests
2325

2426
.PHONY: unit-tests
2527
unit-tests:
26-
docker-compose build test-php
2728
docker-compose run test-php
2829

2930
.PHONY: unit-tests-ci
30-
unit-tests-ci: build
31-
docker-compose build test-php
31+
unit-tests-ci:
3232
docker-compose run --name unittests test-php
3333
docker cp unittests:/var/www/PhpUnitTests.xml .
34+
docker rm unittests
3435

3536
.PHONY: build
3637
build:

test/app/protractorConf.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,36 @@ exports.config = {
2828

2929
browser.driver.manage().window().maximize();
3030

31-
if (process.env.TEAMCITY_VERSION) {
32-
var jasmineReporters = require('jasmine-reporters');
33-
jasmine.getEnv().addReporter(new jasmineReporters.TeamCityReporter());
34-
} else {
35-
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
36-
jasmine.getEnv().addReporter(new SpecReporter({
37-
spec: {
38-
displayStacktrace: true
39-
}
40-
}));
41-
/*
42-
jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({
43-
verbosity: browser.params.verbosity, // [0 to 3, jasmine default 2]
44-
color: true,
45-
showStack: true
46-
}));
47-
*/
48-
var pauseOnFailure = {
49-
specDone: function (spec) {
50-
if (spec.status === 'failed') {
51-
debugger;
52-
}
53-
}
54-
};
31+
var jasmineReporters = require('jasmine-reporters');
32+
if (process.env.GITHUB_ACTIONS) {
33+
// https://github.com/angular/protractor-cookbook/tree/master/jasmine-junit-reports
34+
var junitReporter = new jasmineReporters.JUnitXmlReporter({
35+
savePath: 'e2e-output/',
36+
consolidateAll: true
37+
38+
// results written to file: e2e-output/junitresults.xml
5539

56-
// Uncomment to pause tests on first failure
57-
// jasmine.getEnv().addReporter(pauseOnFailure);
40+
});
41+
jasmine.getEnv().addReporter(junitReporter);
5842
}
43+
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
44+
jasmine.getEnv().addReporter(new SpecReporter({
45+
spec: {
46+
displayStacktrace: true
47+
}
48+
}));
49+
50+
// Uncomment to pause tests on first failure
51+
/*
52+
var pauseOnFailure = {
53+
specDone: function (spec) {
54+
if (spec.status === 'failed') {
55+
debugger;
56+
}
57+
}
58+
};
59+
jasmine.getEnv().addReporter(pauseOnFailure);
60+
*/
5961
},
6062
plugins: [failFast.init()],
6163
afterLaunch: function () {

0 commit comments

Comments
 (0)