Skip to content

1

1 #547

Workflow file for this run

name: Run Tests
on:
push:
tags-ignore:
- '**'
branches:
- '**'
workflow_dispatch:
inputs:
parallel:
description: 'Parallel suite dispatch'
type: boolean
default: true
permissions:
contents: read
actions: write
pull-requests: read
jobs:
run-tests:
runs-on: ubuntu-latest
env:
# 落盘始终写本分支;restore 由 pick 脚本在 miss 时选 diff 最近的分支缓存
TEST_DATA_CACHE_KEY: fount-test-data-${{ github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Wait for merge cache promote
if: github.ref_name == github.event.repository.default_branch && github.event_name == 'push'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
head_ref="$(gh api "repos/${GH_REPO}/commits/${GITHUB_SHA}/pulls" --jq '.[0].head.ref // empty')"
if [[ -z "${head_ref}" ]]; then
echo "commit not from a PR; skip promote wait"
exit 0
fi
echo "merge commit from head ${head_ref}; waiting for promote"
BRANCH="${head_ref}" bash .github/workflows/scripts/wait_test_data_cache_promote.sh
- name: Pick test data cache
id: pick-cache
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
TEST_DATA_CACHE_PREFIX: fount-test-data-
run: bash .github/workflows/scripts/pick_test_data_cache.sh
- name: Restore test data cache
if: steps.pick-cache.outputs.restore_key != ''
uses: actions/cache/restore@v5
with:
path: ./data/test
key: ${{ steps.pick-cache.outputs.restore_key }}
- uses: ./.github/actions/fount-ci
with:
run-step-name: Run tests
run-command: deno run --allow-scripts --allow-all -c "./deno.json" ./src/scripts/test/cli.mjs${{ (github.event_name == 'workflow_dispatch' && !inputs.parallel) && ' --no-parallel' || '' }}
deno-clean-entrypoints: ./src/scripts/test/cli.mjs
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
# 失败/取消也要落盘:imperfect wave 依赖 state;与 node_modules 的「仅成功更新」不同
- name: Delete Previous test data Cache
if: always()
continue-on-error: true
shell: bash
run: |
gh extension install actions/gh-actions-cache || true
gh actions-cache delete "$TEST_DATA_CACHE_KEY" --confirm || true
env:
GH_TOKEN: ${{ github.token }}
- name: clean test data before cache save
if: always()
continue-on-error: true
shell: bash
run: |
# 只保留增量所需的 state / panic 去重;丢弃日志与临时产物以控制缓存体积
rm -rf data/test/tmp data/test/playwright data/test/heapsnapshots data/test/state/logs
rm -f data/test/report.md data/test/report.json data/test/triggered-reasons.md
- name: Save test data Cache
if: always()
continue-on-error: true
uses: actions/cache/save@v5
with:
path: ./data/test
key: ${{ env.TEST_DATA_CACHE_KEY }}