-
-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (164 loc) · 4.98 KB
/
test.yml
File metadata and controls
189 lines (164 loc) · 4.98 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
184
185
186
187
188
189
name: Test
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
phar:
runs-on: ubuntu-24.04
outputs:
php-version: ${{ steps.setup-php.outputs.php-version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: shivammathur/setup-php@v2
id: setup-php
with:
php-version: '8.4'
coverage: none
tools: box:4
- uses: ramsey/composer-install@v3
with:
composer-options: --no-dev --prefer-dist
- run: box compile
- uses: actions/upload-artifact@v6
with:
name: phar
path: phar/composer-semver
if-no-files-found: error
build:
name: build (${{ matrix.runs-on }})
needs: phar
strategy:
matrix: &matrix
include:
- runs-on: ubuntu-24.04-arm
variant: linux_arm64
spc-variant: linux-aarch64
- runs-on: ubuntu-24.04
variant: linux_amd64
spc-variant: linux-x86_64
- runs-on: macos-15
variant: darwin_arm64
spc-variant: macos-aarch64
- runs-on: macos-15-intel
variant: darwin_amd64
spc-variant: macos-x86_64
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v6
with:
sparse-checkout: craft.yml
sparse-checkout-cone-mode: false
- name: Install spc
run: |
gh release download --repo crazywhalecc/static-php-cli --pattern "${PATTERN}" --output spc.tar.gz && \
mkdir -p /tmp/spc && \
tar -xvf spc.tar.gz --directory /tmp/spc && \
echo "/tmp/spc" >> "$GITHUB_PATH"
env:
PATTERN: spc-${{ matrix.spc-variant }}.tar.gz
GH_TOKEN: ${{ github.token }}
- uses: actions/download-artifact@v7
with:
name: phar
path: phar
- name: Restore cached micro.sfx
id: restore-micro-sfx
uses: actions/cache/restore@v5
with:
path: buildroot/bin/micro.sfx
key: micro-sfx-${{ runner.os }}-${{ runner.arch }}-${{ needs.phar.outputs.php-version }}-${{ hashFiles('craft.yml') }}
- name: Build micro.sfx
if: steps.restore-micro-sfx.outputs.cache-hit != 'true'
run: spc craft
env:
GITHUB_TOKEN: ${{ github.token }} # Not a typo.
- name: Cache micro.sfx
id: cache-micro-sfx
if: steps.restore-micro-sfx.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: buildroot/bin/micro.sfx
key: ${{ steps.restore-micro-sfx.outputs.cache-primary-key }}
- run: mkdir -p out
- run: spc micro:combine phar/composer-semver --output out/composer-semver
- uses: actions/upload-artifact@v6
with:
name: composer-semver_${{ matrix.variant }}
path: out/composer-semver
if-no-files-found: error
e2e:
name: e2e (${{ matrix.runs-on }})
needs: build
strategy:
matrix: *matrix
runs-on: ${{ matrix.runs-on }}
env:
GOFLAGS: '-mod=mod'
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- run: echo OS="$(go env GOOS)" >> $GITHUB_ENV
- run: echo ARCH="$(go env GOARCH)" >> $GITHUB_ENV
- uses: actions/download-artifact@v7
with:
name: composer-semver_${{ matrix.variant }}
path: out
- name: Grant the binary execute permission
run: chmod +x out/composer-semver
- name: Add the binary into PATH
run: echo "${WORKSPACE}/out" >> "$GITHUB_PATH"
env:
WORKSPACE: ${{ github.workspace }}
- name: Print the binary path
run: go test -count=1 -v ./internal
- run: go test -count=1 -shuffle=on ./...
merge:
needs:
- build
- e2e
runs-on: ubuntu-24.04
steps:
- name: Merge binary artifacts
uses: actions/upload-artifact/merge@v6
with:
name: binaries
pattern: composer-semver_*
separate-directories: true
delete-merged: true
dispatch:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs:
- e2e
- merge
permissions:
actions: write
runs-on: ubuntu-24.04
steps:
- name: Dispatch Release Workflow
run: |
gh workflow run release.yml \
--repo "${REPO}" \
--ref "${REF}" \
-f version="${VERSION}" \
-f run_id="${RUN_ID}"
env:
REPO: ${{ github.repository }}
REF: ${{ github.ref }}
VERSION: ${{ github.ref_name }}
RUN_ID: ${{ github.run_id }}
GH_TOKEN: ${{ github.token }}