doc: update examples with confirmed working settings
This commit is contained in:
parent
9f7d041693
commit
e69b626212
1 changed files with 121 additions and 16 deletions
|
|
@ -22,6 +22,16 @@ Language-agnostic composite action that executes a project's test suite with opt
|
|||
|
||||
This ordering ensures artifacts are always uploaded on failure, even though the job ultimately fails.
|
||||
|
||||
## Workflow shape
|
||||
|
||||
This Forgejo instance is hosted on a subpath (`bitfreedom.net/code/...`), and Forgejo's action resolver does not handle URL-form `uses:` references against subpath instances. The workflows below therefore:
|
||||
|
||||
1. Run inside a `container:` so the toolchain is predictable across runners.
|
||||
2. Clone the repository under test manually with the job token, in place of `actions/checkout`.
|
||||
3. Clone this actions repo into a local directory and reference the action with `uses: ./.actions/run-tests`, in place of `uses: https://.../run-tests@v1`.
|
||||
|
||||
The manual checkout uses `github.event.pull_request.head.sha`, so it assumes `on: [pull_request]`. For `on: push`, swap that for `github.sha` (or `github.event.head_commit.id`). The same workflow files run on GitHub unchanged.
|
||||
|
||||
## Usage
|
||||
|
||||
Each example below is a complete workflow — drop it into `.forgejo/workflows/test.yml` (or `.github/workflows/test.yml`) and adjust `runs-on` to match a label one of your runners is registered with. See [Choosing a runner](#choosing-a-runner) below.
|
||||
|
|
@ -34,9 +44,27 @@ on: [pull_request]
|
|||
jobs:
|
||||
test:
|
||||
runs-on: docker-amd64
|
||||
container:
|
||||
image: node:20-slim
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Install system deps
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends git ca-certificates
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
setup: npm ci
|
||||
command: npm test
|
||||
|
|
@ -53,9 +81,27 @@ on: [pull_request]
|
|||
jobs:
|
||||
test:
|
||||
runs-on: docker-amd64
|
||||
container:
|
||||
image: python:3.12-slim
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Install system deps
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends git ca-certificates
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
setup: |
|
||||
python -m pip install --upgrade pip
|
||||
|
|
@ -72,9 +118,22 @@ on: [pull_request]
|
|||
jobs:
|
||||
test:
|
||||
runs-on: docker-amd64
|
||||
container:
|
||||
image: rust:1
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
command: cargo test --all
|
||||
```
|
||||
|
|
@ -87,12 +146,25 @@ on: [pull_request]
|
|||
jobs:
|
||||
test:
|
||||
runs-on: docker-amd64
|
||||
container:
|
||||
image: gradle:8-jdk21
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
setup: ./gradlew --version
|
||||
command: ./gradlew test
|
||||
setup: gradle --version
|
||||
command: gradle test
|
||||
artifacts-path: |
|
||||
**/build/reports/tests/**
|
||||
**/build/test-results/**/*.xml
|
||||
|
|
@ -106,9 +178,22 @@ on: [pull_request]
|
|||
jobs:
|
||||
test:
|
||||
runs-on: docker-amd64
|
||||
container:
|
||||
image: maven:3-eclipse-temurin-21
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
setup: mvn --version
|
||||
command: mvn -B test
|
||||
|
|
@ -122,7 +207,7 @@ jobs:
|
|||
Any of the examples above can run multiple commands in a single step by passing a YAML block scalar to `command`:
|
||||
|
||||
```yaml
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
command: |
|
||||
make lint
|
||||
|
|
@ -149,6 +234,8 @@ jobs:
|
|||
Run the same job on every arch in parallel. Useful when you ship binaries, link against native libraries, or want to catch arch-specific bugs early:
|
||||
|
||||
```yaml
|
||||
name: PR Tests
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
|
|
@ -156,9 +243,27 @@ jobs:
|
|||
matrix:
|
||||
arch: [docker-amd64, docker-arm64]
|
||||
runs-on: ${{ matrix.arch }}
|
||||
container:
|
||||
image: python:3.12-slim
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://bitfreedom.net/code/apunkt/actions/run-tests@v1
|
||||
- name: Install system deps
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends git ca-certificates
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git clone --depth=1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/${{ github.repository }}.git" .
|
||||
git fetch --depth=1 origin "+${{ github.event.pull_request.head.sha }}:pr"
|
||||
git checkout pr
|
||||
- name: Fetch action source
|
||||
run: |
|
||||
git clone --depth=1 --branch v1 \
|
||||
"https://oauth2:${{ github.token }}@bitfreedom.net/code/nomyo-ai/actions.git" \
|
||||
./.actions
|
||||
- uses: ./.actions/run-tests
|
||||
with:
|
||||
command: ./run-tests.sh
|
||||
```
|
||||
|
|
@ -185,5 +290,5 @@ After the workflow has run at least once on a PR, the check name will appear in
|
|||
## Notes
|
||||
|
||||
- `runs-on` must match a label your runner was registered with — see [Choosing a runner](#choosing-a-runner). The GitHub-style `ubuntu-latest` typically does not exist on Forgejo.
|
||||
- Action references must use full URLs on Forgejo (`https://code.forgejo.org/actions/checkout@v4`), unlike GitHub where `actions/checkout@v4` is shorthand.
|
||||
- This Forgejo instance is hosted on a subpath, so URL-form `uses:` (e.g. `uses: https://bitfreedom.net/code/...@v1`) does not resolve. The examples clone the repository under test and the actions repo manually, then reference the action by local path. See [Workflow shape](#workflow-shape).
|
||||
- The failure-artifact upload uses [`forgejo/upload-artifact`](https://code.forgejo.org/forgejo/upload-artifact), which is API-compatible with `actions/upload-artifact` and works on both Forgejo and GitHub.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue