add official Gitea Actions test cases (quickstart/checkout/contexts)
This commit is contained in:
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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 }}."
|
||||
@@ -1,3 +1,13 @@
|
||||
# test-runner
|
||||
|
||||
测试runner
|
||||
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 即全部触发。
|
||||
|
||||
Reference in New Issue
Block a user