Merge pull request #693 from yuezk/ci/prepare-3.3.0-release

ci: prepare Native Shell release infrastructure
This commit is contained in:
Kevin Yue authored and GitHub committed 2026-11-05 23:01:42 +08:00
commit d12d677208
13 files changed
+809 -29

No files matched your search

@@ -0,0 +1,64 @@
name: Prepare cached macOS native dependencies
description: Cache only the completed public native-library prefix, without private source or app outputs.
inputs:
gpgui-directory:
description: Private checkout containing the native dependency builder
required: true
outputs:
prefix:
description: Validated native dependency installation prefix
value: ${{ steps.identity.outputs.path }}
cache-hit:
description: Whether the exact dependency cache was restored
value: ${{ steps.restore.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Identify native dependency cache
id: identity
shell: bash
env:
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
run: |
set -euo pipefail
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency cache identification failed; diagnostics suppressed."; fi' EXIT
metadata="$("$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" --cache-info 2>/dev/null)"
key="$(printf '%s\n' "$metadata" | sed -n 's/^key=//p')"
prefix="$(printf '%s\n' "$metadata" | sed -n 's/^path=//p')"
# Emit only an opaque identity and one dependency directory outside the checkout.
if [[ "$key" =~ ^[0-9a-f]{64}$ ]] &&
[[ "$metadata" == "key=$key"$'\n'"path=$prefix" ]] &&
[[ "${prefix%/*}" == "$RUNNER_TOOL_CACHE/gpgui-macos-native-deps" ]] &&
[[ "${prefix##*/}" == macos-*-"$key" ]]; then
printf 'key=macos-native-deps-%s\npath=%s\n' "$key" "$prefix" >> "$GITHUB_OUTPUT"
else
exit 1
fi
- name: Restore public native libraries
id: restore
uses: actions/cache/restore@v5
with:
path: ${{ steps.identity.outputs.path }}
key: ${{ steps.identity.outputs.key }}
- name: Build or validate native libraries
shell: bash
env:
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
run: |
set -euo pipefail
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency preparation failed; diagnostics suppressed."; fi' EXIT
started=$SECONDS
"$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" >/dev/null 2>&1
echo "Native dependency preparation passed in $((SECONDS - started)) seconds."
# Save before any private application compilation or signing credential import.
- name: Save public native libraries
if: steps.restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ${{ steps.identity.outputs.path }}
key: ${{ steps.identity.outputs.key }}
@@ -0,0 +1,109 @@
name: Build Linux Native Shell
on:
workflow_call:
inputs:
gp_ref:
required: true
type: string
gpgui_ref:
required: true
type: string
channel:
required: true
type: string
secrets:
GH_PAT:
required: true
permissions:
contents: read
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.runner }}
name: build (${{ matrix.arch }})
timeout-minutes: 90
env:
CARGO_INCREMENTAL: '0'
CARGO_BUILD_JOBS: '2'
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
GPGUI_GIT_COMMIT: ${{ inputs.gpgui_ref }}
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
ref: ${{ inputs.gp_ref }}
path: source/gp
submodules: recursive
persist-credentials: false
- name: Checkout CI helpers
uses: actions/checkout@v6
with:
path: .ci
persist-credentials: false
- name: Checkout gpgui
uses: ./.ci/.github/actions/checkout-private
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ inputs.gpgui_ref }}
path: source/gpgui
- name: Install Ubuntu 24.04 dependencies
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
clang libclang-dev libgtk-4-dev libxml2-dev \
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
- name: Install the NSH compiler
run: rustup toolchain install 1.97.0 --profile minimal
- name: Cache public crate downloads
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/cache
~/.cargo/registry/index
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
- name: Build and package Native Shell
run: |
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::Native Shell build failed; diagnostics suppressed."; fi' EXIT
(
set -euo pipefail
cd source/gpgui
cargo +1.97.0 build --manifest-path apps/desktop-nsh/Cargo.toml --locked \
--release --bin gpgui-nsh --target-dir target
target/release/gpgui-nsh --version
version="$(cargo +1.97.0 metadata --manifest-path apps/desktop-nsh/Cargo.toml --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "gpgui-nsh") | .version')"
directory="gpgui-nsh_$version"
archive="gpgui-nsh_$(uname -m).bin.tar.xz"
mkdir -p ".build/package/$directory"
cp target/release/gpgui-nsh ".build/package/$directory/"
cp apps/desktop-nsh/ICU4X-LICENSE.txt ".build/package/$directory/ICU4X-LICENSE.txt"
if ldd target/release/gpgui-nsh | grep -q 'libicu'; then
echo "The release executable must not depend on ICU4C." >&2
exit 1
fi
tar -cJf ".build/package/$archive" -C .build/package "$directory"
sha256sum ".build/package/$archive" | cut -d ' ' -f 1 > ".build/package/$archive.sha256"
) >/dev/null 2>&1
echo "Native Shell build and version check passed."
- name: Upload Native Shell
uses: actions/upload-artifact@v7
with:
name: artifact-gpgui-nsh-${{ matrix.arch }}
if-no-files-found: error
path: |
source/gpgui/.build/package/*.bin.tar.xz
source/gpgui/.build/package/*.bin.tar.xz.sha256
+105 -9
View File
@@ -26,6 +26,12 @@ on:
required: true
default: false
type: boolean
macos_gui:
description: 'macOS shell to build; NSH also runs its separate macOS/Linux checks'
required: true
default: nsh
type: choice
options: [tauri, nsh]
build_bsd:
description: 'Build FreeBSD/OpenBSD packages for this run'
required: true
@@ -190,6 +196,16 @@ jobs:
timeout-minutes: 80
run: bash .ci/scripts/test-private-desktop.sh "$PWD/source"
check-nsh:
needs: validate-inputs
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_macos && inputs.macos_gui == 'nsh') || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_MACOS_ON_TAG == 'true') }}
uses: ./.github/workflows/check-nsh.yaml
with:
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
tarball:
needs: validate-inputs
runs-on: ubuntu-latest
@@ -439,6 +455,16 @@ jobs:
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
build-gpgui-nsh:
needs: validate-inputs
uses: ./.github/workflows/build-gpgui-nsh-linux.yaml
with:
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
nix-source:
needs: [validate-inputs, build-gpgui-glibc]
strategy:
@@ -553,8 +579,14 @@ jobs:
build-macos:
name: build-macos
needs: [validate-inputs, test-gp, test-gpgui]
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_macos) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_MACOS_ON_TAG == 'true') }}
needs: [validate-inputs, test-gp, test-gpgui, check-nsh]
if: >-
${{ !cancelled() &&
needs.validate-inputs.result == 'success' &&
needs.test-gp.result == 'success' && needs.test-gpgui.result == 'success' &&
(needs.check-nsh.result == 'success' || needs.check-nsh.result == 'skipped') &&
((github.event_name == 'workflow_dispatch' && inputs.build_macos) ||
(startsWith(github.ref, 'refs/tags/') && vars.BUILD_MACOS_ON_TAG == 'true')) }}
permissions:
contents: read
concurrency:
@@ -563,6 +595,8 @@ jobs:
runs-on: ${{ vars.MACOS_RUNNER || 'macos-15' }}
environment: macos-release
timeout-minutes: 120
env:
MACOS_GUI: ${{ github.event_name == 'workflow_dispatch' && inputs.macos_gui || 'nsh' }}
steps:
- name: Verify runner architecture
run: test "$(uname -m)" = arm64
@@ -670,6 +704,12 @@ jobs:
ninja \
pkgconf \
python
rustup toolchain install 1.97.0 --profile minimal
- name: Prepare cached native dependencies
uses: ./.ci/.github/actions/macos-native-deps
with:
gpgui-directory: source/gpgui
- name: Import signing identity
env:
@@ -742,6 +782,7 @@ jobs:
- name: Build macOS release artifacts
env:
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
GPGUI_GIT_COMMIT: ${{ needs.validate-inputs.outputs.gpgui_sha }}
SPARKLE_PUBLIC_KEY: ${{ vars.SPARKLE_PUBLIC_KEY }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
run: |
@@ -752,7 +793,7 @@ jobs:
if [[ "$CHANNEL" == "snapshot" ]]; then
export GPGUI_RELEASE_DEVTOOLS=1
fi
source/gpgui/scripts/build-macos.sh dmg release
source/gpgui/scripts/build-macos.sh dmg release --gui "$MACOS_GUI"
) 2>&1 | awk '
/^MACOS_STAGE: (Native dependencies|Components|Frontend|Application|Bundle|Bundle icons|Bundle metadata|Bundle licenses|Bundle libraries|Bundle frameworks|Bundle optimization|Signing|Validation|App notarization|Update archive|Disk image|Disk image notarization|Complete)$/ {
print "::notice::" $0
@@ -789,9 +830,15 @@ jobs:
BUILD_VERSION: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
WORKFLOW_SHA: ${{ github.sha }}
run: |
set -euo pipefail
GP_REF="$(git -C source/gp rev-parse HEAD)"
GPGUI_REF="$(git -C source/gpgui rev-parse HEAD)"
export GP_REF GPGUI_REF
GUI="$(plutil -extract GPDesktopShell raw 'source/gpgui/target/release/bundle/macos/GP Connect.app/Contents/Info.plist')"
if [[ "$GUI" != "$MACOS_GUI" ]]; then
echo "Built desktop shell does not match the selected GUI" >&2
exit 1
fi
export GP_REF GPGUI_REF GUI
python3 - <<'PYTHON'
import hashlib
import json
@@ -799,7 +846,7 @@ jobs:
from pathlib import Path
directory = Path("release-assets")
metadata = {key.lower(): os.environ[key] for key in (
"CHANNEL", "RELEASE_TAG", "GP_REF", "GPGUI_REF", "REQUEST_ID", "BUILD_VERSION", "WORKFLOW_SHA")}
"CHANNEL", "RELEASE_TAG", "GP_REF", "GPGUI_REF", "REQUEST_ID", "BUILD_VERSION", "WORKFLOW_SHA", "GUI")}
metadata["artifact_version"] = os.environ["MACOS_ARTIFACT_VERSION"]
metadata["assets"] = {
file.name: hashlib.sha256(file.read_bytes()).hexdigest()
@@ -973,6 +1020,7 @@ jobs:
gmake \
pkgconf \
libxml2 \
liblz4 \
gnutls \
p11-kit \
nettle \
@@ -981,8 +1029,10 @@ jobs:
libayatana-appindicator \
polkit \
webkit2-gtk_41
pkgconf --exists libxml-2.0 liblz4 gnutls p11-kit-1 hogweed nettle gmp
run: |
set -eu
exec 3>&1
(
set -eu
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
@@ -990,12 +1040,33 @@ jobs:
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
cd "${{ matrix.workspace }}/gp"
cargo build --release --workspace
echo "BSD public components: started." >&3
cargo build --release --workspace >&3 2>&3
echo "BSD public components: passed." >&3
cd ../gpgui/apps/desktop/src-tauri
cargo build --release --workspace
echo "BSD desktop: started." >&3
diagnostics="$(mktemp)"
trap 'rm -f "$diagnostics" || true' EXIT
if cargo build --release -p gpgui >"$diagnostics" 2>&1; then
echo "BSD desktop: passed." >&3
else
status=$?
sed -n 's/.*\(error\[E[0-9][0-9][0-9][0-9]\]\).*/::error::BSD Rust diagnostic: \1/p' "$diagnostics" | sort -u >&3 || true
if grep -q 'No space left on device' "$diagnostics"; then
echo "::error::BSD desktop compilation: insufficient disk space." >&3
fi
if grep -Eq 'signal: 9, SIGKILL|ld terminated with signal 9|Killed signal terminated program' "$diagnostics"; then
echo "::error::BSD desktop compilation: compiler or linker killed by SIGKILL." >&3
fi
if grep -Eq 'undefined reference to|undefined symbol:' "$diagnostics"; then
echo "::error::BSD desktop compilation: unresolved linker symbols." >&3
fi
exit "$status"
fi
cd ../../../../gp
echo "BSD packaging: started." >&3
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
pkg install -y ".build/${{ matrix.artifact_dir }}"/artifacts/*.pkg
gpclient --version
@@ -1003,6 +1074,7 @@ jobs:
gpgui --version
rm -rf target ../gpgui/target
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
echo "BSD packaging: passed." >&3
) >/dev/null 2>&1
echo "BSD build passed."
- name: Build on OpenBSD
@@ -1042,6 +1114,7 @@ jobs:
ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
run: |
set -eu
exec 3>&1
(
set -eu
export AUTOCONF_VERSION=2.72
@@ -1051,12 +1124,33 @@ jobs:
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
cd "${{ matrix.workspace }}/gp"
cargo build --release --workspace
echo "BSD public components: started." >&3
cargo build --release --workspace >&3 2>&3
echo "BSD public components: passed." >&3
cd ../gpgui/apps/desktop/src-tauri
cargo build --release --workspace
echo "BSD desktop: started." >&3
diagnostics="$(mktemp)"
trap 'rm -f "$diagnostics" || true' EXIT
if cargo build --release -p gpgui >"$diagnostics" 2>&1; then
echo "BSD desktop: passed." >&3
else
status=$?
sed -n 's/.*\(error\[E[0-9][0-9][0-9][0-9]\]\).*/::error::BSD Rust diagnostic: \1/p' "$diagnostics" | sort -u >&3 || true
if grep -q 'No space left on device' "$diagnostics"; then
echo "::error::BSD desktop compilation: insufficient disk space." >&3
fi
if grep -Eq 'signal: 9, SIGKILL|ld terminated with signal 9|Killed signal terminated program' "$diagnostics"; then
echo "::error::BSD desktop compilation: compiler or linker killed by SIGKILL." >&3
fi
if grep -Eq 'undefined reference to|undefined symbol:' "$diagnostics"; then
echo "::error::BSD desktop compilation: unresolved linker symbols." >&3
fi
exit "$status"
fi
cd ../../../../gp
echo "BSD packaging: started." >&3
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
pkg_add -D unsigned ".build/${{ matrix.artifact_dir }}"/artifacts/*.tgz
gpclient --version
@@ -1064,6 +1158,7 @@ jobs:
gpgui --version
rm -rf target ../gpgui/target
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
echo "BSD packaging: passed." >&3
) >/dev/null 2>&1
echo "BSD build passed."
- name: Upload BSD package
@@ -1095,6 +1190,7 @@ jobs:
- build-docker-image
- build-gpgui-glibc
- build-gpgui-musl
- build-gpgui-nsh
- setup-bsd-matrix
- build-gpgui-frontend
- build-bsd
@@ -0,0 +1,67 @@
name: Check macOS native dependency cache
on:
workflow_dispatch:
inputs:
gpgui_ref:
description: Full gpgui commit SHA
required: true
type: string
workflow_call:
inputs:
gpgui_ref:
required: true
type: string
secrets:
GH_PAT:
required: true
permissions:
contents: read
jobs:
check:
runs-on: ${{ vars.MACOS_RUNNER || 'macos-15' }}
timeout-minutes: 30
steps:
- name: Require immutable source ref
env:
GPGUI_REF: ${{ inputs.gpgui_ref }}
run: test "${#GPGUI_REF}" -eq 40 && [[ "$GPGUI_REF" != *[!0-9a-f]* ]]
- uses: actions/checkout@v6
with:
path: .ci
persist-credentials: false
- name: Checkout gpgui quietly
uses: ./.ci/.github/actions/checkout-private
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ inputs.gpgui_ref }}
path: source/gpgui
- name: Select release toolchain and install native build tools
env:
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
run: |
test "$(uname -m)" = arm64
xcodebuild -version
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
brew install autoconf automake gettext libtool meson ninja pkgconf
- name: Prepare cached native dependencies
id: native
uses: ./.ci/.github/actions/macos-native-deps
with:
gpgui-directory: source/gpgui
- name: Record cache result
env:
CACHE_HIT: ${{ steps.native.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" == true ]]; then
echo "Validated an exact native dependency cache hit." >> "$GITHUB_STEP_SUMMARY"
else
echo "Built and validated native dependencies after a cache miss." >> "$GITHUB_STEP_SUMMARY"
fi
+139
View File
@@ -0,0 +1,139 @@
name: Check NSH
on:
workflow_dispatch:
inputs:
gp_ref:
description: 'Full GlobalProtect-openconnect commit SHA'
required: true
type: string
gpgui_ref:
description: 'Full gpgui commit SHA'
required: true
type: string
workflow_call:
inputs:
gp_ref:
required: true
type: string
gpgui_ref:
required: true
type: string
secrets:
GH_PAT:
required: true
permissions:
contents: read
jobs:
check:
name: NSH (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- platform: linux
runner: ubuntu-24.04
- platform: macos
runner: ${{ vars.MACOS_RUNNER || 'macos-15' }}
env:
CARGO_INCREMENTAL: '0'
CARGO_BUILD_JOBS: '2'
steps:
- name: Require immutable source refs
env:
GP_REF: ${{ inputs.gp_ref }}
GPGUI_REF: ${{ inputs.gpgui_ref }}
run: |
[[ "$GP_REF" =~ ^[0-9a-f]{40}$ && "$GPGUI_REF" =~ ^[0-9a-f]{40}$ ]] || {
echo "Both source refs must be full commit SHAs."
exit 1
}
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
ref: ${{ inputs.gp_ref }}
path: source/gp
submodules: recursive
persist-credentials: false
- name: Checkout CI helpers
uses: actions/checkout@v6
with:
path: .ci
persist-credentials: false
- name: Checkout gpgui
uses: ./.ci/.github/actions/checkout-private
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ inputs.gpgui_ref }}
path: source/gpgui
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
clang libclang-dev libgtk-4-dev libxml2-dev \
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
- name: Install macOS dependencies
if: matrix.platform == 'macos'
env:
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
run: |
xcodebuild -version
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
brew install autoconf automake gettext libtool pkgconf gnutls libxml2 lz4
echo "$(brew --prefix gettext)/bin" >> "$GITHUB_PATH"
echo "ACLOCAL_PATH=$(brew --prefix gettext)/share/aclocal" >> "$GITHUB_ENV"
echo "PKG_CONFIG_PATH=$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix gnutls)/lib/pkgconfig" >> "$GITHUB_ENV"
- name: Install the NSH compiler
run: rustup toolchain install 1.97.0 --profile minimal
- name: Cache public crate downloads
uses: actions/cache@v5
with:
# Private source and build outputs stay out of the public cache.
path: |
~/.cargo/registry/cache
~/.cargo/registry/index
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
- name: Check demo-free NSH production
timeout-minutes: 30
run: |
diagnostics="$(mktemp)"
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH production check failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py compile "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
(
set -euo pipefail
cd source/gpgui
cargo +1.97.0 check --manifest-path apps/desktop-nsh/Cargo.toml --locked --bin gpgui-nsh
) >"$diagnostics" 2>&1
echo "NSH production check passed."
- name: Compile NSH tests
timeout-minutes: 30
run: |
diagnostics="$(mktemp)"
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH test compilation failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py compile "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
(
set -euo pipefail
cd source/gpgui
cargo +1.97.0 test --manifest-path apps/desktop-nsh/Cargo.toml --locked --features demo --no-run
) >"$diagnostics" 2>&1
echo "NSH test compilation passed."
- name: Run NSH tests
timeout-minutes: 10
run: |
diagnostics="$(mktemp)"
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH tests failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py tests "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
(
set -euo pipefail
cd source/gpgui
cargo +1.97.0 test --manifest-path apps/desktop-nsh/Cargo.toml --locked --features demo -- --test-threads=1
) >"$diagnostics" 2>&1
echo "NSH tests passed."
-1
View File
@@ -63,7 +63,6 @@ jobs:
make \
namcap \
nettle \
openssl \
patch \
pkgconf \
librsvg \
+9 -1
View File
@@ -12,6 +12,13 @@ on:
required: true
type: string
expected_gui:
description: 'Expected macOS shell in the selected build artifact'
required: true
default: nsh
type: choice
options: [tauri, nsh]
concurrency:
group: publish-macos-assets
cancel-in-progress: false
@@ -66,10 +73,11 @@ jobs:
RELEASE_TAG: ${{ inputs.release_tag }}
WORKFLOW_COMMIT: ${{ steps.build.outputs.workflow_commit }}
ARTIFACT_NAME: ${{ steps.build.outputs.artifact }}
EXPECTED_GUI: ${{ inputs.expected_gui }}
run: |
set -euo pipefail
metadata="$(python3 scripts/validate-macos-release.py release-assets \
--release-tag "$RELEASE_TAG" --workflow-commit "$WORKFLOW_COMMIT")"
--release-tag "$RELEASE_TAG" --workflow-commit "$WORKFLOW_COMMIT" --gui "$EXPECTED_GUI")"
[[ "$ARTIFACT_NAME" == "macos-release-$(jq -r '.request_id' <<<"$metadata")" ]]
{
echo "gp_ref=$(jq -r '.gp_ref' <<<"$metadata")"
@@ -27,6 +27,10 @@ on:
gp_ref:
required: true
type: string
expected_gui:
required: false
default: nsh
type: string
highlights:
required: false
type: string
@@ -61,6 +65,12 @@ on:
required: true
default: main
type: string
expected_gui:
description: Expected macOS shell in the selected update archive
required: true
default: nsh
type: choice
options: [tauri, nsh]
highlights:
description: Stable release highlights, one per line
required: false
@@ -88,6 +98,7 @@ jobs:
REQUESTED_ARCHIVE: ${{ inputs.archive_name }}
FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
EXPECTED_TEAM_ID: ${{ vars.MACOS_TEAM_ID }}
EXPECTED_GUI: ${{ inputs.expected_gui }}
UPDATES_WORKER_NAME: ${{ vars.UPDATES_WORKER_NAME || 'gp-updates' }}
SPARKLE_VERSION: 2.9.2
UPDATE_HIGHLIGHTS: ${{ inputs.highlights }}
@@ -106,6 +117,10 @@ jobs:
echo "channel must be stable or snapshot" >&2
exit 1
fi
if [[ "$EXPECTED_GUI" != "tauri" && "$EXPECTED_GUI" != "nsh" ]]; then
echo "expected_gui must be tauri or nsh" >&2
exit 1
fi
if [[ ! "$UNIX_PLATFORMS" =~ ^(linux|freebsd|openbsd)(,(linux|freebsd|openbsd))*$ ]]; then
echo "unix_platforms must list published Unix targets separated by commas" >&2
exit 1
@@ -285,6 +300,12 @@ jobs:
fi
file "$app/Contents/MacOS/gpgui" | grep -q 'arm64'
desktop_shell="$(plutil -extract GPDesktopShell raw "$app/Contents/Info.plist")"
if [[ "$desktop_shell" != "$EXPECTED_GUI" ]]; then
echo "Update archive desktop shell does not match the selected GUI" >&2
exit 1
fi
feed_url="$(plutil -extract SUFeedURL raw "$app/Contents/Info.plist")"
if [[ "$feed_url" != "$FEED_URL" ]]; then
echo "Unexpected Sparkle feed URL: $feed_url" >&2
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Report only allowlisted metadata from a private Rust command log."""
import hashlib
from pathlib import Path
import re
import sys
def report_compile(output):
codes = sorted(set(re.findall(r'error\[E[0-9]{4}\]', output)))
if codes:
print(f'::error::Rust diagnostic codes: {" ".join(codes)}.')
categories = [
('No space left on device', 'insufficient disk space'),
(r'signal: 9, SIGKILL|ld terminated with signal 9|Killed signal terminated program',
'compiler or linker killed by SIGKILL'),
(r'undefined reference to|undefined symbol:', 'unresolved linker symbols'),
('proc macro panicked', 'procedural macro failed'),
]
for pattern, description in categories:
if re.search(pattern, output):
print(f'::error::Rust compilation: {description}.')
def report_tests(output):
names = set(re.findall(r'^test (.+?) \.\.\. FAILED\r?$', output, re.MULTILINE))
for fingerprint in sorted(hashlib.sha256(name.encode()).hexdigest() for name in names):
print(f'::error::Rust test failure fingerprint: {fingerprint}')
panics = re.findall(
r"^thread '([^'\r\n]+)'(?: \([0-9]+\))? panicked at [^\r\n]+:([0-9]+):([0-9]+):\r?$",
output, re.MULTILINE)
locations = {(hashlib.sha256(name.encode()).hexdigest(), int(line), int(column))
for name, line, column in panics}
for fingerprint, line, column in sorted(locations):
print(f'::error::Rust test panic location: {fingerprint} {line}:{column}')
overdue = set(re.findall(r'^test (.+?) has been running for over 60 seconds\r?$',
output, re.MULTILINE))
for fingerprint in sorted(hashlib.sha256(name.encode()).hexdigest() for name in overdue):
print(f'::error::Rust overdue test fingerprint: {fingerprint}')
running = re.findall(r'^\s+Running (.+?) \(([^\r\n]+)\)\r?$', output, re.MULTILINE)
if running:
source, executable = running[-1]
basename = re.sub(r'-[0-9a-f]{16}$', '', Path(executable).name)
identity = f'{" ".join(source.split())} ({basename})'
fingerprint = hashlib.sha256(identity.encode()).hexdigest()
print(f'::error::Rust last running target fingerprint: {fingerprint}')
def main():
if len(sys.argv) != 3 or sys.argv[1] not in ('compile', 'tests'):
print('Usage: private-ci-diagnostics.py compile|tests LOGFILE', file=sys.stderr)
return 2
try:
output = Path(sys.argv[2]).read_text(errors='replace')
except OSError:
print('Private Rust diagnostic log is unavailable.', file=sys.stderr)
return 1
if sys.argv[1] == 'compile':
report_compile(output)
else:
report_tests(output)
return 0
if __name__ == '__main__':
sys.exit(main())
+14 -3
View File
@@ -1,19 +1,26 @@
#!/usr/bin/env bash
# Emit only host-owned stage names; never forward private command output.
# Never forward private command output; report stages and allowlisted diagnostics.
set -euo pipefail
source_directory=$1
container="gp-private-tests-$$"
trap 'timeout --kill-after=5s 30s docker rm --force "$container" >/dev/null 2>&1 || true' EXIT
private_output=$(mktemp)
script_directory=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
trap 'timeout --kill-after=5s 30s docker rm --force "$container" >/dev/null 2>&1 || true; unlink "$private_output"' EXIT
run_stage() {
local name=$1 limit=$2 status started=$SECONDS
shift 2
echo "$name: started (limit $limit)."
if timeout --kill-after=30s "$limit" "$@" >/dev/null 2>&1; then
if timeout --kill-after=30s "$limit" "$@" >"$private_output" 2>&1; then
echo "$name: passed ($((SECONDS - started))s)."
else
status=$?
if [[ "$name" == 'Compile Rust tests' ]]; then
python3 "$script_directory/private-ci-diagnostics.py" compile "$private_output" || true
elif [[ "$name" == 'Rust tests' ]]; then
python3 "$script_directory/private-ci-diagnostics.py" tests "$private_output" || true
fi
if [[ "$status" == 124 ]]; then
echo "::error::$name: timed out after $((SECONDS - started))s (limit $limit); diagnostics suppressed."
elif [[ "$status" == 137 ]]; then
@@ -30,6 +37,10 @@ run_stage 'Start test container' 5m docker run --detach --rm \
--user vscode \
-e HOME=/home/vscode \
-e CARGO_TARGET_DIR=/tmp/gpgui-test-target \
-e CARGO_BUILD_JOBS=2 \
-e CARGO_INCREMENTAL=0 \
-e CARGO_PROFILE_DEV_DEBUG=0 \
-e CARGO_PROFILE_TEST_DEBUG=0 \
-e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \
-v "$source_directory:/source:ro" \
+183 -2
View File
@@ -1,5 +1,7 @@
import hashlib
import json
import os
import plistlib
from pathlib import Path
import re
import subprocess
@@ -27,6 +29,41 @@ def run_block(path, step=None):
class PrivateOutputTests(unittest.TestCase):
def test_macos_metadata_records_the_bundled_shell_and_rejects_a_different_one(self):
for gui in ('tauri', 'nsh'):
with self.subTest(gui=gui), tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
tools = root / 'bin'
tools.mkdir()
git = tools / 'git'
git.write_text('#!/bin/sh\nprintf "%040d\\n" 1\n')
git.chmod(0o755)
plutil = tools / 'plutil'
plutil.write_text(f'#!{sys.executable}\nimport plistlib,sys\n'
'with open(sys.argv[-1], "rb") as file:\n'
' print(plistlib.load(file)[sys.argv[2]])\n')
plutil.chmod(0o755)
info = root / 'source/gpgui/target/release/bundle/macos/GP Connect.app/Contents/Info.plist'
info.parent.mkdir(parents=True)
info.write_bytes(plistlib.dumps({'GPDesktopShell': gui}))
artifacts = root / 'release-assets'
artifacts.mkdir()
(artifacts / 'fixture.dmg').write_bytes(b'signed fixture')
env = dict(os.environ, PATH=f'{tools}:{os.environ["PATH"]}', MACOS_GUI='tauri',
CHANNEL='stable', RELEASE_TAG='v3.2.0', REQUEST_ID='42.1.macos',
BUILD_VERSION='42.1', WORKFLOW_SHA='a' * 40, MACOS_ARTIFACT_VERSION='3.2.0')
result = subprocess.run(['bash', '-e', '-c', run_block(
'.github/workflows/build.yaml', 'Record build identity')],
cwd=root, env=env, text=True, capture_output=True)
metadata = artifacts / 'release-build.json'
if gui == 'tauri':
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(json.loads(metadata.read_text())['gui'], 'tauri')
else:
self.assertNotEqual(result.returncode, 0)
self.assertIn('desktop shell', result.stderr)
self.assertFalse(metadata.exists())
def test_private_checkout_supports_branch_tag_and_sha_without_retaining_token(self):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
@@ -78,7 +115,7 @@ class PrivateOutputTests(unittest.TestCase):
(root / 'updates').mkdir()
(root / 'updates/appcast.xml').write_text('fixture')
env = dict(os.environ, PATH=f'{root}:{os.environ["PATH"]}',
TEST_STATUS=str(status), CHANNEL='snapshot', GPGUI_BUILDER='fixture',
TEST_STATUS=str(status), CHANNEL='snapshot', MACOS_GUI='tauri', GPGUI_BUILDER='fixture',
RUNNER_TEMP=str(root), UPDATES_WORKER_NAME='fixture',
PRIVATE_TOKEN='test-token', PRIVATE_REF='test-ref', PRIVATE_PATH='private')
result = subprocess.run(['bash', '-e', '-c', run_block(path, step)],
@@ -92,6 +129,55 @@ class PrivateOutputTests(unittest.TestCase):
self.assertIn('passed' if status == 0 else 'failed', result.stdout)
class NativeDependencyCacheTests(unittest.TestCase):
def run_step(self, step, metadata, status=0):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
helper = root / 'private/scripts/build-macos-native-deps.sh'
helper.parent.mkdir(parents=True)
helper.write_text('#!/bin/sh\nprintf "%s\\n" "$TEST_METADATA"\n'
'echo PRIVATE_STDERR >&2\nexit "$TEST_STATUS"\n')
helper.chmod(0o755)
key = 'a' * 64
prefix = root / f'tools/gpgui-macos-native-deps/macos-13.0-arm64-{key}'
output = root / 'output'
env = dict(os.environ, GPGUI_DIRECTORY=str(root / 'private'),
RUNNER_TOOL_CACHE=str(root / 'tools'), GITHUB_OUTPUT=str(output),
TEST_METADATA=metadata.format(key=key, prefix=prefix, private=root / 'private'),
TEST_STATUS=str(status))
result = subprocess.run(['bash', '-e', '-o', 'pipefail', '-c', run_block(
'.github/actions/macos-native-deps/action.yaml', step)],
cwd=root, env=env, text=True, capture_output=True)
return result, output.read_text() if output.exists() else ''
def test_identity_emits_only_an_opaque_key_and_native_dependency_prefix(self):
result, output = self.run_step('Identify native dependency cache', 'key={key}\npath={prefix}')
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn('key=macos-native-deps-' + 'a' * 64, output)
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
def test_private_output_and_checkout_paths_cannot_become_cache_metadata(self):
for metadata, status in [('PRIVATE_SOURCE_CODE', 0),
('key={key}\npath={private}', 0),
('PRIVATE_SOURCE_CODE', 19)]:
with self.subTest(metadata=metadata, status=status):
result, output = self.run_step('Identify native dependency cache', metadata, status)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(result.returncode, status or 1)
self.assertEqual(output, '')
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
self.assertIn('diagnostics suppressed', result.stdout)
def test_preparation_hides_private_command_output_and_preserves_failure(self):
for status in (0, 19):
with self.subTest(status=status):
result, output = self.run_step('Build or validate native libraries', 'PRIVATE_SOURCE_CODE', status)
self.assertEqual(result.returncode, status)
self.assertEqual(output, '')
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
self.assertIn('passed' if status == 0 else 'failed', result.stdout)
class PrivateTestStageTests(unittest.TestCase):
def run_stages(self, mode):
with tempfile.TemporaryDirectory() as temporary:
@@ -104,10 +190,23 @@ class PrivateTestStageTests(unittest.TestCase):
output.write(json.dumps(sys.argv[1:]) + '\\n')
print('PRIVATE_STDOUT')
print('PRIVATE_STDERR', file=sys.stderr)
if 'cargo' in sys.argv and '--no-run' in sys.argv:
diagnostics = {
'compile-type': 'error[E0061]: PRIVATE_SOURCE\\nerror[E0308]: PRIVATE_SOURCE\\nerror[E0061]: PRIVATE_SOURCE',
'compile-disk': 'PRIVATE_PATH: No space left on device',
'compile-killed': 'PRIVATE_SOURCE (signal: 9, SIGKILL: kill)',
'compile-link': 'PRIVATE_PATH: undefined reference to PRIVATE_SYMBOL',
'compile-macro': 'error: proc macro panicked\\nPRIVATE_SOURCE',
}
diagnostic = diagnostics.get(os.environ['MODE'])
if diagnostic:
print(diagnostic, file=sys.stderr)
sys.exit(101)
if 'cargo' in sys.argv and '--no-run' not in sys.argv:
if os.environ['MODE'] == 'hang':
time.sleep(60)
if os.environ['MODE'] == 'fail':
print('test private::test_function ... FAILED')
sys.exit(19)
'''))
timeout = root / 'timeout'
@@ -126,10 +225,14 @@ class PrivateTestStageTests(unittest.TestCase):
executable.write_text(executable.read_text().replace("#!/usr/bin/env python3", f"#!{sys.executable}"))
executable.chmod(0o755)
calls = root / 'calls.jsonl'
env = dict(os.environ, PATH=f'{root}:{os.environ["PATH"]}', MODE=mode, CALLS=str(calls))
env = dict(os.environ, PATH=f'{root}:{os.environ["PATH"]}', MODE=mode, CALLS=str(calls), TMPDIR=str(root))
result = subprocess.run(['bash', str(ROOT / 'scripts/test-private-desktop.sh'), str(root)],
env=env, text=True, capture_output=True, timeout=10)
self.assertNotIn('PRIVATE_STD', result.stdout + result.stderr)
self.assertNotIn('PRIVATE_SOURCE', result.stdout + result.stderr)
self.assertNotIn('PRIVATE_PATH', result.stdout + result.stderr)
self.assertNotIn('PRIVATE_SYMBOL', result.stdout + result.stderr)
self.assertFalse(list(root.glob('tmp.*')), 'Private command output must be deleted')
recorded = [json.loads(line) for line in calls.read_text().splitlines()]
self.assertEqual(recorded[-1][:2], ['rm', '--force'])
return result
@@ -146,6 +249,8 @@ class PrivateTestStageTests(unittest.TestCase):
result = self.run_stages('fail')
self.assertEqual(result.returncode, 19)
self.assertIn('Rust tests: failed', result.stdout)
self.assertIn(hashlib.sha256(b'private::test_function').hexdigest(), result.stdout)
self.assertNotIn('private::test_function', result.stdout + result.stderr)
self.assertNotRegex(result.stdout, r'(?m)^Rust tests: passed')
def test_hung_tests_report_timeout_and_cleanup(self):
@@ -154,6 +259,82 @@ class PrivateTestStageTests(unittest.TestCase):
self.assertIn('Rust tests: timed out', result.stdout)
self.assertNotRegex(result.stdout, r'(?m)^Rust tests: passed')
def test_compile_failure_reports_only_allowlisted_diagnostics(self):
cases = {
'compile-type': 'Rust diagnostic codes: error[E0061] error[E0308]',
'compile-disk': 'insufficient disk space',
'compile-killed': 'compiler or linker killed by SIGKILL',
'compile-link': 'unresolved linker symbols',
'compile-macro': 'procedural macro failed',
}
for mode, expected in cases.items():
with self.subTest(mode=mode):
result = self.run_stages(mode)
self.assertEqual(result.returncode, 101, result.stdout + result.stderr)
self.assertIn(expected, result.stdout)
self.assertNotRegex(result.stdout, r'(?m)^Rust tests: started')
def test_test_diagnostics_hash_names_without_exposing_private_details(self):
with tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log'
log.write_text('test private::one ... FAILED\nPRIVATE_SOURCE\n'
'test private::one ... FAILED\n'
'test private::two ... ok\n')
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
'tests', str(log)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
digest = hashlib.sha256(b'private::one').hexdigest()
self.assertEqual(result.stdout, f'::error::Rust test failure fingerprint: {digest}\n')
self.assertEqual(result.stderr, '')
def test_panic_diagnostics_hide_filename_and_payload(self):
for thread_id in ('', ' (1234)'):
with self.subTest(thread_id=thread_id), tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log'
log.write_text('test private::one ... FAILED\n'
f"thread 'private::one'{thread_id} panicked at PRIVATE_FILENAME.rs:321:9:\n"
'PRIVATE_PANIC_PAYLOAD\n')
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
'tests', str(log)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
digest = hashlib.sha256(b'private::one').hexdigest()
self.assertEqual(result.stdout,
f'::error::Rust test failure fingerprint: {digest}\n'
f'::error::Rust test panic location: {digest} 321:9\n')
self.assertEqual(result.stderr, '')
def test_overdue_diagnostics_hash_names_without_exposing_messages(self):
with tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log'
log.write_text('test private::slow has been running for over 60 seconds\n'
'PRIVATE_SOURCE_PATH: PRIVATE_PAYLOAD\n'
'test private::slow has been running for over 60 seconds\n')
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
'tests', str(log)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
digest = hashlib.sha256(b'private::slow').hexdigest()
self.assertEqual(result.stdout, f'::error::Rust overdue test fingerprint: {digest}\n')
self.assertEqual(result.stderr, '')
def test_last_running_target_hash_is_stable_without_paths_or_build_hashes(self):
for source, basename in [('unittests src/lib.rs', 'private_crate'),
('tests/PRIVATE_HARNESS.rs', 'private_harness')]:
for prefix, build_hash in [('/PRIVATE_SOURCE_ONE', '0123456789abcdef'),
('/PRIVATE_SOURCE_TWO', 'fedcba9876543210')]:
with self.subTest(source=source, prefix=prefix), tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log'
log.write_text(' Running tests/previous.rs (/PRIVATE_SOURCE/previous-1111111111111111)\n'
f' Running {source} ({prefix}/target/debug/deps/{basename}-{build_hash})\n'
'PRIVATE_PAYLOAD\n')
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
'tests', str(log)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
identity = f'{source} ({basename})'
digest = hashlib.sha256(identity.encode()).hexdigest()
self.assertEqual(result.stdout,
f'::error::Rust last running target fingerprint: {digest}\n')
self.assertEqual(result.stderr, '')
class MacOSArtifactSelectionTests(unittest.TestCase):
def select(self, jobs, artifacts=None):
+26 -11
View File
@@ -18,7 +18,7 @@ class MacOSReleaseTests(unittest.TestCase):
self.commit = "a" * 40
self.metadata = {"gp_ref": "b" * 40, "gpgui_ref": "d" * 40, "workflow_sha": self.commit, "channel": "stable",
"release_tag": "v3.0.1", "artifact_version": "3.0.1",
"request_id": "42.1.macos", "build_version": "903.1", "assets": {}}
"request_id": "42.1.macos", "build_version": "903.1", "gui": "tauri", "assets": {}}
for extension in ("dmg", "zip"):
name = f"GPConnect_3.0.1_arm64.{extension}"
content = b"signed artifact"
@@ -34,48 +34,63 @@ class MacOSReleaseTests(unittest.TestCase):
(self.directory / "release-build.json").write_text(json.dumps(self.metadata))
def test_matching_build_passes(self):
self.assertEqual(release.validate(self.directory, "v3.0.1", self.commit), self.metadata)
self.assertEqual(release.validate(self.directory, "v3.0.1", self.commit, "tauri"), self.metadata)
def test_another_gui_cannot_use_this_build(self):
with self.assertRaisesRegex(ValueError, "desktop shell"):
release.validate(self.directory, "v3.0.1", self.commit, "nsh")
def test_shell_metadata_is_required(self):
del self.metadata["gui"]
self.save()
with self.assertRaisesRegex(ValueError, "desktop shell"):
release.validate(self.directory, "v3.0.1", self.commit, "tauri")
def test_nsh_metadata_is_accepted_only_when_requested(self):
self.metadata["gui"] = "nsh"
self.save()
self.assertEqual(release.validate(self.directory, "v3.0.1", self.commit, "nsh"), self.metadata)
def test_another_release_cannot_use_this_build(self):
with self.assertRaisesRegex(ValueError, "release tag"):
release.validate(self.directory, "v3.0.2", self.commit)
release.validate(self.directory, "v3.0.2", self.commit, "tauri")
def test_another_run_commit_cannot_use_this_build(self):
with self.assertRaisesRegex(ValueError, "public workflow"):
release.validate(self.directory, "v3.0.1", "c" * 40)
release.validate(self.directory, "v3.0.1", "c" * 40, "tauri")
def test_source_commit_cannot_replace_workflow_identity(self):
with self.assertRaisesRegex(ValueError, "public workflow"):
release.validate(self.directory, "v3.0.1", self.metadata["gp_ref"])
release.validate(self.directory, "v3.0.1", self.metadata["gp_ref"], "tauri")
def test_invalid_workflow_commit_is_rejected(self):
self.metadata["workflow_sha"] = "short"
self.save()
with self.assertRaisesRegex(ValueError, "Invalid workflow_sha"):
release.validate(self.directory, "v3.0.1", "short")
release.validate(self.directory, "v3.0.1", "short", "tauri")
def test_corrupt_download_is_rejected(self):
(self.directory / "GPConnect_3.0.1_arm64.zip").write_bytes(b"changed")
with self.assertRaisesRegex(ValueError, "checksum mismatch"):
release.validate(self.directory, "v3.0.1", self.commit)
release.validate(self.directory, "v3.0.1", self.commit, "tauri")
def test_unexpected_file_is_rejected(self):
(self.directory / "unexpected.dmg").write_bytes(b"extra")
with self.assertRaisesRegex(ValueError, "Unexpected"):
release.validate(self.directory, "v3.0.1", self.commit)
release.validate(self.directory, "v3.0.1", self.commit, "tauri")
def test_missing_checksum_is_rejected(self):
self.metadata["assets"].pop("GPConnect_3.0.1_arm64.zip.sha256")
self.save()
with self.assertRaisesRegex(ValueError, "exactly"):
release.validate(self.directory, "v3.0.1", self.commit)
release.validate(self.directory, "v3.0.1", self.commit, "tauri")
def test_snapshot_requires_matching_build_identity(self):
self.metadata.update(channel="snapshot", release_tag="snapshot",
artifact_version="3.0.1-snapshot.903.2")
self.save()
with self.assertRaisesRegex(ValueError, "snapshot artifact version"):
release.validate(self.directory, "snapshot", self.commit)
release.validate(self.directory, "snapshot", self.commit, "tauri")
def test_matching_snapshot_passes(self):
version = "3.0.1-snapshot.903.1"
@@ -92,7 +107,7 @@ class MacOSReleaseTests(unittest.TestCase):
self.metadata.update(channel="snapshot", release_tag="snapshot",
artifact_version=version, assets=assets)
self.save()
self.assertEqual(release.validate(self.directory, "snapshot", self.commit), self.metadata)
self.assertEqual(release.validate(self.directory, "snapshot", self.commit, "tauri"), self.metadata)
if __name__ == "__main__":
+5 -2
View File
@@ -8,8 +8,10 @@ from pathlib import Path
import re
def validate(directory, release_tag, workflow_commit):
def validate(directory, release_tag, workflow_commit, gui):
metadata = json.loads((directory / "release-build.json").read_text())
if gui not in ("tauri", "nsh") or metadata.get("gui") != gui:
raise ValueError("Artifact desktop shell does not match the selected GUI")
for name in ("gp_ref", "gpgui_ref", "workflow_sha"):
if not re.fullmatch(r"[0-9a-f]{40}", metadata[name]):
raise ValueError(f"Invalid {name}")
@@ -59,9 +61,10 @@ if __name__ == "__main__":
parser.add_argument("directory", type=Path)
parser.add_argument("--release-tag", required=True)
parser.add_argument("--workflow-commit", required=True)
parser.add_argument("--gui", choices=("tauri", "nsh"), required=True)
args = parser.parse_args()
try:
result = validate(args.directory, args.release_tag, args.workflow_commit)
result = validate(args.directory, args.release_tag, args.workflow_commit, args.gui)
except (ValueError, KeyError, OSError) as error:
parser.exit(1, f"{error}\n")
print(json.dumps(result))