CI / Linux checks (pull_request) Failing after 21m18s
command -v with two names returns 0 when one resolves, so the guards were weaker than they read. The release workflow's final step killed whatever agent SSH_AGENT_PID named; it now needs the marker the start step writes after it succeeded. Two documentation lines re-wrapped (the review's three minors). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
172 lines
7.0 KiB
YAML
172 lines
7.0 KiB
YAML
name: Linux checks
|
|
description: Shared Linux validation for Gitea CI and release packaging.
|
|
inputs:
|
|
protocol-deploy-key:
|
|
description: >
|
|
Private half of the read-only deploy key registered on the private
|
|
Voelin/VoelinProtocol repository (the repository secret
|
|
VOELIN_PROTOCOL_DEPLOY_KEY, passed in by the workflow: secrets are not
|
|
visible inside a composite action). The action fails when it is empty.
|
|
required: true
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
# The workspace depends on the private VoelinProtocol repository over SSH
|
|
# (docs/ci.md, "VoelinProtocol access"). First, so that a missing key fails
|
|
# in seconds and before anything runs cargo.
|
|
- name: Install the VoelinProtocol deploy key
|
|
# The key reaches this step through the environment only: never in the
|
|
# script text, never echoed, no `set -x`.
|
|
env:
|
|
PROTOCOL_DEPLOY_KEY: ${{ inputs.protocol-deploy-key }}
|
|
run: |
|
|
set -euo pipefail
|
|
umask 077
|
|
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
|
|
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2
|
|
exit 1
|
|
fi
|
|
for tool in ssh ssh-keygen; do
|
|
command -v "$tool" > /dev/null || {
|
|
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
|
|
exit 1
|
|
}
|
|
done
|
|
ssh_dir="$HOME/.ssh"
|
|
key_file="$ssh_dir/voelin_protocol"
|
|
mkdir -p "$ssh_dir"
|
|
chmod 700 "$ssh_dir"
|
|
|
|
# Whatever the secret store did to the line ends and the final newline,
|
|
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
|
|
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
|
|
unset PROTOCOL_DEPLOY_KEY
|
|
chmod 600 "$key_file"
|
|
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
|
|
rm -f "$key_file"
|
|
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
|
|
exit 1
|
|
fi
|
|
# The fingerprint of the public half, to compare with the deploy key in
|
|
# the VoelinProtocol settings.
|
|
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
|
|
|
|
# The reviewed host key from the repository, never one fetched now.
|
|
known_hosts="$ssh_dir/known_hosts"
|
|
touch "$known_hosts"
|
|
chmod 600 "$known_hosts"
|
|
[[ -s "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" ]] || {
|
|
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
|
|
exit 1
|
|
}
|
|
while IFS= read -r line; do
|
|
case "$line" in '' | '#'*) continue ;; esac
|
|
grep -qxF -- "$line" "$known_hosts" || printf '%s\n' "$line" >> "$known_hosts"
|
|
done < "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts"
|
|
|
|
# Use this key, and only this one, for the Gitea server; fail rather than
|
|
# ask when its host key is unknown or changed. The block goes first: ssh
|
|
# takes the first value it finds for each option.
|
|
config="$ssh_dir/config"
|
|
marker="# VoelinProtocol deploy key (.gitea/actions/checks)"
|
|
touch "$config"
|
|
if ! grep -qxF -- "$marker" "$config"; then
|
|
{
|
|
cat << EOF
|
|
$marker
|
|
Host git.faumaray.com
|
|
User gitea
|
|
IdentityFile $key_file
|
|
IdentitiesOnly yes
|
|
UserKnownHostsFile $known_hosts
|
|
StrictHostKeyChecking yes
|
|
BatchMode yes
|
|
ConnectTimeout 30
|
|
|
|
EOF
|
|
cat "$config"
|
|
} > "$config.new"
|
|
mv "$config.new" "$config"
|
|
fi
|
|
chmod 600 "$config"
|
|
|
|
# Cargo's built-in git client (libgit2) cannot use IdentityFile; the
|
|
# system git runs ssh, which reads the config above. `-F` names it
|
|
# outright: ssh looks for ~/.ssh in the passwd entry's home directory, not
|
|
# in $HOME, and a job image may set the two apart.
|
|
{
|
|
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true"
|
|
echo "GIT_SSH_COMMAND=ssh -F '$config'"
|
|
} >> "$GITHUB_ENV"
|
|
shell: bash
|
|
- uses: ./.github/actions/system-deps
|
|
- name: Check read access to VoelinProtocol
|
|
# The first thing cargo does, with the same git and ssh configuration, so
|
|
# that a wrong key or a changed host key fails here with a clear message
|
|
# and not minutes later inside a cargo command.
|
|
run: |
|
|
set -euo pipefail
|
|
if ! GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --exit-code \
|
|
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
|
|
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
|
|
exit 1
|
|
fi
|
|
echo "Voelin/VoelinProtocol is readable with the deploy key."
|
|
shell: bash
|
|
- name: Install pinned Rust toolchain
|
|
run: |
|
|
set -euo pipefail
|
|
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
|
|
export PATH="$CARGO_HOME/bin:$PATH"
|
|
if ! command -v rustup >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
|
|
sh -s -- -y --profile minimal --default-toolchain none
|
|
fi
|
|
if [[ -f "$CARGO_HOME/env" ]]; then
|
|
# shellcheck source=/dev/null
|
|
source "$CARGO_HOME/env"
|
|
fi
|
|
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
|
rustup toolchain install
|
|
shell: bash
|
|
- name: rustfmt (own crates)
|
|
run: |
|
|
set -euo pipefail
|
|
packages=$(scripts/own-crates.sh)
|
|
read -r -a packages <<< "$packages"
|
|
cargo fmt "${packages[@]}" --check
|
|
shell: bash
|
|
- name: clippy (own crates, deny warnings)
|
|
run: |
|
|
set -euo pipefail
|
|
packages=$(scripts/own-crates.sh)
|
|
read -r -a packages <<< "$packages"
|
|
cargo clippy "${packages[@]}" --all-targets --no-deps --locked -- -D warnings
|
|
shell: bash
|
|
- name: clippy (workspace, report warnings)
|
|
run: cargo clippy --workspace --all-targets --locked
|
|
shell: bash
|
|
- name: Build
|
|
run: cargo build --workspace --all-targets --locked
|
|
shell: bash
|
|
- name: Test (X11 enabled)
|
|
run: |
|
|
# DISPLAY is assigned by xvfb-run, then expanded by the inner shell.
|
|
# shellcheck disable=SC2016
|
|
xvfb-run -a bash -c 'VOELIN_X11_TEST_DISPLAY="$DISPLAY" cargo test --workspace --locked'
|
|
shell: bash
|
|
- name: Install cargo-deny and cargo-about
|
|
run: |
|
|
cargo install cargo-deny --locked --version 0.20.2
|
|
cargo install cargo-about --locked --version 0.9.2 --features cli
|
|
shell: bash
|
|
- name: Dependency policy
|
|
run: cargo deny --locked --workspace check
|
|
shell: bash
|
|
- name: Third-party notices
|
|
run: scripts/notices.sh --check
|
|
shell: bash
|
|
- name: Release tooling regressions
|
|
run: python3 scripts/test-gitea-release.py
|
|
shell: bash
|