ci: split style, build-test, and smoke jobs

This commit is contained in:
Qiu Yuzhou
2026-10-25 23:38:19 +08:00
parent e38d333a71
commit 3ace468e2a
4 changed files with 163 additions and 91 deletions
+69 -87
View File
@@ -14,111 +14,93 @@ concurrency:
group: ng2-ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ShadowsocksX-NG2
jobs:
checks:
name: ${{ matrix.gate == 'test' && 'Lint, test, build' || 'Smoke tests' }} (Xcode 27 arm64)
strategy:
fail-fast: false
matrix:
gate: [test, 'test:smoke']
style:
name: Style (Xcode 27 arm64)
runs-on: xcode-27
timeout-minutes: 60
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Prepare Homebrew download cache
id: homebrew-cache-key
run: |
brew info --json=v2 age go-task xcodegen swiftlint > "$RUNNER_TEMP/homebrew-formulae.json"
formula_hash=$(python3 - "$RUNNER_TEMP/homebrew-formulae.json" <<'PY'
import hashlib
import json
import sys
with open(sys.argv[1]) as source:
formulae = json.load(source)["formulae"]
versions = sorted(
(f["full_name"], f["versions"]["stable"], f["revision"], f["bottle"])
for f in formulae
)
print(hashlib.sha256(json.dumps(versions, sort_keys=True).encode()).hexdigest())
PY
)
echo "path=$(brew --cache)/downloads" >> "$GITHUB_OUTPUT"
echo "key=ng2-homebrew-downloads-v1-macos-$(sw_vers -productVersion)-$(uname -m)-$formula_hash" >> "$GITHUB_OUTPUT"
- name: Restore Homebrew download cache
id: homebrew-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- name: Set up dependencies
uses: ./.github/actions/setup-ng2
with:
path: ${{ steps.homebrew-cache-key.outputs.path }}
key: ${{ steps.homebrew-cache-key.outputs.key }}
- name: Install build tools and test dependencies
id: install-build-tools
env:
HOMEBREW_NO_AUTO_UPDATE: '1'
HOMEBREW_NO_INSTALL_CLEANUP: '1'
run: brew install age go-task xcodegen swiftlint
- name: Save Homebrew download cache
if: steps.install-build-tools.outcome == 'success' && steps.homebrew-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.homebrew-cache-key.outputs.path }}
key: ${{ steps.homebrew-cache-key.outputs.key }}
- name: Restore external binary archive cache
id: external-binary-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ShadowsocksX-NG2/.build/external-binary-archives
key: ng2-external-binaries-macos-arm64-${{ hashFiles('ShadowsocksX-NG2/Vendor/sslocal/manifest.json', 'ShadowsocksX-NG2/Vendor/v2ray-plugin/manifest.json', 'ShadowsocksX-NG2/Vendor/ck-client/manifest.json') }}
restore-keys: |
ng2-external-binaries-macos-arm64-
- name: Fetch and verify external binaries
id: fetch-external-binaries
working-directory: ShadowsocksX-NG2
env:
EXTERNAL_BINARY_CACHE_DIR: ${{ github.workspace }}/ShadowsocksX-NG2/.build/external-binary-archives
run: Scripts/fetch-external-binaries.sh
- name: Save external binary archive cache
if: steps.fetch-external-binaries.outcome == 'success' && steps.external-binary-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ShadowsocksX-NG2/.build/external-binary-archives
key: ng2-external-binaries-macos-arm64-${{ hashFiles('ShadowsocksX-NG2/Vendor/sslocal/manifest.json', 'ShadowsocksX-NG2/Vendor/v2ray-plugin/manifest.json', 'ShadowsocksX-NG2/Vendor/ck-client/manifest.json') }}
packages: go-task swiftlint
external-binaries: 'false'
- name: Check Swift formatting
if: matrix.gate == 'test'
working-directory: ShadowsocksX-NG2
run: task format:check
run: task --exit-code validate -- format:check
- name: Lint
if: matrix.gate == 'test'
working-directory: ShadowsocksX-NG2
run: task --exit-code lint
run: task --exit-code validate -- lint
- name: Test
working-directory: ShadowsocksX-NG2
run: task --exit-code validate -- ${{ matrix.gate }}
- name: Build
if: matrix.gate == 'test'
working-directory: ShadowsocksX-NG2
run: task --exit-code build
- name: Upload failed test evidence
- name: Upload failed validation evidence
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: validation-${{ strategy.job-index }}
name: validation-${{ github.job }}
path: ShadowsocksX-NG2/.build/validation/
include-hidden-files: true
retention-days: 7
if-no-files-found: warn
build-test:
name: Build and test (Xcode 27 arm64)
runs-on: xcode-27
timeout-minutes: 60
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up dependencies
uses: ./.github/actions/setup-ng2
- name: Build
run: task --exit-code validate -- build
- name: Test
run: task --exit-code validate -- test
- name: Upload failed validation evidence
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: validation-${{ github.job }}
path: ShadowsocksX-NG2/.build/validation/
include-hidden-files: true
retention-days: 7
if-no-files-found: warn
smoke:
name: Smoke tests (Xcode 27 arm64)
runs-on: xcode-27
timeout-minutes: 60
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up dependencies
uses: ./.github/actions/setup-ng2
- name: Smoke tests
run: task --exit-code validate -- test:smoke
- name: Upload failed validation evidence
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: validation-${{ github.job }}
path: ShadowsocksX-NG2/.build/validation/
include-hidden-files: true
retention-days: 7