Prototype a continuous integration workflow

This workflow is too spendthrift for deployment: every job sets up Rust,
and the `build` job also installs Trunk, which takes even more
resources. The workflow serves well, however, as a proof of concept.
Introducing a syntax error into `src/main.rs` causes the `build` and
`test` jobs to fail, but allows `run-examples` to succeed. Similarly,
introducing a syntax error into `examples/point-on-sphere.rs` causes
`run-examples` to fail, but allows the other jobs to succeed.
This commit is contained in:
Aaron Fenyes 2025-03-06 22:24:52 -08:00
parent d243f19e25
commit bbfdf2b87f
3 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,12 @@
# run all Cargo examples, as described here:
#
# Karol Kuczmarski. "Add examples to your Rust libraries"
# http://xion.io/post/code/rust-examples.html
#
runs:
using: "composite"
steps:
- run: cd app-proto; cargo run --example irisawa-hexlet
- run: cd app-proto; cargo run --example three-spheres
- run: cd app-proto; cargo run --example point-on-sphere
- run: cd app-proto; cargo run --example kaleidocycle

View file

@ -0,0 +1,10 @@
# set up the Rust toolchain. based on David Tolnay's more general
# `rust-toolchain` action for GitHub
#
# https://github.com/dtolnay/rust-toolchain
#
runs:
using: "composite"
steps:
- run: curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail 'https://sh.rustup.rs' | sh -s -- -y --profile minimal
- run: echo $HOME/.cargo/bin >> $GITHUB_PATH

View file

@ -0,0 +1,25 @@
on:
pull_request:
push:
branches: [main]
jobs:
build:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: ./.forgejo/setup-rust
- run: rustup target add wasm32-unknown-unknown
- run: cargo install trunk
- run: cd app-proto; trunk build
test:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: ./.forgejo/setup-rust
- run: cd app-proto; cargo test
run-examples:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: ./.forgejo/setup-rust
- uses: ./.forgejo/run-examples