mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
release-app.yml now starts by hand with a version, title and notes (plan2code-publish does it). It builds the four systems, makes a draft release with every file attached and then publishes it, so the vX.Y.Z tag the update check watches appears only when the downloads exist. Publishing a release by hand or pushing a v* tag still starts it as a fallback. plan2code-publish dispatches the workflow and watches it instead of running gh release create. app.yml: pushes to main run the app job on Ubuntu only; the full three-system run stays on manual runs and the full-matrix label.
204 lines
8.3 KiB
YAML
204 lines
8.3 KiB
YAML
name: app
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, labeled]
|
|
# Run the full three-system matrix by hand on any branch.
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# A newer push to a pull request replaces its still-running checks. A push to main always
|
|
# finishes, so a merged change is never left half checked.
|
|
concurrency:
|
|
group: app-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
# Speed: pushes and pull requests run on Ubuntu only (the cheapest runner) unless a pull request
|
|
# carries the `full-matrix` label; manual runs use all three systems. The release build
|
|
# (release-app.yml) compiles on Windows and macOS too. A change that
|
|
# touches only the website, the README, the changelog or similar skips the heavy `app` job. The
|
|
# fast `prose` job runs on every push and pull request. The root `npm test` suite does not run on
|
|
# pushes or pull requests at all: run it locally, or start `node-tests` by hand.
|
|
jobs:
|
|
changes:
|
|
name: changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
code: ${{ steps.diff.outputs.code }}
|
|
steps:
|
|
- uses: actions/checkout@v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
- id: diff
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
case "${{ github.event_name }}" in
|
|
pull_request) base="${{ github.event.pull_request.base.sha }}" ;;
|
|
push) base="${{ github.event.before }}" ;;
|
|
*) base="" ;;
|
|
esac
|
|
# A manual run, a new branch or a base git cannot find: run everything.
|
|
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] || ! git cat-file -e "$base^{commit}" 2>/dev/null; then
|
|
echo "code=true" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
files="$(git diff --name-only "$base" HEAD)"
|
|
echo "Changed files:"; echo "$files"
|
|
# .readme/, AGENTS.md and .agents-docs/ are read by tests, so they count as code.
|
|
if [ -n "$files" ] && ! echo "$files" | grep -qvE '^(docs/|prototypes/|README\.md$|CHANGELOG\.md$|QUICK-REFERENCE\.md$|LICENSE$)'; then
|
|
echo "code=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "code=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
prose:
|
|
name: prose checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4.2.2
|
|
- uses: actions/setup-node@v4.4.0
|
|
with:
|
|
node-version: 20
|
|
- name: Versions agree
|
|
run: node scripts/check-versions.mjs
|
|
- name: Spelling, install command in the docs, line endings
|
|
run: node --test scripts/test-us-english.mjs scripts/test-getting-started.mjs scripts/test-line-endings.mjs scripts/test-check-versions.mjs
|
|
|
|
app:
|
|
name: app (${{ matrix.os }})
|
|
needs: changes
|
|
if: needs.changes.outputs.code == 'true'
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ${{ fromJSON((github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'full-matrix')) && '["windows-latest","macos-latest","ubuntu-latest"]' || '["ubuntu-latest"]') }}
|
|
defaults:
|
|
run:
|
|
working-directory: plan2code-app
|
|
steps:
|
|
- uses: actions/checkout@v4.2.2
|
|
- uses: actions/setup-node@v4.4.0
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: plan2code-app/package-lock.json
|
|
- name: Check the versions agree
|
|
working-directory: .
|
|
run: node scripts/check-versions.mjs
|
|
- name: Install the pinned Rust toolchain
|
|
shell: bash
|
|
# clippy and rustfmt are not part of rust-toolchain.toml's minimal profile.
|
|
run: rustup toolchain install "$(grep channel rust-toolchain.toml | cut -d '"' -f2)" --profile minimal --component clippy --component rustfmt
|
|
- name: Cache the Cargo registry and build output
|
|
uses: actions/cache@v6.1.0
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
plan2code-app/target
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('plan2code-app/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-${{ runner.os }}-
|
|
- name: Name this week for the apt cache
|
|
if: runner.os == 'Linux'
|
|
id: week
|
|
run: echo "week=$(date +%G-%V)" >> "$GITHUB_OUTPUT"
|
|
- name: Cache the Linux system packages
|
|
# The WebKit packages are hundreds of MB, and the runner's Ubuntu mirror is sometimes
|
|
# slow (one download took 7 minutes), so keep the downloaded .deb files. The key rolls
|
|
# over weekly so versions do not go stale; an older week still restores what it can.
|
|
if: runner.os == 'Linux'
|
|
uses: actions/cache@v6.1.0
|
|
with:
|
|
path: ~/apt-archives
|
|
key: apt-tauri-${{ runner.os }}-${{ steps.week.outputs.week }}
|
|
restore-keys: |
|
|
apt-tauri-${{ runner.os }}-
|
|
- name: Install Linux system packages
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
mkdir -p "$HOME/apt-archives/partial"
|
|
sudo apt-get update
|
|
sudo apt-get -o Dir::Cache::archives="$HOME/apt-archives" install -y libwebkit2gtk-4.1-dev build-essential libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev xvfb
|
|
# apt ran as root: hand the folder back so the cache step can read and save it.
|
|
sudo chown -R "$(id -u):$(id -g)" "$HOME/apt-archives"
|
|
- name: Install the app's packages
|
|
run: npm ci
|
|
- name: Vendor the xterm files cargo needs
|
|
# `tauri build` runs this itself (beforeBuildCommand in tauri.conf.json); the cargo
|
|
# steps below call straight into cargo and skip that, so they need it run by hand.
|
|
run: node scripts/vendor.mjs
|
|
- name: Format check
|
|
run: cargo fmt --check
|
|
- name: Lint
|
|
run: cargo clippy --workspace --all-targets -- -D warnings
|
|
- name: Test
|
|
run: cargo test --workspace
|
|
- name: Build
|
|
run: cargo build --workspace
|
|
- name: Build the app (tauri build --no-bundle)
|
|
run: npm run tauri -- build --no-bundle
|
|
- name: Smoke-test the built app against the fake agent
|
|
shell: bash
|
|
# Points the real app at tests/agent_manager.rs's fake-agent fixture (already built
|
|
# by the "Build" step above, in target/debug) and checks the real binary comes up and
|
|
# stays up for a few seconds instead of crashing. Linux has no display by default.
|
|
run: |
|
|
exe=plan2code-app
|
|
agent=fake-agent
|
|
if [ "${{ runner.os }}" = "Windows" ]; then exe="$exe.exe"; agent="$agent.exe"; fi
|
|
export PLAN2CODE_APP_AGENT_BIN="$(pwd)/target/debug/$agent"
|
|
launch=("target/release/$exe")
|
|
if [ "${{ runner.os }}" = "Linux" ]; then launch=(xvfb-run -a "target/release/$exe"); fi
|
|
"${launch[@]}" &
|
|
pid=$!
|
|
sleep 5
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
echo "plan2code-app is still running after 5s; smoke test passed"
|
|
kill "$pid"
|
|
else
|
|
wait "$pid"
|
|
echo "plan2code-app exited within 5s (exit code $?); smoke test failed"
|
|
exit 1
|
|
fi
|
|
|
|
node-tests:
|
|
name: npm test (${{ matrix.os }})
|
|
# Manual runs only: run `npm test` on the dev machine before pushing. Start this from the
|
|
# Actions tab to check all three systems.
|
|
if: github.event_name == 'workflow_dispatch'
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [windows-latest, macos-latest, ubuntu-latest]
|
|
steps:
|
|
- uses: actions/checkout@v4.2.2
|
|
- uses: actions/setup-node@v4.4.0
|
|
with:
|
|
node-version: 20
|
|
- name: Cache the npm downloads
|
|
# setup-node's own cache needs a tracked lockfile and the root has none, so cache npm's
|
|
# download folder directly (both places it lives: Linux and macOS, then Windows).
|
|
uses: actions/cache@v6.1.0
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
~/AppData/Local/npm-cache
|
|
key: npm-${{ runner.os }}-${{ hashFiles('package.json', 'plan2code-metrics/package.json') }}
|
|
restore-keys: |
|
|
npm-${{ runner.os }}-
|
|
- run: npm install
|
|
- run: npm test
|
|
- name: Metrics tests
|
|
working-directory: plan2code-metrics
|
|
run: |
|
|
npm install
|
|
npm test
|