Files
piik/.github/workflows/repository-hygiene.yml
T

525 lines
22 KiB
YAML

name: CI
on:
pull_request:
types: [opened, synchronize, reopened, edited]
push:
branches:
- main
workflow_dispatch:
inputs:
channel_native:
description: Build Rust Native/App and run the synthetic macOS H264 roundtrip
required: false
default: false
type: boolean
channel_network_lab:
description: Run one isolated network control (never publishes)
required: false
default: none
type: choice
options: [none, ordinary, prepared, recovery, media, browser-relay, public-peer]
app_checks:
description: Build and verify App and Server candidates
required: false
default: false
type: boolean
candidate_version:
description: Optional candidate version (vMAJOR.MINOR.PATCH); never publishes
required: false
type: string
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}${{ github.event_name == 'workflow_dispatch' && inputs.channel_network_lab != 'none' && inputs.channel_network_lab != '' && '-network-lab' || '' }}
cancel-in-progress: false
queue: max
jobs:
channel-network:
if: github.event_name == 'workflow_dispatch' && inputs.channel_network_lab != 'none' && inputs.channel_network_lab != '' && inputs.channel_network_lab != 'public-peer'
runs-on: ubuntu-24.04
timeout-minutes: 40
defaults:
run:
shell: bash --noprofile --norc -e -o pipefail {0}
env:
CARGO_BUILD_JOBS: '2'
CARGO_INCREMENTAL: '0'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- run: npm ci
- name: Install laboratory tools
run: |
sudo apt-get update
sudo apt-get install -y iproute2 nftables conntrack tcpdump
npm install --prefix "$RUNNER_TEMP/channel-network-tools" --no-save --package-lock=false agent-browser@0.36.0
rustup toolchain install 1.91.0 --profile minimal --target wasm32-unknown-unknown
cargo +1.91.0 install wasm-bindgen-cli --version 0.2.129 --locked
echo "CARGO_TARGET_DIR=$RUNNER_TEMP/channel-network-target" >> "$GITHUB_ENV"
echo "AGENT_BROWSER_BIN=$RUNNER_TEMP/channel-network-tools/node_modules/agent-browser/bin/agent-browser-linux-x64" >> "$GITHUB_ENV"
mkdir -p "$RUNNER_TEMP/channel-network"
- name: Build the matching Native process and Browser adapter
run: |
cargo +1.91.0 build --locked --manifest-path prototype/channel-server/Cargo.toml --example network_lab -j2 2>&1 | tee "$RUNNER_TEMP/channel-network/native-build.log"
node prototype/channel-browser/build.mjs 2>&1 | tee "$RUNNER_TEMP/channel-network/wasm-build.log"
- name: Run the selected kernel-NAT control
env:
CHANNEL_NETWORK_CASE: ${{ inputs.channel_network_lab }}
SOURCE_HEAD: ${{ github.sha }}
CHROMIUM_BIN: /usr/bin/google-chrome
run: |
{
echo "$SOURCE_HEAD"
rustc +1.91.0 --version
node --version
"$AGENT_BROWSER_BIN" --version
"$CHROMIUM_BIN" --version
sha256sum "$CARGO_TARGET_DIR/debug/examples/network_lab" prototype/channel-browser/pkg/piik_channel_browser_bg.wasm
} | tee "$RUNNER_TEMP/channel-network/identity.log"
sudo --preserve-env=PATH,CARGO_TARGET_DIR,AGENT_BROWSER_BIN,CHROMIUM_BIN,SOURCE_HEAD "$(command -v node)" --import tsx scripts/network-lab.ts \
--case "$CHANNEL_NETWORK_CASE" --output "$RUNNER_TEMP/channel-network/$CHANNEL_NETWORK_CASE" 2>&1 | tee "$RUNNER_TEMP/channel-network/run.log"
- name: Save kernel-NAT evidence
if: always()
uses: actions/upload-artifact@v7
with:
name: channel-network-${{ inputs.channel_network_lab }}-${{ github.sha }}
path: ${{ runner.temp }}/channel-network/
if-no-files-found: warn
retention-days: 7
channel-public-peer:
if: github.event_name == 'workflow_dispatch' && inputs.channel_network_lab == 'public-peer'
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
- name: Validate the temporary public LAB contract
env:
CHANNEL_PUBLIC_LAB: ${{ secrets.CHANNEL_PUBLIC_LAB }}
run: node prototype/channel-server/browser-public-peer.mjs --check-contract
- name: Install the existing browser driver
run: npm install --prefix "$RUNNER_TEMP/channel-public-tools" --no-save --package-lock=false agent-browser@0.36.0
- name: Confirm the normal Android room and picture
env:
CHANNEL_PUBLIC_LAB: ${{ secrets.CHANNEL_PUBLIC_LAB }}
CHANNEL_ACCEPTANCE_OUTPUT: ${{ runner.temp }}/channel-public-peer
AGENT_BROWSER_BIN: ${{ runner.temp }}/channel-public-tools/node_modules/agent-browser/bin/agent-browser-linux-x64
AGENT_BROWSER_EXECUTABLE_PATH: /usr/bin/google-chrome
run: node prototype/channel-server/browser-public-peer.mjs
- name: Save redacted public-peer evidence
if: always()
uses: actions/upload-artifact@v7
with:
name: channel-public-peer-${{ github.sha }}
path: ${{ runner.temp }}/channel-public-peer/
if-no-files-found: warn
retention-days: 7
channel-native:
if: github.event_name == 'workflow_dispatch' && inputs.channel_native == true
runs-on: macos-15
timeout-minutes: 40
defaults:
run:
shell: bash --noprofile --norc -e -o pipefail {0}
env:
MACOSX_DEPLOYMENT_TARGET: '13.0'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install Rust 1.91.0
run: |
rustup toolchain install 1.91.0 --profile minimal
echo "CARGO_TARGET_DIR=$RUNNER_TEMP/channel-native-target" >> "$GITHUB_ENV"
- name: Build Rust Server and App with capture
run: |
mkdir -p "$RUNNER_TEMP/channel-native-logs"
cargo +1.91.0 build --locked --manifest-path prototype/channel-server/Cargo.toml --features capture --bins 2>&1 | tee "$RUNNER_TEMP/channel-native-logs/server-app.log"
- name: Compile Native tests without running them
run: cargo +1.91.0 test --locked --manifest-path prototype/channel-native/Cargo.toml --features capture --tests --no-run 2>&1 | tee "$RUNNER_TEMP/channel-native-logs/native-tests.log"
- name: Run the synthetic VideoToolbox roundtrip without capture
timeout-minutes: 2
run: >-
cargo +1.91.0 test --locked --manifest-path prototype/channel-native/Cargo.toml
--features capture --lib capture::macos::tests::synthetic_h264_roundtrip_preserves_source_time_and_stops
-- --exact --nocapture 2>&1 | tee "$RUNNER_TEMP/channel-native-logs/synthetic-h264.log"
- name: Save macOS build and codec logs
if: always()
uses: actions/upload-artifact@v7
with:
name: channel-native-macos-${{ github.sha }}
path: ${{ runner.temp }}/channel-native-logs/
if-no-files-found: warn
retention-days: 7
release-notes:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- run: npm ci --ignore-scripts
- name: Validate PR release notes
run: node scripts/release-notes.mjs --pull-request
validate:
if: >-
github.event_name != 'pull_request' &&
!(github.event_name == 'workflow_dispatch' &&
(inputs.channel_native == true || (inputs.channel_network_lab != 'none' && inputs.channel_network_lab != '')))
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.version }}
publish: ${{ steps.release.outputs.publish }}
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Validate tracked project state
run: sh scripts/check-project-state.sh
env:
PIIK_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
- name: Install dependencies
run: npm ci
- name: Determine release identity
id: release
env:
PIIK_BUILD_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.candidate_version || '' }}
run: >-
node scripts/release-version.mjs
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.PIIK_RELEASES_ENABLED == 'true' && 'plan' || 'build' }}
--github-output
- name: Preview release notes
if: steps.release.outputs.publish == 'true'
run: node scripts/release-notes.mjs "$PIIK_RELEASE_VERSION" "$GITHUB_SHA" --github-summary
env:
PIIK_RELEASE_VERSION: ${{ steps.release.outputs.version }}
- name: Install Rust validation tools
run: |
rustup toolchain install 1.91.0 --profile minimal --target wasm32-unknown-unknown
cargo +1.91.0 install wasm-bindgen-cli --version 0.2.129 --locked
cargo +1.91.0 install cargo-about --version 0.9.3 --locked --features cli
echo "CARGO_TARGET_DIR=$RUNNER_TEMP/rust-check" >> "$GITHUB_ENV"
- name: Check Rust and the shared Web UI
run: npm run check
env:
PIIK_BUILD_VERSION: ${{ steps.release.outputs.version }}
VITE_PIIK_VERSION: ${{ steps.release.outputs.version }}
VITE_PIIK_REVISION: ${{ github.sha }}
release-server:
needs: validate
if: >-
needs.validate.outputs.publish == 'true' ||
(github.event_name == 'workflow_dispatch' && inputs.app_checks == true)
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
runner: ubuntu-24.04
artifact: piik-server
- os: linux
arch: arm64
runner: ubuntu-24.04-arm
artifact: piik-server-linux-arm64
- os: windows
arch: amd64
runner: windows-latest
artifact: piik-server-windows-amd64
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
defaults:
run:
shell: bash
env:
PIIK_BUILD_VERSION: ${{ needs.validate.outputs.version }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Install Rust packaging tools
run: |
rustup toolchain install 1.91.0 --profile minimal --target wasm32-unknown-unknown
cargo +1.91.0 install wasm-bindgen-cli --version 0.2.129 --locked
cargo +1.91.0 install cargo-about --version 0.9.3 --locked --features cli
- name: Install static Server toolchain
if: matrix.os == 'linux'
run: |
sudo apt-get update && sudo apt-get install -y musl-tools binutils
target="$(node --input-type=module -e 'import { SERVER_PACKAGE_TARGETS } from "./scripts/server-package-targets.mjs"; console.log(SERVER_PACKAGE_TARGETS.find(t => t.goos === process.argv[1] && t.goarch === process.argv[2]).rustTarget)' '${{ matrix.os }}' '${{ matrix.arch }}')"
rustup target add --toolchain 1.91.0 "$target"
- name: Install dependencies
run: npm ci
- name: Package Server release
if: matrix.os == 'linux'
run: >-
node scripts/package-server-release.mjs "$RUNNER_TEMP/server-release"
--os "${{ matrix.os }}" --arch "${{ matrix.arch }}"
--container-image "piik-candidate:$GITHUB_SHA-${{ matrix.arch }}"
- name: Package Windows Server release
if: matrix.os == 'windows'
run: >-
node scripts/package-server-release.mjs "$RUNNER_TEMP/server-release"
--os "${{ matrix.os }}" --arch "${{ matrix.arch }}"
- name: Check the container and deployment recipe
if: matrix.os == 'linux'
run: npm run check:container -- "piik-candidate:$GITHUB_SHA-${{ matrix.arch }}" "$GITHUB_SHA"
- name: Save the verified container
if: matrix.os == 'linux'
run: docker save "piik-candidate:$GITHUB_SHA-${{ matrix.arch }}" --output "$RUNNER_TEMP/piik-container-${{ matrix.arch }}.tar"
- name: Upload the verified container
if: matrix.os == 'linux'
uses: actions/upload-artifact@v7
with:
name: piik-container-${{ matrix.arch }}-${{ github.sha }}
path: ${{ runner.temp }}/piik-container-${{ matrix.arch }}.tar
if-no-files-found: error
retention-days: 14
- name: Upload Server release
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-${{ github.sha }}
path: ${{ runner.temp }}/server-release/*
if-no-files-found: error
retention-days: 14
release-apps:
needs:
- validate
if: >-
needs.validate.outputs.publish == 'true' ||
(github.event_name == 'workflow_dispatch' && inputs.app_checks == true)
strategy:
fail-fast: false
matrix:
include:
- target: windows-amd64
runner: windows-latest
# Native Linux capture links system libraries; keep both architectures
# on the same explicit build baseline instead of following latest.
- target: linux-amd64
runner: ubuntu-24.04
- target: linux-arm64
runner: ubuntu-24.04-arm
- target: darwin-arm64
runner: macos-15
- target: darwin-amd64
runner: macos-15-intel
- target: android-universal
runner: ubuntu-24.04
runs-on: ${{ matrix.runner }}
timeout-minutes: ${{ matrix.target == 'android-universal' && 45 || 35 }}
env:
PIIK_BUILD_VERSION: ${{ needs.validate.outputs.version }}
PIIK_UPDATE_PUBLIC_KEY: ${{ vars.PIIK_UPDATE_PUBLIC_KEY }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Set up Go
if: matrix.target == 'android-universal'
uses: actions/setup-go@v6
with:
go-version-file: .go-version
cache: false
- name: Install dependencies
run: npm ci
- name: Install Rust packaging tools
run: |
rustup toolchain install 1.91.0 --profile minimal --target wasm32-unknown-unknown
cargo +1.91.0 install wasm-bindgen-cli --version 0.2.129 --locked
cargo +1.91.0 install cargo-about --version 0.9.3 --locked --features cli
- name: Install Linux packaging and native capture dependencies
if: startsWith(matrix.target, 'linux-')
run: >-
sudo apt-get update && sudo apt-get install -y
zip
unzip
libgstreamer1.0-dev
libgstreamer-plugins-base1.0-dev
gstreamer1.0-pipewire
gstreamer1.0-plugins-bad
gstreamer1.0-pulseaudio
- name: Build and verify App candidate
if: matrix.target != 'android-universal'
run: >-
node scripts/package-app-candidate.mjs
"${{ matrix.target }}"
"${{ runner.temp }}/app-release"
- name: Set up Android Java
if: matrix.target == 'android-universal'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
- name: Set up Android Gradle
if: matrix.target == 'android-universal'
uses: gradle/actions/setup-gradle@v6
with:
gradle-version: '8.11.1'
cache-provider: basic
- name: Install pinned Android build tools
if: matrix.target == 'android-universal'
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" 'platforms;android-35' 'build-tools;35.0.0' 'ndk;30.0.16248370'
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/30.0.16248370" >> "$GITHUB_ENV"
echo "GRADLE_HOME=$(dirname "$(dirname "$(readlink -f "$(command -v gradle)")")")" >> "$GITHUB_ENV"
rustup target add --toolchain 1.91.0 aarch64-linux-android x86_64-linux-android
- name: Prepare Android signing
if: matrix.target == 'android-universal'
env:
PIIK_PUBLISH: ${{ needs.validate.outputs.publish }}
PIIK_ANDROID_KEYSTORE_BASE64: ${{ secrets.PIIK_ANDROID_KEYSTORE_BASE64 }}
PIIK_ANDROID_STORE_PASSWORD: ${{ secrets.PIIK_ANDROID_STORE_PASSWORD }}
PIIK_ANDROID_KEY_ALIAS: ${{ secrets.PIIK_ANDROID_KEY_ALIAS }}
PIIK_ANDROID_KEY_PASSWORD: ${{ secrets.PIIK_ANDROID_KEY_PASSWORD }}
run: |
if [ "$PIIK_PUBLISH" = true ]; then
for name in PIIK_ANDROID_KEYSTORE_BASE64 PIIK_ANDROID_STORE_PASSWORD PIIK_ANDROID_KEY_ALIAS PIIK_ANDROID_KEY_PASSWORD; do
if [ -z "${!name}" ]; then echo "Android publication requires $name" >&2; exit 1; fi
done
umask 077
printf '%s' "$PIIK_ANDROID_KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/piik-android.keystore"
else
# Manual candidates exercise the same release variant with a disposable key.
keytool -genkeypair -keystore "$RUNNER_TEMP/piik-android.keystore" -storetype PKCS12 \
-storepass candidate-password -keypass candidate-password -alias piik-candidate \
-keyalg RSA -keysize 3072 -validity 2 -dname 'CN=Piik CI candidate' -noprompt
fi
- name: Build and verify Android release APK
if: matrix.target == 'android-universal'
env:
PIIK_ANDROID_KEYSTORE: ${{ runner.temp }}/piik-android.keystore
PIIK_ANDROID_STORE_PASSWORD: ${{ needs.validate.outputs.publish == 'true' && secrets.PIIK_ANDROID_STORE_PASSWORD || 'candidate-password' }}
PIIK_ANDROID_KEY_ALIAS: ${{ needs.validate.outputs.publish == 'true' && secrets.PIIK_ANDROID_KEY_ALIAS || 'piik-candidate' }}
PIIK_ANDROID_KEY_PASSWORD: ${{ needs.validate.outputs.publish == 'true' && secrets.PIIK_ANDROID_KEY_PASSWORD || 'candidate-password' }}
run: node scripts/build-android.mjs --release --output "$RUNNER_TEMP/app-release"
- name: Remove temporary Android signing material
if: always() && matrix.target == 'android-universal'
run: rm -f -- "$RUNNER_TEMP/piik-android.keystore"
- name: Upload App release candidate
uses: actions/upload-artifact@v7
with:
name: piik-app-${{ matrix.target }}-${{ github.sha }}
path: ${{ runner.temp }}/app-release/*
if-no-files-found: error
compression-level: 0
retention-days: 14
publish:
needs:
- validate
- release-server
- release-apps
if: needs.validate.outputs.publish == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
packages: write
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Download Server release
uses: actions/download-artifact@v8
with:
pattern: piik-server*-${{ github.sha }}
path: ${{ runner.temp }}/publish-release
merge-multiple: true
- name: Download App release candidates
uses: actions/download-artifact@v8
with:
pattern: piik-app-*-${{ github.sha }}
path: ${{ runner.temp }}/publish-release
merge-multiple: true
- name: Download the verified container
uses: actions/download-artifact@v8
with:
pattern: piik-container-*-${{ github.sha }}
path: ${{ runner.temp }}/container
merge-multiple: true
- name: Load the verified container
run: |
for arch in amd64 arm64; do
docker load --input "$RUNNER_TEMP/container/piik-container-$arch.tar"
done
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
# Local descriptors/manifests/checksums are validated before publishing.
# Signed update metadata accompanies packages when the App trust root is configured.
- name: Publish packages with release notes and checksums
run: >-
node scripts/publish-release.mjs
"$RUNNER_TEMP/publish-release" "$PIIK_RELEASE_VERSION" "$GITHUB_SHA"
env:
GH_TOKEN: ${{ github.token }}
PIIK_RELEASE_VERSION: ${{ needs.validate.outputs.version }}
PIIK_UPDATE_PUBLIC_KEY: ${{ vars.PIIK_UPDATE_PUBLIC_KEY }}
PIIK_UPDATE_SIGNING_KEY: ${{ secrets.PIIK_UPDATE_SIGNING_KEY }}
- name: Retain original signed update metadata
if: always() && vars.PIIK_UPDATE_PUBLIC_KEY != ''
uses: actions/upload-artifact@v7
with:
name: piik-update-${{ github.sha }}
path: ${{ runner.temp }}/publish-release/signed-update/*
if-no-files-found: ignore
retention-days: 14
- name: Publish the matching Server container
run: >-
node scripts/publish-container.mjs "piik-candidate:$GITHUB_SHA"
"$RUNNER_TEMP/publish-release" "$PIIK_RELEASE_VERSION" "$GITHUB_SHA"
env:
GH_TOKEN: ${{ github.token }}
PIIK_RELEASE_VERSION: ${{ needs.validate.outputs.version }}