204 lines (164 loc) · 6.07 KB
/
phar.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Compile PHAR"
on:
pull_request:
push:
branches:
- "**"
tags:
- '1.5.*'
env:
COMPOSER_ROOT_VERSION: "1.5.x-dev"
jobs:
compiler-tests:
name: "Compiler Tests"
runs-on: "ubuntu-latest"
timeout-minutes: 60
outputs:
checksum: ${{ steps.checksum.outputs.md5 }}
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 0
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"
- name: "Install compiler dependencies"
run: "composer install --no-interaction --no-progress --working-dir=compiler"
- name: "Compiler tests"
working-directory: "compiler"
run: "vendor/bin/phpunit -c tests/phpunit.xml tests"
- name: "Compiler PHPStan"
working-directory: "compiler"
run: "../bin/phpstan analyse -l 8 src tests"
- name: "Prepare for PHAR compilation"
working-directory: "compiler"
run: "php bin/prepare"
- name: "Compile PHAR"
working-directory: "compiler/build"
run: "php box.phar compile --no-parallel"
- name: "Run PHAR"
working-directory: "compiler"
run: "../tmp/phpstan.phar list"
- uses: actions/upload-artifact@v2
with:
name: phar-file
path: tmp/phpstan.phar
- name: "Delete PHAR"
run: "rm tmp/phpstan.phar"
- name: "Set autoloader suffix"
run: "composer config autoloader-suffix PHPStanChecksum"
- name: "Install libfaketime"
run: "sudo apt-get install -y libfaketime"
- name: "Test libfaketime"
run: "date"
env:
FAKETIME: 2017-10-11 08:58:00
LD_PRELOAD: libfaketime.so.1
- name: "Reset timestamps"
run: 'find . -type f -exec touch {} +'
env:
FAKETIME: 2017-10-11 08:58:00
LD_PRELOAD: /usr/local/lib/faketime/libfaketime.so.1
- name: "Compile PHAR for checksum"
working-directory: "compiler/build"
run: "php box.phar compile --no-parallel"
env:
PHAR_CHECKSUM: "1"
FAKETIME: 2017-10-11 08:58:00
LD_PRELOAD: /usr/local/lib/faketime/libfaketime.so.1
- name: "Unset autoloader suffix"
run: "composer config autoloader-suffix --unset"
- name: "Save checksum"
id: "checksum"
run: echo "::set-output name=md5::$(md5sum tmp/phpstan.phar)"
- name: "Delete checksum PHAR"
run: "rm tmp/phpstan.phar"
integration-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/integration-tests.yml@1.5.x
with:
ref: 1.5.x
extension-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/extension-tests.yml@1.5.x
with:
ref: 1.5.x
other-tests:
if: github.event_name == 'pull_request'
needs: compiler-tests
uses: phpstan/phpstan/.github/workflows/other-tests.yml@1.5.x
with:
ref: 1.5.x
commit:
if: "github.ref == 'refs/heads/1.5.x' || startsWith(github.ref, 'refs/tags/')"
needs: compiler-tests
name: "Commit PHAR"
runs-on: "ubuntu-latest"
timeout-minutes: 60
steps:
- name: "Configure GPG signing key"
run: echo "$GPG_SIGNING_KEY" | base64 --decode | gpg --import --no-tty --batch --yes
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
- name: "Get Git log"
id: git-log
run: echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/phpstan\/phpstan-src\/commit\//')
- name: "Checkout phpstan-dist"
uses: "actions/checkout@v2"
with:
repository: phpstan/phpstan
path: phpstan-dist
token: ${{ secrets.PAT }}
ref: 1.5.x
- name: "Download phpstan.phar"
uses: actions/download-artifact@v3
with:
name: phar-file
- name: "mv PHAR"
run: mv phpstan.phar phpstan-dist/phpstan.phar
- name: "chmod PHAR"
run: chmod 755 phpstan-dist/phpstan.phar
- name: "Update checksum"
run: echo ${{needs.compiler-tests.outputs.checksum}} > phpstan-dist/.phar-checksum
- name: "Sign PHAR"
working-directory: phpstan-dist
run: rm phpstan.phar.asc && gpg --command-fd 0 --pinentry-mode loopback -u "$GPG_ID" --batch --detach-sign --armor --output phpstan.phar.asc phpstan.phar
env:
GPG_ID: ${{ secrets.GPG_ID }}
- name: "Verify PHAR"
working-directory: phpstan-dist
run: "gpg --verify phpstan.phar.asc"
- name: "Set Git signing key"
working-directory: phpstan-dist
run: git config user.signingkey "$GPG_ID"
env:
GPG_ID: ${{ secrets.GPG_ID }}
- name: "Commit PHAR - development"
if: "!startsWith(github.ref, 'refs/tags/')"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: "Ondrej Mirtes"
commit_user_email: "ondrej@mirtes.cz"
commit_author: "Ondrej Mirtes <ondrej@mirtes.cz>"
commit_options: "--gpg-sign"
repository: phpstan-dist
commit_message: "Updated PHPStan to commit ${{ github.event.after }}\n\n${{ steps.git-log.outputs.log }}"
- name: "Commit PHAR - tag"
if: "startsWith(github.ref, 'refs/tags/')"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: "Ondrej Mirtes"
commit_user_email: "ondrej@mirtes.cz"
commit_author: "Ondrej Mirtes <ondrej@mirtes.cz>"
commit_options: "--gpg-sign"
repository: phpstan-dist
commit_message: "PHPStan ${{github.ref_name}}\n\n${{ steps.git-log.outputs.log }}"
tagging_message: ${{github.ref_name}}