diff --git a/git b/git new file mode 100644 index 0000000..e69de29 diff --git a/issue-5 b/issue-5 new file mode 100644 index 0000000..e69de29 diff --git a/manual/devopsAutomatedManualBuild.tex b/manual/devopsAutomatedManualBuild.tex new file mode 100644 index 0000000..9435e14 --- /dev/null +++ b/manual/devopsAutomatedManualBuild.tex @@ -0,0 +1,261 @@ +\chapter{Automated Manual Build} +\ChapterLabel{AutomatedManualBuild} +\index{Gitea Actions} +\index{automated manual build} + +% --------------------------------------------------------------------------- +% Bracketed italic text marks evidence that is added once the runner is online +% and a real workflow run exists. Replace each placeholder with the actual +% value or screenshot; do not fill them in before the run has happened. +% --------------------------------------------------------------------------- + +\section{Source and Trigger} + +\textbf{Repository and files:} +\begin{description} + \item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web} + \item[Manual source folder:] + \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual} + \item[Main file:] + \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual/devopsAssignment.tex} + \item[Workflow:] + \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/.gitea/workflows/manual.yml} + \item[Tracking issue:] + \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/8} + \item[Pull request:] \textit{[link to the merged pull request from + \texttt{issue-8} into \texttt{main}]} +\end{description} + +The manual is stored in the \texttt{manual/} folder of the team's existing +product repository, Scrap-Web, rather than in a separate repository. The +complete buildable project is version-controlled there: every chapter file, +the \texttt{cornell.cls} document class, the \texttt{IEEEtran.bst} +bibliography style, \texttt{devopsReferences.bib}, the glossary, and all +figures under \texttt{HW2 images/} and \texttt{HW4 images/}. Generated files +(PDF, \texttt{.aux}, \texttt{.log}, minted cache, and so on) are excluded by +\texttt{manual/.gitignore}, so the repository holds source only. The +repository is the source of truth; the PDF is never edited directly. + +\textbf{How the source was added:} the manual was committed on the branch +\texttt{issue-8} (tracked by issue \#8), pushed to Gitea, and merged into +\texttt{main} through a pull request. Work on the website itself happens on +other branches and is unaffected. + +\textbf{Selected branch and event:} the workflow runs on a \texttt{push} to +\texttt{main}. A path filter limits it to pushes that change +\texttt{manual/**} or the workflow file itself, so website-only commits do +not rebuild the manual. Merging a pull request into \texttt{main} counts as +such a push. The workflow can also be started by hand from the Actions tab +(\texttt{workflow\_dispatch}). + +\textit{[Figure: Actions tab showing a run triggered by the merge commit into +\texttt{main}, dated.]} + +\textbf{Git remote and network path:} team members push over HTTPS. The +remote is configured as: +\begin{verbatim} +$ git remote -v +origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (fetch) +origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (push) +\end{verbatim} + +\begin{center} +\begin{tabular}{lll} +\toprule +Hop & Port & Exposure \\ +\midrule +Laptop $\rightarrow$ Caddy (TLS proxy) & 443/TCP (HTTPS) & Public \\ +Caddy $\rightarrow$ Gitea web service & 3000/TCP (HTTP) & Private Docker network only \\ +\bottomrule +\end{tabular} +\end{center} + +A \texttt{git push} connects to \texttt{git.ssw590-08.me} on port 443, +exactly as a browser does. Caddy terminates TLS and forwards the request over +the internal Docker network to Gitea on port 3000, which is not published to +the internet. Gitea's public root URL is set to +\url{https://git.ssw590-08.me/}, so clone URLs and links point at the HTTPS +hostname. SSH pushes are not needed for this assignment. + +\textbf{Why the runner needs no public port:} the runner never receives +connections. It contacts Gitea outbound over HTTPS to register and to poll +for jobs; the job then checks out the source and uploads the PDF over the +same HTTPS URL. Because all traffic is initiated by the runner, no submission +or management port has to be opened for it. + +\section{Runner Setup} +\textit{[To be completed with the runner registration (Part 2): version, +location, scope, label \texttt{latex}, execution mode, capacity, network path, +and a screenshot of the runner online with a job assigned.]} + +\section{Reproducible Compilation} + +\begin{description} + \item[Main file:] \texttt{manual/devopsAssignment.tex} + \item[Build command:] \texttt{latexmk devopsAssignment.tex}, run in the + \texttt{manual/} folder + \item[Build configuration:] \texttt{manual/.latexmkrc} + \item[Expected PDF path:] \texttt{manual/devopsAssignment.pdf} + \item[Job image definition:] \texttt{manual/ci/Dockerfile} + \item[Base image:] \texttt{texlive/texlive:TL2025-historic} + \item[Resolved image ID/digest:] \textit{[from the runner host]} +\end{description} + +\textbf{Where TeX runs:} the compiler is not installed in the Gitea +container. The workflow targets the runner label \texttt{latex} +(\texttt{runs-on: latex}), which maps to a job image built from +\texttt{manual/ci/Dockerfile}. That image is the official TeX Live image, +which already contains \texttt{pdflatex}, \texttt{latexmk}, \texttt{bibtex}, +\texttt{makeindex}, \texttt{makeglossaries}, and Python with Pygments (needed +by the \texttt{minted} package). The Dockerfile adds only Node.js and Git from +the image's own Debian package repositories, which the checkout and upload +actions require; no external script is downloaded and executed. The base +image uses a fixed TeX Live release tag rather than \texttt{latest}, so every +build uses the same toolchain. + +\textbf{Build command and dependencies:} all compiler options are stored in +\texttt{manual/.latexmkrc}, so the same command works on a laptop and in the +workflow: +\begin{minted}[breaklines]{perl} +$pdf_mode = 1; +$pdflatex = 'pdflatex -shell-escape -interaction=nonstopmode -halt-on-error -file-line-error %O %S'; +add_cus_dep('glo', 'gls', 0, 'run_makeglossaries'); +add_cus_dep('acn', 'acr', 0, 'run_makeglossaries'); +sub run_makeglossaries { return system("makeglossaries \"$_[0]\""); } +\end{minted} +\texttt{latexmk} runs \texttt{pdflatex} as many times as needed and calls +\texttt{bibtex}, \texttt{makeindex}, and \texttt{makeglossaries} when their +inputs change. \texttt{-shell-escape} is required by \texttt{minted}. + +\textbf{Workflow:} the complete workflow file is shown below. +\begin{minted}[breaklines]{yaml} +name: Build IT manual + +on: + push: + branches: [main] + paths: + - 'manual/**' + - '.gitea/workflows/manual.yml' + workflow_dispatch: + +jobs: + build-manual: + runs-on: latex + defaults: + run: + shell: bash + steps: + - name: Check out the triggering commit + uses: actions/checkout@v4 + + - name: Record build identity and toolchain + run: | + SHORT_SHA="${GITHUB_SHA::7}" + echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV" + echo "Commit: ${GITHUB_SHA} (${SHORT_SHA})" + echo "Run number: ${GITHUB_RUN_NUMBER}" + pdflatex --version | head -n 1 + latexmk -v | head -n 2 | tail -n 1 + python3 -c "import pygments; print('Pygments', pygments.__version__)" + + - name: Compile the manual + working-directory: manual + run: latexmk devopsAssignment.tex + + - name: Verify the PDF exists + working-directory: manual + run: | + if [ ! -s devopsAssignment.pdf ]; then + echo "ERROR: manual/devopsAssignment.pdf is missing or empty" + exit 1 + fi + ls -l devopsAssignment.pdf + + - name: Upload the PDF as an artifact + uses: actions/upload-artifact@v4 + with: + name: it-manual-build-${{ github.run_number }}-${{ env.SHORT_SHA }} + path: manual/devopsAssignment.pdf + if-no-files-found: error + retention-days: 30 +\end{minted} + +\textbf{Failure detection:} the build fails in three independent ways. +\begin{enumerate} + \item A LaTeX error stops \texttt{pdflatex} immediately + (\texttt{-halt-on-error}); \texttt{latexmk} then exits with a non-zero + code, which fails the \emph{Compile the manual} step. The log shows the + failing file and line (\texttt{-file-line-error}). + \item If compilation reports success but the PDF is missing or empty, the + \emph{Verify the PDF exists} step exits with code 1 and prints an error. + \item The upload step uses \texttt{if-no-files-found: error}, so it cannot + silently upload nothing. +\end{enumerate} +A failed step stops the job, so no artifact is produced from a broken build. + +\textbf{Checkout and upload without a shared filesystem:} the job container +shares no files with Gitea. The \texttt{actions/checkout} step clones the +exact triggering commit from Gitea over HTTPS, the compile happens inside the +temporary job container, and \texttt{actions/upload-artifact} sends the PDF +back to Gitea over HTTPS, where it is attached to the matching run. The +container is discarded when the job ends. + +\textit{[Link to a successful run log, and a dated screenshot of the +compile and verify steps passing.]} + +\section{PDF Version Traceability} +\textit{[To be completed (Part 4): human-maintained version, generated build +identifier such as \texttt{v1.4+build.N.abcdef0}, visible commit hash and run +number in the PDF, matching Gitea run, and how the metadata is injected +without committing back to the branch.]} + +\section{Downloadable Artifact} + +\begin{description} + \item[Artifact name:] \texttt{it-manual-build-\textit{N}-\textit{H}}, + where \textit{N} is the workflow run number and \textit{H} is the short + commit hash; for example, \texttt{it-manual-build-12-a1b2c3d} + \item[Contents:] \texttt{devopsAssignment.pdf} + \item[Retention:] 30 days, set in the workflow + (\texttt{retention-days: 30}). \textit{[Confirm the server's maximum + artifact retention; Gitea applies the lower of the two.]} + \item[Example artifact link:] \textit{[link to the artifact on a successful + run]} +\end{description} + +Because the run number and commit hash are part of the artifact name, each +downloaded file can be matched to the run and commit that produced it. + +\textbf{How a team member downloads the PDF:} +\begin{enumerate} + \item Open \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions}. + \item Select the \emph{Build IT manual} workflow and open the run for the + commit of interest (the run lists its commit hash and branch). + \item Confirm the run finished successfully. + \item In the run's \emph{Artifacts} section, click + \texttt{it-manual-build-\ldots} to download it, then extract and open + \texttt{devopsAssignment.pdf}. +\end{enumerate} + +Artifacts expire after the retention period and are not a backup. The +permanent record is the LaTeX source in Git, from which any version of the +manual can be rebuilt. + +\textit{[Figure: run page with the artifact listed, and the downloaded PDF +open, dated.]} + +\section{Change, Failure, and Repair Evidence} +\textit{[To be completed together (Part 6): two successive commits with +their runs and PDF identifiers, one deliberate LaTeX error with its failed +run, and the repaired passing run.]} + +\section{Runner and Secret Boundary} +\textit{[To be completed (Part 7): workflow edit rights, where the runner +registration token is stored (without its value), runner isolation, and +Docker socket risk.]} + +\section{Manual Quality and Controls} +\textit{[To be completed (Part 8): version and history update, whether the +Hosts and Passwords tables changed, and a short failed-build troubleshooting +procedure.]}