Add automated LaTeX manual build (refs #12)
Automated Manual Build / manual (push) Successful in 1m27s
Automated Manual Build / manual (push) Successful in 1m27s
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!Dockerfile
|
||||
@@ -0,0 +1 @@
|
||||
*.sh text eol=lf
|
||||
@@ -0,0 +1,12 @@
|
||||
# Node.js 22 on Debian Bookworm; resolve the base once, then pin its digest.
|
||||
FROM node:22-bookworm-slim@sha256:c3de60bf2f9dd0ac6370e6117950ff62d6e339527e7472301c9c78a017978392
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates git perl python3 python3-pygments libfile-which-perl \
|
||||
texlive-latex-base texlive-latex-recommended texlive-latex-extra \
|
||||
texlive-pictures texlive-fonts-recommended lmodern latexmk \
|
||||
&& mkdir -p /opt/manual-toolchain \
|
||||
&& dpkg-query -W -f='${Package} ${Version}\n' > /opt/manual-toolchain/packages.txt \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /workspace
|
||||
CMD ["bash"]
|
||||
@@ -0,0 +1,83 @@
|
||||
# Manual compiler and Gitea workflow
|
||||
|
||||
## Local runner preparation
|
||||
|
||||
Build the job image on the runner's Docker Desktop engine from repository root:
|
||||
|
||||
```powershell
|
||||
docker build --tag ssw590-manual-ci:20261007 ci/manual
|
||||
docker image inspect ssw590-manual-ci:20261007 --format '{{.Id}} {{.Size}}'
|
||||
```
|
||||
|
||||
The image includes Node.js for Actions, Git, TeX Live, latexmk, makeindex,
|
||||
Pygments, and the report's LaTeX dependencies. Its base image is pinned by
|
||||
digest. Debian package versions are recorded in
|
||||
`/opt/manual-toolchain/packages.txt`; a later rebuild can resolve newer Debian
|
||||
packages. Keep the tested local image and record its ID for the assignment.
|
||||
The runner's `latex-local` label selects this image, with one job at a time.
|
||||
Another runner machine must build the same image before accepting this label.
|
||||
|
||||
Verified on October 7, 2026:
|
||||
|
||||
- Image ID: `sha256:5d24657a4578977fc7709165b82fc869f09a654a58ab4a0c8defd9d2cd662d5d`.
|
||||
- Uncompressed image size: 1,257,822,547 bytes (about 1.17 GiB).
|
||||
- TeX Live 2022/Debian, latexmk 4.79, Node.js 22.23.3, Git 2.39.5.
|
||||
- Full document compiled locally; intentional LaTeX failure and repair passed,
|
||||
stale PDF/checksum were removed on failure, and a mismatched SHA was rejected.
|
||||
- Runner 2.3.0 parsed and listed the push workflow successfully. Checkout and
|
||||
artifact upload/download have not yet been demonstrated in a Gitea run.
|
||||
|
||||
## Workflow
|
||||
|
||||
`.gitea/workflows/manual.yml` runs on pushes to `main` and
|
||||
`codex/assignment5-*`. It checks out the triggering commit, verifies the
|
||||
checked-out SHA, compiles the manual, and uploads:
|
||||
|
||||
- `manual-pdf-build-<run>`: the verified, nonempty PDF;
|
||||
- `manual-diagnostics-build-<run>`: tool versions, package versions, compilation
|
||||
output, and PDF SHA-256 when available, including compilation failures.
|
||||
|
||||
Retention is requested as 14 days, subject to Gitea server policy. The PDF is
|
||||
named `2026F-SSW-590-DevOps-Group-1.pdf`. Its title-page version appends
|
||||
`+build.<run>.<short-commit>` to the human version. Metadata is generated only
|
||||
inside the job checkout and ignored by Git. The workflow never commits or
|
||||
pushes. A failed compilation removes any earlier deliverable and fails the job.
|
||||
Compilation runs in a disposable source copy under `build/manual/intermediate`
|
||||
so the installed minted version finds its temporary files in the current
|
||||
directory. The source checkout remains unchanged by metadata generation.
|
||||
Checkout and upload actions are pinned to full commits. The artifact action
|
||||
uses the v3-node20 legacy protocol for Gitea; actual upload and download still
|
||||
need a real Gitea run to establish compatibility.
|
||||
|
||||
## Local compiler check
|
||||
|
||||
From the prepared Gitea checkout:
|
||||
|
||||
```powershell
|
||||
docker run --rm --network none --cpus 1 --memory 512m --memory-swap 512m `
|
||||
--mount "type=bind,source=$((Get-Location).Path),target=/workspace" `
|
||||
--workdir /workspace --env MANUAL_LOCAL_TEST=1 `
|
||||
ssw590-manual-ci:20261007 sh ci/manual/build.sh
|
||||
```
|
||||
|
||||
This explicitly labels the PDF `+local-test`; it is not submission evidence for
|
||||
an Actions run. No registration token is needed. A real run must also prove
|
||||
checkout, job assignment, artifact upload, download, and opening the PDF.
|
||||
|
||||
## Trust boundary
|
||||
|
||||
Only the two trusted group members should be able to change workflow-covered
|
||||
branches. TeX uses shell escape for minted. The runner has Docker Desktop
|
||||
socket access and can create containers on this laptop; treat workflows as
|
||||
trusted code. Jobs are not privileged and the runner configuration does not
|
||||
automatically mount that socket into jobs. Registration state stays in the
|
||||
runner's named Docker volume, outside Git. No cloud or account secret is
|
||||
needed for a public source build; private checkout uses Gitea's automatic job
|
||||
token. Stop the runner when it is not needed.
|
||||
|
||||
## Evidence checkpoints
|
||||
|
||||
Capture the online runner; the run's triggering commit and assigned runner;
|
||||
successful compiler output; named artifact and download; the opened PDF with
|
||||
visible version/run/commit; then the second source-change run and the
|
||||
controlled failure and repair. Keep tokens and account settings out of shots.
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
repo_root=$(pwd)
|
||||
if [ -f "$repo_root/manual/latex/devopsAssignment.tex" ]; then
|
||||
source_dir="$repo_root/manual/latex"
|
||||
elif [ -f "$repo_root/latex/devopsAssignment.tex" ]; then
|
||||
source_dir="$repo_root/latex"
|
||||
else
|
||||
echo 'ERROR: main LaTeX source was not found.' >&2
|
||||
exit 1
|
||||
fi
|
||||
output_dir="$repo_root/build/manual"
|
||||
mkdir -p "$output_dir/intermediate"
|
||||
# Remove an earlier deliverable so it cannot be uploaded after a failed build.
|
||||
rm -f "$output_dir/2026F-SSW-590-DevOps-Group-1.pdf" "$output_dir/pdf-sha256.txt"
|
||||
|
||||
if [ "${MANUAL_LOCAL_TEST:-}" = '1' ]; then
|
||||
suffix='+local-test'
|
||||
revision='LOCAL WORKING COPY (not a Gitea run)'
|
||||
run_number='local-test'
|
||||
else
|
||||
: "${GITEA_SHA:?Workflow must supply the triggering commit}"
|
||||
: "${GITEA_RUN_NUMBER:?Workflow must supply the run number}"
|
||||
case "$GITEA_SHA" in *[!0-9a-fA-F]*|'') echo 'Invalid commit hash.' >&2; exit 1;; esac
|
||||
[ "${#GITEA_SHA}" -eq 40 ] || { echo 'Expected a full 40-character commit hash.' >&2; exit 1; }
|
||||
case "$GITEA_RUN_NUMBER" in *[!0-9]*|'') echo 'Invalid run number.' >&2; exit 1;; esac
|
||||
revision=$(git rev-parse HEAD)
|
||||
[ "$revision" = "$GITEA_SHA" ] || { echo 'Checked-out revision does not match the triggering commit.' >&2; exit 1; }
|
||||
short_sha=$(printf '%s' "$GITEA_SHA" | cut -c1-7)
|
||||
run_number="$GITEA_RUN_NUMBER"
|
||||
suffix="+build.$run_number.$short_sha"
|
||||
fi
|
||||
# minted in TeX Live 2022 expects its temporary files in the working directory.
|
||||
# Compile a disposable copy there instead of using pdflatex's output-directory.
|
||||
cp -R "$source_dir/." "$output_dir/intermediate/"
|
||||
printf '\\def\\CIBuildSuffix{%s}\n' "$suffix" > "$output_dir/intermediate/ci-build-metadata.tex"
|
||||
{
|
||||
printf 'Source revision: %s\nWorkflow run: %s\nVersion suffix: %s\n' "$revision" "$run_number" "$suffix"
|
||||
printf '\nToolchain:\n'
|
||||
pdflatex --version | head -n 1
|
||||
latexmk -version
|
||||
git --version
|
||||
node --version
|
||||
} | tee "$output_dir/build-info.txt"
|
||||
cp /opt/manual-toolchain/packages.txt "$output_dir/toolchain-packages.txt"
|
||||
cd "$output_dir/intermediate"
|
||||
if latexmk -r "$repo_root/ci/manual/latexmkrc" -pdf -shell-escape \
|
||||
-interaction=nonstopmode -halt-on-error -file-line-error \
|
||||
devopsAssignment.tex \
|
||||
> "$output_dir/compile-console.txt" 2>&1; then
|
||||
:
|
||||
else
|
||||
tail -n 65 "$output_dir/compile-console.txt"
|
||||
echo 'ERROR: LaTeX compilation failed.' >&2
|
||||
exit 1
|
||||
fi
|
||||
test -s "$output_dir/intermediate/devopsAssignment.pdf" || {
|
||||
echo 'ERROR: compiler returned without the expected PDF.' >&2
|
||||
exit 1
|
||||
}
|
||||
cp "$output_dir/intermediate/devopsAssignment.pdf" "$output_dir/2026F-SSW-590-DevOps-Group-1.pdf"
|
||||
sha256sum "$output_dir/2026F-SSW-590-DevOps-Group-1.pdf" | tee "$output_dir/pdf-sha256.txt"
|
||||
printf '\nPASS: PDF created at build/manual/2026F-SSW-590-DevOps-Group-1.pdf\n'
|
||||
printf 'Visible version suffix: %s\n' "$suffix"
|
||||
@@ -0,0 +1,10 @@
|
||||
add_cus_dep('glo', 'gls', 0, 'make_glossary');
|
||||
add_cus_dep('acn', 'acr', 0, 'make_acronyms');
|
||||
sub make_glossary {
|
||||
return system('makeindex', '-s', "$_[0].ist", '-t', "$_[0].glg",
|
||||
'-o', "$_[0].gls", "$_[0].glo");
|
||||
}
|
||||
sub make_acronyms {
|
||||
return system('makeindex', '-s', "$_[0].ist", '-t', "$_[0].alg",
|
||||
'-o', "$_[0].acr", "$_[0].acn");
|
||||
}
|
||||
Reference in New Issue
Block a user