-
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (156 loc) · 6.33 KB
/
Copy pathphpunit83.yml
File metadata and controls
183 lines (156 loc) · 6.33 KB
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
182
183
# This file is part of the sshilko/php-sql-mydb package.
#
# (c) Sergei Shilko <contact@sshilko.com>
#
# MIT License
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
# @license https://opensource.org/licenses/mit-license.php MIT
name: 8.3 PHPUnit
on:
push:
branches: ["master"]
permissions:
contents: read
jobs:
build-containers:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-ci')"
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: List files
run: pwd && ls -l
- name: Cache Docker php-image
id: docker-php-image-cache
uses: actions/cache@v5
with:
path: /tmp/docker-save
key: ${{ runner.os }}-docker-php83-image-${{ hashFiles('build/Dockerfile.php83', 'composer.lock') }}
- name: Load cached Docker image
run: docker load -i /tmp/docker-save/snapshot.tar || true
if: steps.docker-php-image-cache.outputs.cache-hit == 'true'
- name: Build Docker image
run: ls -l && docker build -f build/Dockerfile.php83 --build-arg BUILDKIT_INLINE_CACHE=1 -t mydb/php-image --cache-from=mydb/php83-image-cache ./build
if: steps.docker-php-image-cache.outputs.cache-hit != 'true'
env:
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
- name: Tag Docker image
run: docker tag mydb/php-image mydb/php83-image-cache && mkdir -p /tmp/docker-save && docker save mydb/php83-image-cache -o /tmp/docker-save/snapshot.tar && ls -lh /tmp/docker-save || true
if: always() && steps.docker-php-image-cache.outputs.cache-hit != 'true'
build:
needs: build-containers
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-ci')"
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- name: Load cached app docker image
id: docker-php-image-cache
uses: actions/cache@v5
with:
path: /tmp/docker-save
key: ${{ runner.os }}-docker-php83-image-${{ hashFiles('build/Dockerfile.php83', 'composer.lock') }}
- name: Load cached Docker image
if: steps.docker-php-image-cache.outputs.cache-hit == 'true'
run: docker load -i /tmp/docker-save/snapshot.tar && docker tag mydb/php83-image-cache mydb/php83
- name: Build Docker image
if: steps.docker-php-image-cache.outputs.cache-hit != 'true'
run: docker build -f build/Dockerfile.php83 -t mydb/php83 ./build
timeout-minutes: 20
- name: Docker boot
env:
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
SERVICES_NAME: "mydb-app-php83 mydb-mysql80"
run: docker compose up -d --no-build $SERVICES_NAME
timeout-minutes: 3
- name: Wait for all services to become healthy
run: for SVC in "mydb-app-php83" "mydb-mysql80"; do while [ "\"healthy\"" != "$(docker inspect --format '{{json .State.Health.Status }}' ${SVC})" ];do docker compose ps && sleep 5; done; done
timeout-minutes: 5
- name: Sleep
run: sleep 4
- run: docker compose ps
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php83-${{ hashFiles('composer.lock') }}-composer-dev
- name: Docker install dependencies
run: docker compose exec -T mydb-app-php83 composer install
- name: Docker run PHPUnit
run: docker compose exec -T mydb-app-php83 composer app-phpunit
- name: Docker run PHPUnit with MySQL8.0 & Coverage
run: docker compose exec -T mydb-app-php83 composer app-phpunit-mydb-mysql80-coverage
- name: Docker run PHPUnit badge generation
id: app-phpunit-badges-coverage
continue-on-error: true
run: |
#3 attempts to generate badges
docker compose exec -T mydb-app-php83 composer app-phpunit-badges-coverage || \
docker compose exec -T mydb-app-php83 composer app-phpunit-badges-coverage || \
docker compose exec -T mydb-app-php83 composer app-phpunit-badges-coverage
# Docs: https://github.com/marketplace/actions/phpunit-coverage-badge
- name: Generate PHPUnit coverage badge
uses: timkrase/phpunit-coverage-badge@v1.2.0
with:
coverage_badge_path: "test/tmp/phpunit-coverage-badge.svg"
push_badge: false
report: test/tmp/phpunit-clover.xml
# https://github.com/actions/upload-artifact
- name: Upload PHPUnit artifacts
uses: actions/upload-artifact@v4
with:
name: phpunit-output
path: |
test/tmp/html
test/tmp/xml
test/tmp/phpunit-testdox-html.html
test/tmp/phpunit-testdox-text.txt
test/tmp/phpunit-clover.xml
test/tmp/phpunit-junit.xml
test/tmp/phpunit-cobertura.xml
test/tmp/phpunit-crap4j.xml
test/tmp/phpunit-coverage.txt
test/tmp/phpunit-coverage-badge.svg
test/tmp/phpunit-coverage-badge-lines.svg
test/tmp/phpunit-coverage-badge-classes.svg
test/tmp/phpunit-coverage-badge-methods.svg
retention-days: 1
badges:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 2
permissions: write-all
steps:
# https://github.com/actions/checkout
- name: Checkout pages branch
uses: actions/checkout@v5
with:
ref: pages
# https://github.com/marketplace/actions/download-a-build-artifact
- name: Download all PHPUnit artifacts
uses: actions/download-artifact@v4
with:
name: phpunit-output
path: php/phpunit83
- uses: nick-fields/retry@v3
name: Commit coverage details
continue-on-error: true
with:
timeout_seconds: 20
max_attempts: 3
retry_on: error
command: |
git status
git config user.name github-actions
git config user.email github-actions@github.com
git pull
git add php/phpunit83/*
git commit -m "generated phpunit artifacts from revision ${GITHUB_SHA::7}"
git push