4 Commits

Author SHA1 Message Date
samahk13 81c343ddb6 Fix total_price: restore multiplication (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-23 22:41:45 -04:00
samahk13 091a9a9695 Update repository with local changes 2026-10-23 22:36:04 -04:00
samahk13 ab0bcc25f3 Demonstrate failing CI check: use addition in total_price (#11)
Scrap-Web/pipeline/pr-main There was a failure building this commit
2026-10-23 22:32:31 -04:00
samahk13 b899233138 Add pricing module, tests and Jenkinsfile for CI (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-18 15:03:41 -04:00
8 changed files with 326 additions and 13 deletions
+1
View File
@@ -0,0 +1 @@
__pycache__/
Vendored
+40
View File
@@ -0,0 +1,40 @@
// CI pipeline for Scrap-Web (SSW 590, Continuous Integration with Jenkins).
// Runs for every pull request through the Multibranch Pipeline job and reports
// its result to Gitea as a commit status. Uses only the Python 3 standard
// library, so no packages are downloaded during the build.
pipeline {
// Builds run on the Jenkins controller executor (see the IT manual for the
// documented risk). python3 must be installed in the Jenkins container.
agent any
options {
skipDefaultCheckout()
timeout(time: 10, unit: 'MINUTES')
}
stages {
stage('Checkout') {
steps {
checkout scm
// Record exactly which commit is being tested, for traceability.
sh 'git rev-parse HEAD'
sh 'python3 --version'
}
}
stage('Syntax check') {
steps {
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
}
}
stage('Test') {
steps {
sh 'python3 -m unittest discover -s tests -v'
}
}
}
post {
success { echo 'All checks passed.' }
failure { echo 'A stage failed: see the stage view for which one.' }
}
}
View File
View File
-13
View File
@@ -1,13 +0,0 @@
# Jenkins controller image for the Scrap-Web CI pipeline (SSW 590).
# The official Jenkins LTS image does not include Python, which the
# Jenkinsfile needs (builds run on the controller executor).
#
# Replace <LTS-TAG> with the exact tag currently in the Compose file,
# e.g. 2.xxx.y-lts-jdk21, so the recorded Jenkins version does not change.
FROM jenkins/jenkins:<LTS-TAG>
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 \
&& rm -rf /var/lib/apt/lists/*
USER jenkins
+261
View File
@@ -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.]}
+8
View File
@@ -0,0 +1,8 @@
"""Pricing helper for the Scrap-Web CI pipeline (SSW 590, Jenkins assignment)."""
def total_price(unit_price, quantity):
"""Return the total price for `quantity` items at `unit_price` each."""
if quantity < 1:
raise ValueError("Quantity must be positive")
return unit_price * quantity
+16
View File
@@ -0,0 +1,16 @@
import unittest
from pricing import total_price
class PricingTests(unittest.TestCase):
def test_total(self):
self.assertEqual(total_price(10, 3), 30)
def test_invalid_quantity(self):
with self.assertRaises(ValueError):
total_price(10, 0)
if __name__ == "__main__":
unittest.main()