From ca38d8fe86545a93e3d81a3369be3d093ff05399 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 2 Jul 2026 21:09:17 +0800 Subject: [PATCH] [Chore] (trace-replay): fetch fixture from mirror --- .github/scripts/fetch-trace-fixture-lfs.sh | 26 +++++++++-- .github/workflows/apk.yml | 52 ++++++++++++++++++++-- .github/workflows/test.yml | 48 ++++++++++++++++++-- 3 files changed, 117 insertions(+), 9 deletions(-) diff --git a/.github/scripts/fetch-trace-fixture-lfs.sh b/.github/scripts/fetch-trace-fixture-lfs.sh index 20ec0a0f..d8dab943 100644 --- a/.github/scripts/fetch-trace-fixture-lfs.sh +++ b/.github/scripts/fetch-trace-fixture-lfs.sh @@ -9,6 +9,7 @@ fi case_name="$1" fixture_dir="${2:-tools/trace_replay/fixtures}" python_bin="${PYTHON:-python3}" +mirror_base="${MOBILEGL_TRACE_FIXTURE_MIRROR_BASE:-https://repo.miawa.cn/mgl/tools/trace_replay/fixtures}" if ! command -v "${python_bin}" >/dev/null 2>&1 && command -v python >/dev/null 2>&1; then python_bin=python @@ -33,10 +34,29 @@ if [ "${case_name}" = "OpenRA" ]; then exit 0 fi -echo "Fetching LFS fixture files for ${case_name}: ${include}" +fetch_from_mirror() { + mkdir -p "${fixture_dir}" + for file in "${files[@]}"; do + local name + local url + name="$(basename "${file}")" + url="${mirror_base%/}/${name}" + echo "Fetching trace fixture from mirror: ${url}" + if ! curl -L --fail --retry 3 --retry-delay 2 -o "${file}.tmp" "${url}"; then + rm -f "${file}.tmp" + return 1 + fi + mv "${file}.tmp" "${file}" + done +} -git lfs install --local -git lfs pull --include="${include}" --exclude="" +if fetch_from_mirror; then + echo "Fetched trace fixture files for ${case_name} from mirror: ${include}" +else + echo "Mirror fetch failed for ${case_name}; falling back to Git LFS: ${include}" + git lfs install --local + git lfs pull --include="${include}" --exclude="" +fi for file in "${files[@]}"; do test -s "${file}" diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index e96f33ba..657e8993 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -133,13 +133,49 @@ jobs: runs-on: ubuntu-latest outputs: android: ${{ steps.trace-cases.outputs.android }} + names: ${{ steps.trace-cases.outputs.names }} steps: - name: Checkout repo uses: actions/checkout@v4 - name: Load trace cases id: trace-cases - run: echo "android=$(python3 tools/trace_replay/trace_cases.py --format github-apk)" >> "$GITHUB_OUTPUT" + run: | + echo "android=$(python3 tools/trace_replay/trace_cases.py --format github-apk)" >> "$GITHUB_OUTPUT" + echo "names=$(python3 tools/trace_replay/trace_cases.py --format names)" >> "$GITHUB_OUTPUT" + + trace-fixtures: + name: trace fixture (${{ matrix.case }}) + runs-on: ubuntu-latest + needs: trace-cases + strategy: + fail-fast: false + max-parallel: 4 + matrix: + case: ${{ fromJSON(needs.trace-cases.outputs.names) }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Fetch trace fixture + run: bash .github/scripts/fetch-trace-fixture-lfs.sh '${{ matrix.case }}' + + - name: Stage trace fixture + run: | + safe_case="$(printf '%s' '${{ matrix.case }}' | sed 's/[^A-Za-z0-9._-]/_/g')" + stage_dir="trace-fixtures/${safe_case}" + mkdir -p "${stage_dir}" + python3 tools/trace_replay/trace_cases.py --format fixture-files --case '${{ matrix.case }}' | + while IFS= read -r file; do + cp "${file}" "${stage_dir}/" + done + + - name: Upload trace fixture + uses: actions/upload-artifact@v4 + with: + name: MobileGL-trace-fixture-${{ matrix.case }} + path: trace-fixtures/** + if-no-files-found: error retrace: name: retrace (${{ matrix.backend.name }}, ${{ matrix.case.name }}) @@ -147,6 +183,8 @@ jobs: needs: - build - trace-cases + - trace-fixtures + if: ${{ always() && needs.build.result == 'success' && needs.trace-cases.result == 'success' }} timeout-minutes: 75 env: AVD_NAME: mobilegl-${{ matrix.backend.id }} @@ -170,8 +208,16 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Fetch trace fixture - run: bash .github/scripts/fetch-trace-fixture-lfs.sh '${{ matrix.case.name }}' + - name: Download trace fixture + uses: actions/download-artifact@v4 + with: + name: MobileGL-trace-fixture-${{ matrix.case.name }} + path: trace-fixture-download + + - name: Install trace fixture + run: | + mkdir -p tools/trace_replay/fixtures + find trace-fixture-download -type f -exec cp {} tools/trace_replay/fixtures/ \; - name: Set artifact metadata run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08aa5665..64f61087 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -342,6 +342,39 @@ jobs: id: trace-cases run: echo "names=$(python3 tools/trace_replay/trace_cases.py --format names)" >> "$GITHUB_OUTPUT" + trace-fixtures: + name: trace fixture (${{ matrix.case }}) + runs-on: ubuntu-latest + needs: trace-cases + strategy: + fail-fast: false + max-parallel: 4 + matrix: + case: ${{ fromJSON(needs.trace-cases.outputs.names) }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Fetch trace fixture + run: bash .github/scripts/fetch-trace-fixture-lfs.sh '${{ matrix.case }}' + + - name: Stage trace fixture + run: | + safe_case="$(printf '%s' '${{ matrix.case }}' | sed 's/[^A-Za-z0-9._-]/_/g')" + stage_dir="trace-fixtures/${safe_case}" + mkdir -p "${stage_dir}" + python3 tools/trace_replay/trace_cases.py --format fixture-files --case '${{ matrix.case }}' | + while IFS= read -r file; do + cp "${file}" "${stage_dir}/" + done + + - name: Upload trace fixture + uses: actions/upload-artifact@v4 + with: + name: trace-fixture-${{ matrix.case }} + path: trace-fixtures/** + if-no-files-found: error + retrace: name: retrace (${{ matrix.backend }}, ${{ matrix.case }}) runs-on: ubuntu-latest @@ -349,6 +382,8 @@ jobs: - build-linux - build-retrace - trace-cases + - trace-fixtures + if: ${{ always() && needs.build-linux.result == 'success' && needs.build-retrace.result == 'success' && needs.trace-cases.result == 'success' }} strategy: fail-fast: false max-parallel: 4 @@ -362,8 +397,16 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Fetch trace fixture - run: bash .github/scripts/fetch-trace-fixture-lfs.sh '${{ matrix.case }}' + - name: Download trace fixture + uses: actions/download-artifact@v4 + with: + name: trace-fixture-${{ matrix.case }} + path: trace-fixture-download + + - name: Install trace fixture + run: | + mkdir -p tools/trace_replay/fixtures + find trace-fixture-download -type f -exec cp {} tools/trace_replay/fixtures/ \; - name: Get CMake uses: lukka/get-cmake@latest @@ -449,4 +492,3 @@ jobs: path: retrace-summary/mobilegl-linux-retrace-overview.html archive: false if-no-files-found: error -