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: a pull request runs on Ubuntu only (the cheapest runner) unless it carries the # `full-matrix` label; pushes to main and manual runs use all three systems. A change that # touches only the website, the README, the changelog or similar skips the heavy jobs and runs # the fast `prose` job instead, which keeps the checks that read those files. 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 needs: changes if: needs.changes.outputs.code == 'false' 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 == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') && '["ubuntu-latest"]' || '["windows-latest","macos-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: Install Linux system packages if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev xvfb - 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 }}) needs: changes if: needs.changes.outputs.code == 'true' runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ${{ fromJSON(github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') && '["ubuntu-latest"]' || '["windows-latest","macos-latest","ubuntu-latest"]') }} steps: - uses: actions/checkout@v4.2.2 - uses: actions/setup-node@v4.4.0 with: node-version: 20 cache: npm - run: npm install - run: npm test - name: Metrics tests working-directory: plan2code-metrics run: | npm install npm test