ci: rework workflow for Gitea Actions (M0.2) #2

Merged
sharang merged 3 commits from fix/m0.2-gitea-friendly-ci into main 2026-05-18 19:42:35 +00:00
2 changed files with 34 additions and 10 deletions
Showing only changes of commit ca046f3ddb - Show all commits
+33 -10
View File
@@ -1,4 +1,5 @@
# CI for TypeScript / Next.js services. Copy to .gitea/workflows/ci.yaml in the repo.
# CI for TypeScript / Next.js services on Gitea Actions.
# `shared` always runs; `test`/`e2e`/`image` activate when package.json lands.
name: ci
on:
@@ -16,10 +17,34 @@ jobs:
- name: commitlint (PR only)
if: github.event_name == 'pull_request'
uses: wagoid/commitlint-github-action@v6
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
pattern='^(feat|fix|docs|chore|refactor|test|perf|build|ci|revert)(\([a-z0-9_/.-]+\))?!?: .{1,72}$'
bad=0
while IFS= read -r subject; do
if ! [[ "$subject" =~ $pattern ]]; then
echo "::error::Commit subject does not match Conventional Commits: $subject"
bad=$((bad+1))
fi
done < <(git log --format=%s "${BASE_SHA}..${HEAD_SHA}")
if [ "$bad" -gt 0 ]; then
echo "::error::$bad commit(s) failed commitlint."
exit 1
fi
echo "commitlint: OK"
- name: gitleaks
uses: gitleaks/gitleaks-action@v2
shell: bash
run: |
set -euo pipefail
GL_VERSION=8.18.4
curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${GL_VERSION}/gitleaks_${GL_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /tmp gitleaks
/tmp/gitleaks detect --source . --no-banner --redact --verbose --exit-code 1
- name: trivy fs scan
uses: aquasecurity/trivy-action@master
@@ -27,9 +52,11 @@ jobs:
scan-type: fs
severity: HIGH,CRITICAL
exit-code: 1
ignore-unfixed: true
test:
runs-on: docker
if: hashFiles('package.json') != ''
steps:
- uses: actions/checkout@v4
@@ -42,20 +69,18 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm typecheck
- run: pnpm test --coverage
- name: coverage gate
run: |
node -e "const c=require('./coverage/coverage-summary.json').total.lines.pct; if (c<70) { console.error('coverage', c, '< 70%'); process.exit(1) }"
- run: pnpm build
e2e:
needs: test
runs-on: docker
if: hashFiles('playwright.config.ts','playwright.config.js') != '' && github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
@@ -64,9 +89,7 @@ jobs:
with: { node-version: '20', cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium
- name: e2e against stage
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: pnpm e2e
- run: pnpm e2e
env:
PLAYWRIGHT_BASE_URL: https://stage.yourplatform.com
PLAYWRIGHT_TEST_USER: ${{ secrets.STAGE_TEST_USER }}
@@ -74,7 +97,7 @@ jobs:
image:
needs: [shared, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && hashFiles('Dockerfile') != ''
runs-on: docker
steps:
- uses: actions/checkout@v4
+1
View File
@@ -12,6 +12,7 @@ Generated section is appended on release tag via `git-cliff` (see `.gitea/workfl
-
### Fixed
- ci: rework workflow for Gitea Actions (bash commitlint, inline gitleaks binary, per-stack jobs gated on real code)
-
### Removed