-
-
Notifications
You must be signed in to change notification settings - Fork 41
168 lines (141 loc) · 4.46 KB
/
build.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
name: Test
on:
push:
pull_request:
release:
types:
- published
jobs:
build:
runs-on: "ubuntu-22.04"
strategy:
fail-fast: false
matrix:
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
coverage-driver: [ 'pcov' ]
steps:
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v2.2
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist
- name: Coding Standard Checks
run: PHP_CS_FIXER_IGNORE_ENV=1 ./bin/php-cs-fixer fix --dry-run -v
- name: Static Analysis
run: ./bin/psalm
- name: Test
run: ./bin/phpunit -d memory_limit=-1 --coverage-clover clover.xml
- name: Upload coverage to Codecov
if: ${{ matrix.php-versions == '7.1' }}
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
phar:
runs-on: "ubuntu-20.04"
needs: build
steps:
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.1
tools: composer:v2.2
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
- name: Install dependencies
run: composer install --prefer-dist --no-dev -o
- name: "Compile phparkitect phar"
run: php bin/box.phar compile -c ./box.json
- name: "Check phar"
run: php ./phparkitect.phar
- name: "Rename phar to avoid conflicts"
run: mv ./phparkitect.phar phparkitect-${{ github.sha }}.phar
- name: "Upload phar file artifact"
uses: actions/upload-artifact@v3
with:
name: phar-artifact
path: ./phparkitect-${{ github.sha }}.phar
retention-days: 1
smoke-test-phar:
needs: phar
runs-on: "ubuntu-20.04"
strategy:
matrix:
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
coverage-driver: [ 'pcov' ]
steps:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
- name: "Download phar ./phparkitect-${{ github.sha }}.phar"
uses: actions/download-artifact@v3
with:
# will download phar in project root
name: phar-artifact
- name: "Smoke test phar"
run: php ./phparkitect-${{ github.sha }}.phar
publish_phar:
needs: [build, smoke-test-phar]
runs-on: "ubuntu-20.04"
if: github.event_name == 'release'
steps:
- name: "Download phar ./phparkitect-${{ github.sha }}.phar"
uses: actions/download-artifact@v3
with:
# will download phar in project root
name: phar-artifact
- name: Upload Release Asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./phparkitect-${{ github.sha }}.phar
asset_name: phparkitect.phar
tag: ${{ github.ref }}
publish_docker_images:
needs: [build, smoke-test-phar]
runs-on: "ubuntu-20.04"
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: phparkitect/phparkitect
tags: |
type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }}
type=ref,event=tag
flavor: |
latest=false
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}