From 285801422e7fdf71ccce9b8a53d9cb9c813ae774 Mon Sep 17 00:00:00 2001 From: th33raphat Date: Thu, 12 Nov 2026 03:25:59 +0700 Subject: [PATCH 1/3] ci: on a PR, build only the packages a push can affect On PR #24, a one-file fix ran all three package builds again, though two had already passed. Now a new "changes" job (tools/ci/changed-jobs.sh) decides per package. On a pull request a package is skipped when: - it passed on this PR before, at some commit S (an actual build: a skip never counts, so reuse doesn't chain), and - no file it builds from changed between S and this run's merge commit. What each package builds from: - all three: Cargo.toml/lock, crates/proto, crates/app/assets (the Mac host inlines the page), this workflow and tools/ci. - macos: crates/host, tools/package-macos.sh, tools/macos. - windows: crates/app's src, build.rs and Cargo.toml. - android: crates/app (Kotlin, launcher icons and Dioxus.toml too), crates/host, tools/build-android.sh. Diffing against the merge commit also counts what dev gained since S, so a skip is never wrong; at worst it rebuilds more than needed. If S is gone (a force push) or GitHub's API fails, everything builds. Pushes to dev, tags and manual runs build everything: each release stamps a new version into all three packages. The changes job's summary says, per package, built or reused, and links the run where it passed. Changes only to docs/ or brand/ no longer start a run, as with Markdown. Dry run against PR #24's runs, with a one-file change each: - Kotlin: android only. - App source: windows and android. - The page's CSS or proto: all three. - docs: none. - tools/package-macos.sh: macos only. - A push to dev: all three. --- .github/workflows/release-beta.yml | 41 ++++++++++++++--- tools/ci/changed-jobs.sh | 73 ++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) create mode 100755 tools/ci/changed-jobs.sh diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 519fbad..7d88d41 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -8,14 +8,16 @@ # How it runs: # - A pull request into dev: tests and builds every package, publishes # nothing (packages are on the run's page). A newer push to the PR cancels -# the older run. +# the older run. A package that already passed on the PR is not built +# again unless a file it builds from changed since (tools/ci/changed-jobs.sh; +# the "changes" job's summary links the run where it passed). # - Merging it (any push to dev): builds and publishes the next beta, # -beta., e.g. 0.1.0-beta.12, and tags it. # Run numbers count PR runs too, so betas are not consecutive. # - By hand: Actions > Beta release > Run workflow. Untick "publish" for a # dry run. # - Push a tag: git tag v0.1.0-beta.3 && git push origin v0.1.0-beta.3 -# Changes to Markdown alone do not run it. +# Changes to Markdown, docs/ or brand/ alone do not run it. # # Mullion.app checks these releases for updates (crates/host/src/update.rs); # it installs the .pkg asset. @@ -30,14 +32,15 @@ on: default: true pull_request: branches: [dev] - paths-ignore: ["**.md"] + paths-ignore: ["**.md", "docs/**", "brand/**"] push: branches: [dev] tags: ["v*-beta.*"] - paths-ignore: ["**.md"] + paths-ignore: ["**.md", "docs/**", "brand/**"] permissions: contents: write + actions: read # changes: earlier runs of this PR # Releases one at a time, in order; a PR's runs replace each other. concurrency: @@ -63,8 +66,30 @@ jobs: echo "version=$v" >> "$GITHUB_OUTPUT" echo "Version: $v" + # Which packages this run builds: on a PR, only those a change can affect. + changes: + runs-on: ubuntu-latest + outputs: + macos: ${{ steps.pick.outputs.macos }} + windows: ${{ steps.pick.outputs.windows }} + android: ${{ steps.pick.outputs.android }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 # to compare with the commit where a package last passed + - id: pick + env: + EVENT: ${{ github.event_name }} + TO_SHA: ${{ github.sha }} + REPO: ${{ github.repository }} + BRANCH: ${{ github.head_ref }} + RUN_ID: ${{ github.run_id }} + GH_TOKEN: ${{ github.token }} + run: tools/ci/changed-jobs.sh + macos: - needs: version + needs: [version, changes] + if: needs.changes.outputs.macos == 'true' # Apple silicon, like the package (hostArchitectures="arm64"). runs-on: macos-15 timeout-minutes: 45 @@ -107,7 +132,8 @@ jobs: if-no-files-found: error windows: - needs: version + needs: [version, changes] + if: needs.changes.outputs.windows == 'true' runs-on: windows-latest timeout-minutes: 45 env: @@ -130,7 +156,8 @@ jobs: if-no-files-found: error android: - needs: version + needs: [version, changes] + if: needs.changes.outputs.android == 'true' runs-on: ubuntu-latest timeout-minutes: 45 env: diff --git a/tools/ci/changed-jobs.sh b/tools/ci/changed-jobs.sh new file mode 100755 index 0000000..950a912 --- /dev/null +++ b/tools/ci/changed-jobs.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +# Which platform jobs a run of release-beta.yml must build (its "changes" job). +# +# On a pull request a job is skipped when it already passed on this PR at some +# commit S, and nothing it builds from has changed since S. Pushes to dev, tags +# and manual runs build everything: each release stamps a new version into all +# three packages. +# +# Env: EVENT (github.event_name), TO_SHA (the commit this run builds), +# REPO, BRANCH (the PR's head branch), RUN_ID (this run, left out of the +# search), GH_TOKEN. Writes macos=, windows=, android= to $GITHUB_OUTPUT and a +# line per job to $GITHUB_STEP_SUMMARY. +set -euo pipefail + +out=${GITHUB_OUTPUT:-/dev/stdout} +summary=${GITHUB_STEP_SUMMARY:-/dev/stderr} +jobs="macos windows android" + +# What each job builds from (tools/package-macos.sh, build-android.sh, the +# include_str!s). Shared: every package compiles proto and carries the page. +shared='^(Cargo\.(toml|lock)$|crates/proto/|crates/app/assets/|\.github/workflows/release-beta\.yml$|tools/ci/)' +own() { + case $1 in + macos) echo '^(crates/host/|tools/package-macos\.sh$|tools/macos/)' ;; + # cargo build of the app: not android/ (Kotlin, launcher icons) or Dioxus.toml. + windows) echo '^crates/app/(src/|build\.rs$|Cargo\.toml$)' ;; + android) echo '^(crates/app/|crates/host/|tools/build-android\.sh$)' ;; + esac +} + +if [ "${EVENT:?}" != pull_request ]; then + for j in $jobs; do echo "$j=true" >> "$out"; done + echo "Builds every package (${EVENT})." >> "$summary" + exit 0 +fi + +# The newest earlier run on this PR in which each job passed: its commit and +# run id. Only real builds count, never a skip, so reuse does not chain. +runs=$(gh api -X GET "repos/${REPO:?}/actions/workflows/release-beta.yml/runs" \ + -f branch="${BRANCH:?}" -f event=pull_request -f per_page=30 \ + --jq '.workflow_runs[] | "\(.id) \(.head_sha)"') || runs="" # API trouble: build everything +found="" +while read -r id sha; do + [ -n "$id" ] && [ "$id" != "${RUN_ID:-}" ] || continue + passed=$(gh api "repos/$REPO/actions/runs/$id/jobs" --jq '.jobs[] | select(.conclusion == "success") | .name') || passed="" + for j in $jobs; do + case " $found " in *" $j="*) continue ;; esac + if grep -qx "$j" <<< "$passed"; then found="$found $j=$id:$sha"; fi + done + [ "$(wc -w <<< "$found")" -lt 3 ] || break +done <<< "$runs" + +for j in $jobs; do + hit=$(tr ' ' '\n' <<< "$found" | sed -n "s/^$j=//p") + run=${hit%%:*} sha=${hit#*:} + build=true why="no earlier pass on this PR" + if [ -n "$hit" ]; then + if ! git cat-file -e "$sha^{commit}" 2>/dev/null; then + why="its last pass (${sha:0:7}) is gone from history (force push)" + else + # Against the merge commit this run builds: also counts what dev gained + # since, so a skip is never wrong (it may rebuild more than needed). + changed=$(git diff --name-only "$sha" "${TO_SHA:?}" | grep -E "$shared|$(own "$j")" || true) + if [ -z "$changed" ]; then + build=false why="reused: passed at ${sha:0:7} in [run $run](https://github.com/$REPO/actions/runs/$run), nothing it builds from changed since" + else + why="changed since its pass at ${sha:0:7}: $(head -3 <<< "$changed" | tr '\n' ' ')" + fi + fi + fi + echo "$j=$build" >> "$out" + echo "- **$j**: $([ "$build" = true ] && echo built || echo skipped). $why" >> "$summary" +done From 2bade7df54c25b6921dd1fca65ee17ea2f0df24e Mon Sep 17 00:00:00 2001 From: th33raphat Date: Thu, 12 Nov 2026 04:09:45 +0700 Subject: [PATCH 2/3] ci: run again (the first run was never scheduled) From 7368b00d344bf0516883e01383b26e0e4d093240 Mon Sep 17 00:00:00 2001 From: th33raphat Date: Thu, 12 Nov 2026 04:14:23 +0700 Subject: [PATCH 3/3] docs(tools): package-macos.sh names where CI tracks its inputs --- tools/package-macos.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/package-macos.sh b/tools/package-macos.sh index 238e8c1..d033e87 100755 --- a/tools/package-macos.sh +++ b/tools/package-macos.sh @@ -5,6 +5,9 @@ # tools/package-macos.sh # -> dist/macos/Mullion.app, dist/Mullion-.pkg (ad-hoc signed) # +# In CI a pull request rebuilds this package only when a file it builds from +# changed (tools/ci/changed-jobs.sh): add new inputs there too. +# # Signing (optional): # MULLION_SIGN_ID="Mullion Code Signing" tools/package-macos.sh # A stable signature: macOS keeps Screen Recording permission across