From f4712f7fb2df5e64d07233cbd0400b2ea1ac8420 Mon Sep 17 00:00:00 2001 From: xweiba Date: Fri, 11 Sep 2026 14:20:50 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=A5=91=E7=BA=A6=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=20CI=20=E4=B8=8E=20make=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/contract-tests.yml | 23 +++++++++++++++++++ .github/workflows/release.yml | 3 +++ Makefile | 5 ++++- Tests/run_all_contract_tests.sh | 33 ++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/contract-tests.yml create mode 100755 Tests/run_all_contract_tests.sh diff --git a/.github/workflows/contract-tests.yml b/.github/workflows/contract-tests.yml new file mode 100644 index 0000000..0cbeb1c --- /dev/null +++ b/.github/workflows/contract-tests.yml @@ -0,0 +1,23 @@ +name: Contract Tests + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + contract-tests: + runs-on: macos-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run contract tests + run: ./Tests/run_all_contract_tests.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2bd1604..2a40389 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,9 @@ jobs: - name: Install XcodeGen run: brew install xcodegen + - name: Run contract tests + run: ./Tests/run_all_contract_tests.sh + - name: Build unsigned IPA run: ./build.sh diff --git a/Makefile b/Makefile index d2290eb..9d280c1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: setup core ipa-unsigned verify-ipa +.PHONY: setup core ipa-unsigned verify-ipa test setup: ./Scripts/setup.sh @@ -12,3 +12,6 @@ ipa-unsigned: core verify-ipa: @test -n "$(IPA)" || (echo "Usage: make verify-ipa IPA=/absolute/path/to/signed.ipa" >&2; exit 2) ./Scripts/verify-ipa.sh --signed "$(IPA)" + +test: + ./Tests/run_all_contract_tests.sh diff --git a/Tests/run_all_contract_tests.sh b/Tests/run_all_contract_tests.sh new file mode 100755 index 0000000..c1b255c --- /dev/null +++ b/Tests/run_all_contract_tests.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +passed=0 +failed=0 +failed_scripts=() + +for script in "$ROOT"/Tests/*_test.sh; do + name="$(basename "$script")" + echo "==> $name" + if bash "$script"; then + echo "PASS: $name" + passed=$((passed + 1)) + else + echo "FAIL: $name" + failed_scripts+=("$name") + failed=$((failed + 1)) + fi +done + +echo "----------------------------------------" +echo "Contract tests: $passed passed / $failed failed" +if [ "$failed" -gt 0 ]; then + echo "Failed scripts:" + for name in "${failed_scripts[@]}"; do + echo " - $name" + done + exit 1 +fi + +echo "PASS: all contract tests"