Skip to content

Commit 0732c1f

Browse files
authored
Merge branch 'v3' into feat/clickhouse
2 parents 3f48413 + 9b64ad8 commit 0732c1f

63 files changed

Lines changed: 1606 additions & 323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ jobs:
120120
with:
121121
files: dist/${{ matrix.operating-system.filename }}
122122

123+
- name: "Deploy to self-hosted OSS (nightly)"
124+
# only run this step if the repository is static-php-cli and is push to v3 branch
125+
if: ${{ github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/v3' }}
126+
uses: static-php/upload-s3-action@v1.0.0
127+
with:
128+
aws_key_id: ${{ secrets.AWS_KEY_ID }}
129+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
130+
aws_bucket: ${{ secrets.AWS_BUCKET }}
131+
source_dir: "dist/"
132+
destination_dir: v3/spc-bin/nightly/
133+
endpoint: ${{ secrets.AWS_ENDPOINT }}
134+
123135
- name: "Deploy to self-hosted OSS (latest)"
124136
# only run this step if the repository is static-php-cli and is release tag
125137
if: ${{ github.repository == 'crazywhalecc/static-php-cli' && startsWith(github.ref, 'refs/tags/') }}

.github/workflows/tests.yml

Lines changed: 144 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Tests
1+
name: v3 Tests
22

33
on:
44
pull_request:
5-
branches: [ "main", "v3" ]
6-
types: [ opened, synchronize, reopened ]
5+
branches: [ "v3" ]
6+
types: [ opened, synchronize, reopened, labeled, unlabeled ]
77
paths:
88
- 'src/**'
99
- 'config/**'
@@ -15,6 +15,10 @@ on:
1515

1616
permissions: read-all
1717

18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
20+
cancel-in-progress: true
21+
1822
env:
1923
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2024

@@ -103,114 +107,171 @@ jobs:
103107
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
104108

105109
- name: "Run PHPUnit Tests"
106-
run: SPC_LIBC=glibc vendor/bin/phpunit tests/ --no-coverage
110+
run: vendor/bin/phpunit tests/ --no-coverage
107111

108-
define-matrix:
109-
if: false # TODO: enable when refactoring workflows
110-
name: "Define Matrix"
112+
check-gate:
113+
name: "Check: need-test label"
111114
runs-on: ubuntu-latest
112115
outputs:
113-
php: ${{ steps.gendef.outputs.php }}
114-
os: ${{ steps.gendef.outputs.os }}
116+
enabled: ${{ steps.gate.outputs.enabled }}
115117
steps:
116-
- name: "Checkout"
117-
uses: actions/checkout@v4
118+
- name: Check label
119+
id: gate
120+
run: |
121+
LABELS='${{ toJSON(github.event.pull_request.labels.*.name) }}'
122+
if echo "$LABELS" | grep -q '"need-test"'; then
123+
echo "enabled=true" >> "$GITHUB_OUTPUT"
124+
else
125+
echo "enabled=false" >> "$GITHUB_OUTPUT"
126+
fi
127+
128+
test-bot:
129+
name: "Test Bot: analyze PR"
130+
needs: check-gate
131+
if: needs.check-gate.outputs.enabled == 'true'
132+
runs-on: ubuntu-latest
133+
permissions:
134+
pull-requests: write
135+
contents: read
136+
outputs:
137+
need_test: ${{ steps.bot.outputs.need_test }}
138+
gen_matrix_args: ${{ steps.bot.outputs.gen_matrix_args }}
139+
gen_matrix_args_tier2: ${{ steps.bot.outputs.gen_matrix_args_tier2 }}
140+
php_versions: ${{ steps.bot.outputs.php_versions }}
141+
tier2: ${{ steps.bot.outputs.tier2 }}
142+
steps:
143+
- uses: actions/checkout@v4
118144

119-
- name: "Setup PHP"
145+
- name: Setup PHP
120146
uses: shivammathur/setup-php@v2
121147
with:
122-
php-version: 8.4
148+
php-version: '8.4'
123149
extensions: curl, openssl, mbstring
150+
ini-values: memory_limit=-1
151+
tools: composer
152+
153+
- name: Install dependencies
154+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
124155

125-
- name: Define
126-
id: gendef
156+
- name: Run dev:test-bot
157+
id: bot
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127160
run: |
128-
PHP_VERSIONS=$(php src/globals/test-extensions.php php)
129-
OS_VERSIONS=$(php src/globals/test-extensions.php os)
130-
echo 'php='"$PHP_VERSIONS" >> "$GITHUB_OUTPUT"
131-
echo 'os='"$OS_VERSIONS" >> "$GITHUB_OUTPUT"
161+
BOT_JSON=$(php -d opcache.enable_cli=0 bin/spc dev:test-bot \
162+
--pr=${{ github.event.pull_request.number }} \
163+
--repo=${{ github.repository }} 2>/dev/null)
164+
165+
echo "need_test=$(echo "$BOT_JSON" | jq -r '.need_test')" >> "$GITHUB_OUTPUT"
166+
echo "gen_matrix_args=$(echo "$BOT_JSON" | jq -r '.gen_matrix_args')" >> "$GITHUB_OUTPUT"
167+
echo "gen_matrix_args_tier2=$(echo "$BOT_JSON" | jq -r '.gen_matrix_args_tier2')" >> "$GITHUB_OUTPUT"
168+
echo "php_versions=$(echo "$BOT_JSON" | jq -c '.php_versions')" >> "$GITHUB_OUTPUT"
169+
echo "tier2=$(echo "$BOT_JSON" | jq -r '.tier2')" >> "$GITHUB_OUTPUT"
170+
171+
COMMENT_BODY=$(echo "$BOT_JSON" | jq -r '.comment_body')
172+
MARKER="<!-- spc-test-bot -->"
173+
174+
# Find existing bot comment id
175+
EXISTING_ID=$(gh api \
176+
repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
177+
--jq "[.[] | select(.body | startswith(\"$MARKER\")) | .id] | first // empty")
178+
179+
if [ -n "$EXISTING_ID" ]; then
180+
gh api --method PATCH \
181+
repos/${{ github.repository }}/issues/comments/"$EXISTING_ID" \
182+
-f body="$COMMENT_BODY"
183+
else
184+
gh pr comment ${{ github.event.pull_request.number }} \
185+
--repo ${{ github.repository }} \
186+
--body "$COMMENT_BODY"
187+
fi
188+
189+
gen-matrix:
190+
name: "Generate test matrix"
191+
needs: test-bot
192+
if: needs.test-bot.outputs.need_test == 'true'
193+
runs-on: ubuntu-latest
194+
outputs:
195+
matrix: ${{ steps.build.outputs.matrix }}
196+
steps:
197+
- uses: actions/checkout@v4
132198

199+
- name: Setup PHP
200+
uses: shivammathur/setup-php@v2
201+
with:
202+
php-version: '8.4'
203+
extensions: curl, openssl, mbstring
204+
ini-values: memory_limit=-1
205+
tools: composer
206+
207+
- name: Install dependencies
208+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
133209

134-
build:
135-
if: false
136-
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
137-
runs-on: ${{ matrix.os }}
138-
needs: [define-matrix, php-cs-fixer, phpstan, phpunit]
210+
- name: Build matrix
211+
id: build
212+
env:
213+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
214+
GEN_MATRIX_ARGS: ${{ needs.test-bot.outputs.gen_matrix_args }}
215+
GEN_MATRIX_ARGS_TIER2: ${{ needs.test-bot.outputs.gen_matrix_args_tier2 }}
216+
PHP_VERSIONS: ${{ needs.test-bot.outputs.php_versions }}
217+
TIER2: ${{ needs.test-bot.outputs.tier2 }}
218+
run: |
219+
# Tier1 matrix
220+
MATRIX1=$(bin/spc dev:gen-ext-test-matrix $GEN_MATRIX_ARGS 2>/dev/null)
221+
222+
# Merge Tier2 if requested
223+
if [ "$TIER2" = "true" ] && [ -n "$GEN_MATRIX_ARGS_TIER2" ]; then
224+
MATRIX2=$(bin/spc dev:gen-ext-test-matrix $GEN_MATRIX_ARGS_TIER2 2>/dev/null)
225+
COMBINED=$(jq -n --argjson m1 "$MATRIX1" --argjson m2 "$MATRIX2" '$m1 + $m2')
226+
else
227+
COMBINED=$MATRIX1
228+
fi
229+
230+
# Expand PHP versions: cartesian product of entries × php_versions
231+
FINAL=$(echo "$COMBINED" | jq --argjson versions "$PHP_VERSIONS" \
232+
'[.[] | . as $entry | $versions[] | $entry + {"php-version": .}]')
233+
234+
echo "matrix=$(echo "$FINAL" | jq -c '{"combo": .}')" >> "$GITHUB_OUTPUT"
235+
236+
ext-test:
237+
name: "Ext test: ${{ matrix.combo.extension }} (PHP ${{ matrix.combo.php-version }} · ${{ matrix.combo.os }}-${{ matrix.combo.arch }})"
238+
needs: gen-matrix
239+
runs-on: ${{ matrix.combo.runner }}
139240
timeout-minutes: 120
140241
strategy:
141-
matrix:
142-
php: ${{ fromJSON(needs.define-matrix.outputs.php) }}
143-
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
144242
fail-fast: false
243+
matrix: ${{ fromJSON(needs.gen-matrix.outputs.matrix) }}
145244
steps:
146-
- name: "Update runner packages"
147-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
148-
run: sudo apt-get update && sudo apt-get install -y ca-certificates
245+
- uses: actions/checkout@v4
149246

150-
- name: "Checkout"
151-
uses: actions/checkout@v4
152-
153-
- name: "Setup PHP"
247+
- name: Setup PHP
154248
uses: shivammathur/setup-php@v2
155249
with:
156250
php-version: 8.4
157-
tools: pecl, composer
158251
extensions: curl, openssl, mbstring
159252
ini-values: memory_limit=-1
253+
tools: composer
160254
env:
161255
phpts: nts
162256

163-
- name: "Cache composer packages"
164-
id: composer-cache
165-
uses: actions/cache@v4
166-
with:
167-
path: vendor
168-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
169-
restore-keys: |
170-
${{ runner.os }}-php-
171-
172-
# Cache downloaded source
173-
- id: cache-download
174-
uses: actions/cache@v4
175-
with:
176-
path: downloads
177-
key: php-dependencies-${{ matrix.os }}
178-
179-
- name: "Install Dependencies"
180-
run: composer update -vvv --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-plugins
181-
182-
- name: "Run Build Tests (doctor)"
183-
run: php src/globals/test-extensions.php doctor_cmd ${{ matrix.os }} ${{ matrix.php }}
184-
185-
- name: "Prepare UPX for Windows"
186-
if: ${{ startsWith(matrix.os, 'windows-') }}
187-
run: |
188-
php src/globals/test-extensions.php install_upx_cmd ${{ matrix.os }} ${{ matrix.php }}
189-
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $env:GITHUB_ENV
257+
- name: Install dependencies
258+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
190259

191-
- name: "Prepare UPX for Linux"
192-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
260+
- name: Build
261+
env:
262+
SPC_USE_SUDO: "yes"
263+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193264
run: |
194-
php src/globals/test-extensions.php install_upx_cmd ${{ matrix.os }} ${{ matrix.php }}
195-
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV
196-
197-
- name: "Run Build Tests (download)"
198-
run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
199-
200-
- name: "Run Build Tests (build)"
201-
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}
265+
./bin/spc doctor --auto-fix
266+
${{ matrix.combo.build-args }} --dl-with-php=${{ matrix.combo.php-version }}
202267
203-
- name: "Run Build Tests (build - embed for non-windows)"
204-
if: ${{ !startsWith(matrix.os, 'windows-') }}
205-
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
268+
# - name: Setup upterm session
269+
# if: ${{ failure() }}
270+
# uses: owenthereal/action-upterm@v1
206271

207-
- name: "Upload logs"
208-
if: ${{ always() && hashFiles('log/**') != '' }}
209-
uses: actions/upload-artifact@v7
272+
- name: Upload logs
273+
if: always() && hashFiles('log/**') != ''
274+
uses: actions/upload-artifact@v4
210275
with:
211-
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
276+
name: logs-${{ matrix.combo.os }}-${{ matrix.combo.arch }}-${{ matrix.combo.extension }}-php${{ matrix.combo.php-version }}
212277
path: log
213-
214-
# - name: Setup tmate session
215-
# if: ${{ failure() }}
216-
# uses: mxschmitt/action-tmate@v3

.github/workflows/vitepress-deploy.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
name: Docs Auto Deploy
1+
name: Docs build test and auto deploy
22
on:
3+
pull_request:
4+
branches: [ "v3" ]
5+
types: [ opened, synchronize, reopened ]
6+
paths:
7+
- 'config/**.yml'
8+
- 'docs/**'
9+
- 'package.json'
10+
- 'yarn.lock'
11+
- '.github/workflows/vitepress-deploy.yml'
312
push:
4-
branches:
5-
- v3
13+
branches: [ "v3" ]
614
paths:
715
- 'config/**.yml'
816
- 'docs/**'
@@ -20,15 +28,8 @@ jobs:
2028
uses: actions/checkout@v4
2129

2230
- uses: actions/setup-node@v3
23-
with:
24-
cache: yarn
2531

26-
- run: yarn install --frozen-lockfile
27-
28-
- name: "Copy Config Files"
29-
run: |
30-
mkdir -p docs/.vitepress/config
31-
cp -r config/* docs/.vitepress/config/
32+
- run: npm install
3233

3334
- name: "Install PHP for official runners"
3435
uses: shivammathur/setup-php@v2
@@ -55,19 +56,13 @@ jobs:
5556
- name: "Install Locked Dependencies"
5657
run: "composer install --no-interaction --no-progress"
5758

58-
# TODO: Uncomment when v3 gen commands are implemented
59-
# - name: "Generate Extension Support List"
60-
# run: |
61-
# bin/spc dev:gen-ext-docs > docs/en/guide/extensions.md
62-
# bin/spc dev:gen-ext-docs > docs/zh/guide/extensions.md
63-
# bin/spc dev:gen-ext-dep-docs > docs/en/guide/deps-map.md
64-
# bin/spc dev:gen-ext-dep-docs > docs/zh/guide/deps-map.md
65-
6659
- name: Build
67-
run: yarn docs:build
60+
run: npm run docs:build
6861

62+
# Deploy to GitHub Pages only when the workflow is triggered by a push to the v3 branch
6963
- name: Deploy to GitHub Pages
7064
uses: peaceiris/actions-gh-pages@v3
65+
if: github.event_name == 'push' && github.ref == 'refs/heads/v3'
7166
with:
7267
github_token: ${{ secrets.GITHUB_TOKEN }}
7368
publish_dir: docs/.vitepress/dist

README-zh.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141

4242
```bash
4343
# For Linux x86_64
44-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-x86_64
44+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
4545
# For Linux aarch64
46-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-aarch64
46+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64
4747
# macOS x86_64 (Intel)
48-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-x86_64
48+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64
4949
# macOS aarch64 (Apple)
50-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-aarch64
50+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64
5151
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
52-
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/latest/spc-windows-x64.exe
52+
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x64.exe
5353
```
5454

5555
对于 macOS 和 Linux,请先添加可执行权限:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141

4242
```bash
4343
# For Linux x86_64
44-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-x86_64
44+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
4545
# For Linux aarch64
46-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-aarch64
46+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64
4747
# macOS x86_64 (Intel)
48-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-x86_64
48+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64
4949
# macOS aarch64 (Apple)
50-
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-aarch64
50+
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64
5151
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
52-
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/latest/spc-windows-x64.exe
52+
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x64.exe
5353
```
5454

5555
For macOS and Linux, add execute permission first:

0 commit comments

Comments
 (0)