From 22763250f96d59444d30573bf124dc3445f82803 Mon Sep 17 00:00:00 2001 From: hermes Date: Mon, 3 Aug 2026 15:08:16 +0800 Subject: [PATCH] add official Gitea Actions test cases (quickstart/checkout/contexts) --- .gitea/workflows/official-checkout.yml | 24 ++++++++++++++++ .gitea/workflows/official-contexts.yml | 35 ++++++++++++++++++++++++ .gitea/workflows/official-quickstart.yml | 22 +++++++++++++++ README.md | 12 +++++++- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/official-checkout.yml create mode 100644 .gitea/workflows/official-contexts.yml create mode 100644 .gitea/workflows/official-quickstart.yml diff --git a/.gitea/workflows/official-checkout.yml b/.gitea/workflows/official-checkout.yml new file mode 100644 index 0000000..3361957 --- /dev/null +++ b/.gitea/workflows/official-checkout.yml @@ -0,0 +1,24 @@ +# 官方用例 2: actions/checkout@v4 官方 Action 深度验证 +# 覆盖: 官方 action 在 Gitea 的兼容性 / 私有仓 clone 认证(GITHUB_TOKEN) / 内容与 commit 完整性 +name: Official Action - checkout +on: [push] + +jobs: + checkout: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: verify workspace content + run: | + set -e + echo "workspace=$GITHUB_WORKSPACE" + ls -la + test -f README.md || { echo "FAIL: README.md not found"; exit 1; } + echo "OK: repository checked out" + - name: verify commit info + run: | + set -e + test -n "$GITHUB_SHA" || { echo "FAIL: GITHUB_SHA empty"; exit 1; } + echo "sha=$GITHUB_SHA" + git log -1 --oneline + git rev-parse HEAD | grep -q "^${GITHUB_SHA}" && echo "OK: HEAD matches GITHUB_SHA" diff --git a/.gitea/workflows/official-contexts.yml b/.gitea/workflows/official-contexts.yml new file mode 100644 index 0000000..507fac4 --- /dev/null +++ b/.gitea/workflows/official-contexts.yml @@ -0,0 +1,35 @@ +# 官方用例 3: 上下文变量渲染与等价性(gitea.* vs github.*) +# 参考: https://docs.gitea.com/usage/actions/quickstart +# 断言官方文档演示脚本用到的全部上下文字段,并验证 gitea.* 与 GITHUB_* 环境变量一致 +name: Official Contexts +on: [push] + +jobs: + contexts: + runs-on: ubuntu-latest + steps: + - name: print gitea.* contexts + run: | + echo "gitea.actor=${{ gitea.actor }}" + echo "gitea.event_name=${{ gitea.event_name }}" + echo "gitea.ref=${{ gitea.ref }}" + echo "gitea.repository=${{ gitea.repository }}" + echo "gitea.sha=${{ gitea.sha }}" + echo "gitea.workspace=${{ gitea.workspace }}" + - name: print github.* envs + run: | + echo "GITHUB_ACTOR=$GITHUB_ACTOR" + echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME" + echo "GITHUB_REF=$GITHUB_REF" + echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" + echo "GITHUB_SHA=$GITHUB_SHA" + echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" + - name: assert gitea.* == github.* + run: | + set -e + [ "${{ gitea.actor }}" = "$GITHUB_ACTOR" ] || { echo "FAIL: actor"; exit 1; } + [ "${{ gitea.event_name }}" = "$GITHUB_EVENT_NAME" ] || { echo "FAIL: event_name"; exit 1; } + [ "${{ gitea.ref }}" = "$GITHUB_REF" ] || { echo "FAIL: ref"; exit 1; } + [ "${{ gitea.repository }}" = "$GITHUB_REPOSITORY" ] || { echo "FAIL: repository"; exit 1; } + [ "${{ gitea.sha }}" = "$GITHUB_SHA" ] || { echo "FAIL: sha"; exit 1; } + echo "OK: gitea.* and github.* are equivalent" diff --git a/.gitea/workflows/official-quickstart.yml b/.gitea/workflows/official-quickstart.yml new file mode 100644 index 0000000..1bdc377 --- /dev/null +++ b/.gitea/workflows/official-quickstart.yml @@ -0,0 +1,22 @@ +# 官方用例 1: Gitea Actions Quickstart 演示流水线(原样) +# 来源: https://docs.gitea.com/usage/actions/quickstart +# 覆盖: gitea.* 上下文渲染 / actions/checkout@v4 官方 action / job.status +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." diff --git a/README.md b/README.md index 0a2c53b..506359b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # test-runner -测试runner \ No newline at end of file +Gitea Actions runner 测试仓库。所有流水线均为官方用例,用于验证 runner 对官方流水线的兼容性。 + +## 测试用例 + +| 工作流 | 用例来源 | 覆盖点 | +|---|---|---| +| `.gitea/workflows/official-quickstart.yml` | Gitea 官方 Quickstart(原样) | gitea.* 上下文渲染、actions/checkout@v4、job.status | +| `.gitea/workflows/official-checkout.yml` | actions/checkout@v4(官方 Action) | 私有仓 clone 认证(GITHUB_TOKEN)、内容与 commit 完整性 | +| `.gitea/workflows/official-contexts.yml` | Gitea 官方 Quickstart 上下文 | gitea.* 全部字段渲染,及与 GITHUB_* 环境变量等价性断言 | + +触发方式:`on: [push]`,push 到 main 即全部触发。