commit
e092cb029c
252 files changed
+35037
No files matched your search
@@ -0,0 +1,108 @@
|
||||
# Programming+ on Gitea Actions, with a runner that has no container image: the act_runner runs jobs directly on
|
||||
# the droplet's shell ("host mode"). docs/deploy.md has the runner's setup, once.
|
||||
#
|
||||
# Every push and pull request runs `pixi run ci`, the same task a developer runs, in the environment pixi.lock pins
|
||||
# (Node, Python, pandoc, Mojo): every test of the site (the Quarto ones fail, not skip, without pandoc), and core's
|
||||
# tests and mojo-status-strict at the pinned commit. A push to main also checks the chain of pointers
|
||||
# (`pixi run release-check`) and publishes the site to /srv/www/<slug> as an atomic release (scripts/deploy.sh).
|
||||
#
|
||||
# On GitHub Actions the build and test steps run with one change, `runs-on: ubuntu-latest`; the publish step needs
|
||||
# a host that serves /srv/www, so it is the droplet's.
|
||||
#
|
||||
# Repository -> Settings -> Actions -> Variables (all optional):
|
||||
# SITE_SLUG the directory under /srv/www (defaults to the repository name)
|
||||
# SITE_URL e.g. https://pplus.scient.ing, turns on the smoke test
|
||||
name: Build, test, deploy
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: deploy-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# set by Gitea and GitHub Actions already; written here so the tests' "fail, not skip, under CI" never depends on it
|
||||
CI: "true"
|
||||
# the pixi that reads pixi.lock; when the host has another version, this one is fetched into the cache below
|
||||
PIXI_VERSION: "0.83.0"
|
||||
|
||||
jobs:
|
||||
site:
|
||||
# a pull request runs only from a branch of this repository: on a host runner a fork's workflow would run its
|
||||
# own code on the droplet (docs/deploy.md in pplus-web). Drop this line for a runner that is a throwaway VM.
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
# The host-mode label from the runner registration. Jobs run as the runner's user, in a fresh working directory.
|
||||
runs-on: quarto-deploy
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
# core/ is pplus-core, a submodule pinned to one commit, and core/library/ is pplus-library, pinned by core;
|
||||
# the job's token must be able to read both repositories while they are private
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# pixi: the host's when it is the pinned version, else the pinned release, fetched once into a cache directory
|
||||
# the runner's user owns (no sudo), checked by SHA-256
|
||||
- name: pixi, pinned
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if command -v pixi >/dev/null && [ "$(pixi --version | cut -d' ' -f2)" = "$PIXI_VERSION" ]; then
|
||||
echo "pixi $PIXI_VERSION is on the host: $(command -v pixi)"; exit 0
|
||||
fi
|
||||
dir="${PPLUS_CI_CACHE:-$HOME/.cache/pplus-ci}/pixi-$PIXI_VERSION"
|
||||
if [ ! -x "$dir/pixi" ]; then
|
||||
case "$(uname -s)-$(uname -m)" in
|
||||
Linux-x86_64) asset=pixi-x86_64-unknown-linux-musl.tar.gz; sum=064f371e692aaa3400ac581c89da2843c91437f20c2d9155395a5d0037f33551 ;;
|
||||
Linux-aarch64) asset=pixi-aarch64-unknown-linux-musl.tar.gz; sum=d08403d8f048626ec93ba7b7c56e3b747a5f3a95c4e6e0c815ceb264f5f0b9ce ;;
|
||||
*) echo "no pinned pixi for $(uname -sm)" >&2; exit 1 ;;
|
||||
esac
|
||||
tmp="$(mktemp -d)"
|
||||
curl -fsSL --retry 3 -o "$tmp/$asset" "https://github.com/prefix-dev/pixi/releases/download/v$PIXI_VERSION/$asset"
|
||||
echo "$sum $tmp/$asset" | sha256sum -c -
|
||||
mkdir -p "$dir" && tar -xzf "$tmp/$asset" -C "$dir" pixi && rm -rf "$tmp"
|
||||
fi
|
||||
echo "$dir" >> "$GITHUB_PATH"
|
||||
"$dir/pixi" --version
|
||||
|
||||
- name: The pinned environment, exactly as pixi.lock has it
|
||||
run: pixi install --locked
|
||||
|
||||
# every test of the site; core's tests and mojo-status-strict at the pinned commit (pixi.toml)
|
||||
- name: pixi run ci
|
||||
run: pixi run ci
|
||||
|
||||
# each pointer on its pushed branch, the generated files current, Mojo pinned alike (scripts/release.mjs);
|
||||
# a pointer it cannot check (a private remote the job cannot ask) is reported, not failed
|
||||
- name: The chain of pointers
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
run: pixi run release-check
|
||||
|
||||
- name: Assemble the site
|
||||
run: scripts/assemble.sh
|
||||
env:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
|
||||
- name: Publish to /srv/www
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
env:
|
||||
SLUG: ${{ vars.SITE_SLUG || github.event.repository.name }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: scripts/deploy.sh "$SLUG"
|
||||
|
||||
- name: Smoke test
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.SITE_URL != ''
|
||||
shell: bash
|
||||
env:
|
||||
SITE_URL: ${{ vars.SITE_URL }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
sleep 2
|
||||
live=$(curl -fsS "$SITE_URL/VERSION")
|
||||
case "$live" in
|
||||
"${GITHUB_SHA:0:12}"*) echo "live site is at $live" ;;
|
||||
*) echo "live site reports '$live', expected ${GITHUB_SHA:0:12}" >&2; exit 1 ;;
|
||||
esac
|
||||
Reference in new issue
Block a user