Skip to content
This repository was archived by the owner on Aug 28, 2022. It is now read-only.

Commit c942fc1

Browse files
authored
Merge pull request #3 from shrink/feature/build-artifacts
Expose PHPUnit and Psalm test reports as build artifacts
2 parents be5601e + 01a815a commit c942fc1

File tree

9 files changed

+1608
-487
lines changed

9 files changed

+1608
-487
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ trim_trailing_whitespace = true
1111
[*.md]
1212
trim_trailing_whitespace = false
1313

14-
[*.{yml,yaml}]
14+
[*.{yml,yaml,json}]
1515
indent_size = 2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
.env
66
.env.backup
77
.phpunit.result.cache
8+
artifacts/
9+
junit.xml

.gitlab-ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
image: docker:18
1+
image: docker:19
22

33
services:
44
- docker:dind
55

66
stages:
77
- build
88

9-
build:
9+
app:
1010
stage: build
11+
only:
12+
- branches
13+
- merge_requests
14+
- tags
1115
script:
12-
- docker build --tag test .
16+
- docker build .
17+
after_script:
18+
- CID=$(docker create $(docker images --format='{{.ID}}' | head -1))
19+
- docker cp ${CID}:/srv/artifacts .
20+
artifacts:
21+
reports:
22+
junit: artifacts/*.xml

.meta/githooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make insights
1+
make quality

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ COPY . /srv
4242
RUN composer dump-autoload
4343

4444
FROM dependencies as test
45-
RUN composer quality
45+
RUN composer quality || echo "error" > error.exit
46+
47+
RUN mv junit.xml artifacts/psalm.xml
48+
RUN [[ ! -f error.exit ]] && exit 0
4649

4750
FROM dependencies as clean
4851
RUN composer install --no-dev
4952
RUN composer dump-autoload --optimize
5053

5154
FROM php
5255
COPY . /srv
56+
COPY --from=test /srv/artifacts /srv/artifacts
5357
COPY --from=clean /srv/vendor /srv/vendor
58+
59+
WORKDIR /srv

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ begin:
1919
serve:
2020
docker-compose up
2121

22+
# Build the application Docker image
23+
build:
24+
docker build . && (docker images --format='{{.ID}}' | head -1)
25+
2226
# Run the application's quality check
2327
quality:
2428
${COMPOSER_COMMAND} quality

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@php artisan insights --ansi --no-interaction --config-path=config/insights.php"
6969
],
7070
"static": [
71-
"vendor/bin/psalm --long-progress"
71+
"vendor/bin/psalm --long-progress --report=junit.xml"
7272
]
7373
}
7474
}

0 commit comments

Comments
 (0)