Merge branch 'main' into wt/t_87d7245b
This commit is contained in:
commit
f01cb7b937
4 changed files with 147 additions and 51 deletions
|
|
@ -2,10 +2,29 @@ name: ci
|
|||
|
||||
# Tests and clippy run on the Pi runner (aarch64) inside a rust container, so
|
||||
# this CI proves the aarch64 build too. Jobs use the runner's `docker` label.
|
||||
#
|
||||
# Path allowlist: skip the cargo job when the change cannot affect the Rust
|
||||
# build (docs, android, scripts, sibling workflows, markdown). No required
|
||||
# status checks on main, so a missing run is not a merge trap.
|
||||
# workflow_dispatch has no path filter — it always runs the suite.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/**"
|
||||
- "crates/**"
|
||||
- "tests/**"
|
||||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- ".forgejo/workflows/ci.yml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "src/**"
|
||||
- "crates/**"
|
||||
- "tests/**"
|
||||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- ".forgejo/workflows/ci.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
# One cargo job on the Pi at a time. Overlapping PR+main runs shared the
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ on:
|
|||
- "crates/**"
|
||||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- ".forgejo/workflows/release.yml"
|
||||
- "scripts/build-release-local.sh"
|
||||
- "scripts/release-body.md"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
|
@ -28,13 +26,18 @@ on:
|
|||
type: string
|
||||
default: "false"
|
||||
|
||||
# Same group as ci.yml: both cargo builds share the Pi's 4 cores and the
|
||||
# onionwire-cargo-registry volume. A separate group raced tests and produced
|
||||
# Permission denied (os error 13) on /target/debug/deps/* binaries.
|
||||
concurrency:
|
||||
group: onionwire-release
|
||||
group: onionwire-ci-pi
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: never
|
||||
RUST_IMAGE: rust:1.91-bookworm
|
||||
# Not baking pkg-config/libssl-dev into a custom image on this card —
|
||||
# dind PVC would make that the durable fix for the apt loop. Filed separately.
|
||||
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
||||
|
||||
jobs:
|
||||
|
|
@ -170,8 +173,8 @@ jobs:
|
|||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& cargo build --release --locked \
|
||||
&& strip /target/release/onionwire \
|
||||
&& ls -l /target/release/onionwire'
|
||||
|
|
@ -221,6 +224,21 @@ jobs:
|
|||
- name: Show runner arch
|
||||
run: uname -m && echo "target=$TARGET"
|
||||
|
||||
- name: Ensure docker CLI (amd64 dind job image has none)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.3.1.tgz \
|
||||
| tar xz -C /tmp
|
||||
install -m 755 /tmp/docker/docker /usr/local/bin/docker
|
||||
fi
|
||||
docker version
|
||||
if [ ! -S /var/run/docker.sock ]; then
|
||||
echo "docker.sock is not mounted into the job container" >&2
|
||||
ls -l /var/run || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build ${{ env.TARGET }} in a rust container
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
|
@ -238,8 +256,8 @@ jobs:
|
|||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& cargo build --release --locked \
|
||||
&& strip /target/release/onionwire \
|
||||
&& ls -l /target/release/onionwire'
|
||||
|
|
@ -274,21 +292,43 @@ jobs:
|
|||
|
||||
publish:
|
||||
needs: [version, aarch64, x86_64]
|
||||
if: needs.version.outputs.dry_run != 'true'
|
||||
runs-on: docker-amd64
|
||||
# Always run after version so a failed build still hits the fail-closed
|
||||
# delete step (a skipped publish left act without a job result).
|
||||
# Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and
|
||||
# android-release sat in front of run 116's publish for ~1h; the Pi
|
||||
# already created the tag over the public API (version job), so publish
|
||||
# uses that same path. This job only curls the Forgejo API — no docker CLI.
|
||||
# Fail-closed tag delete lives as a step here: a sibling cleanup job ran
|
||||
# after a successful publish (act treats needs.publish.result as unset, so
|
||||
# != success) and Early-terminated on run 135. Do not restore that job.
|
||||
if: always() && needs.version.result == 'success'
|
||||
runs-on: docker
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Skip publish on dry_run
|
||||
if: needs.version.outputs.dry_run == 'true'
|
||||
run: echo "dry_run not publishing"
|
||||
|
||||
- name: Fail closed if a build failed
|
||||
if: needs.version.outputs.dry_run != 'true' && (needs.aarch64.result != 'success' || needs.x86_64.result != 'success')
|
||||
run: |
|
||||
echo "aarch64=${{ needs.aarch64.result }} x86_64=${{ needs.x86_64.result }}" >&2
|
||||
exit 1
|
||||
|
||||
- name: Checkout CI tooling
|
||||
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
path: .ci-tools
|
||||
|
||||
- name: Download both arch artifacts
|
||||
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
|
||||
uses: https://code.forgejo.org/actions/download-artifact@v3
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Publish both binaries to one release
|
||||
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
|
|
@ -335,30 +375,33 @@ jobs:
|
|||
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
|
||||
cleanup:
|
||||
needs: [version, aarch64, x86_64, publish]
|
||||
if: ${{ always() && needs.version.outputs.created_tag == 'true' && (needs.aarch64.result != 'success' || needs.x86_64.result != 'success' || needs.publish.result != 'success') }}
|
||||
runs-on: docker
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Delete tag and incomplete release we created
|
||||
- name: Delete tag we created if this job failed
|
||||
if: failure() && needs.version.outputs.created_tag == 'true' && needs.version.outputs.dry_run != 'true'
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
TAG: ${{ needs.version.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
|
||||
echo "fail-closed: removing tag $TAG created by this run"
|
||||
code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/releases/tags/$TAG")
|
||||
if [ "$code" = "200" ]; then
|
||||
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
|
||||
echo "deleting incomplete release id $rid"
|
||||
curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
curl -sS --http1.1 -X DELETE \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n"
|
||||
else
|
||||
echo "no release for $TAG (HTTP $code)"
|
||||
fi
|
||||
curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
"$REPO_API/tags/$TAG" -o /dev/null -w "DELETE tag HTTP %{http_code}\n"
|
||||
del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \
|
||||
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||
"$REPO_API/tags/$TAG")
|
||||
echo "DELETE tag HTTP $del"
|
||||
if [ "$del" != "204" ] && [ "$del" != "404" ]; then
|
||||
cat /tmp/tag-del.json >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue