Files

61 lines
2.6 KiB
YAML

name: ci
# Deliberately not triggered by pull_request.
#
# The forge this runs on is public and takes pull requests from strangers, and a
# runner executes whatever the workflow checks out. Triggering on pull_request
# would mean a stranger's first contribution runs code on the runner host before
# anyone has read it. Triggering only on push means the runner only ever executes
# code that someone with push rights put there.
on:
push:
branches: ['**']
workflow_dispatch:
jobs:
check:
# `docker`, not `ubuntu-latest`. The runner registers both labels but only
# serves this one; a job asking for the other is never claimed at all, and
# shows up as a run that failed in sixty seconds with an empty log.
runs-on: docker
# Pinned, not floating: `cargo fmt --check` is part of the gate and
# rustfmt's output moves between releases, so a moving image would fail on
# formatting nobody touched. CI is the authority on which release that is.
container:
image: rust:1.98-bookworm
steps:
# Not actions/checkout. That is a JavaScript action: the runner executes
# it with `node` inside this container, and a Rust image carries no node,
# so the job dies at the first step with "node: executable file not found
# in $PATH". actions/cache is the same. Cloning by hand costs a few lines
# and keeps the lean image.
#
# The repository is private, so the clone has to authenticate or git
# stops to ask for a username at a terminal that is not there. The token
# goes in a header rather than in the remote URL, so it is not written
# into .git/config where a later step could print it.
- name: Checkout
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git init -q .
git config --local "http.$GITHUB_SERVER_URL/.extraheader" \
"Authorization: Basic $(printf 'x-access-token:%s' "$TOKEN" | base64 | tr -d '\n')"
git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
git fetch -q --depth 1 origin "$GITHUB_SHA"
git checkout -q FETCH_HEAD
# check.sh runs the link checker when python3 is there and says it
# skipped when it is not. In CI it should run.
- name: Tools the gate uses
run: |
apt-get update -qq
apt-get install -qq -y --no-install-recommends python3 >/dev/null
rustup component add rustfmt clippy
# The WebAssembly binding is checked for its own target.
rustup target add wasm32-unknown-unknown
- name: Check
run: ./check.sh