Skip to content

Commit

Permalink
Merge pull request #237 from siefkenj/ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
siefkenj authored Mar 26, 2024
2 parents 79e9158 + bdc043c commit 1a58ced
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 98 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Textbook

on:
push:
branches: ["master", "main"]
pull_request:
branches: ["master", "main"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run makedist.sh in Docker container
run: |
cd ./ci
./prepare-for-ci.sh
docker compose up -d
docker compose exec -T ibllinearalgebra ./makedist.sh
docker compose down
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: textbook
path: ci/dist/

- name: Verifies all PDFs were built
run: |
cd ./ci
./verify-all-compiled.sh
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ci/book*
*.aux
*.fls
*.idx
*.ilg
*.ind
*.toc
*.xdv
*.log
*.out
draft
testing
html-conversion
newdocumentclass
*-bak
node_modules
slide-conversion
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

101 changes: 31 additions & 70 deletions book/linearalgebra.tex
Original file line number Diff line number Diff line change
@@ -1,87 +1,39 @@

% WARNING! Do not type any of the following 10 characters except as directed:
% & $ # % _ { } ^ ~ \
%
%%
%% default option for pdfx.sty if not specified on the command-line.
\providecommand{\pdfxopt}{a-1b}
%%
%% Use {filecontents} for the .xmpdata file before input encoding is specified.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents*}{\jobname.xmpdata}
% a macro definition, used below
\pdfxEnableCommands{% simple macro definitions can be provided everything expands to characters
\def\RossPete{Ross \& Pete}
}
\Title{Linear Algebra (\jobname)}% *not* set by LaTeX's \title
\Author{Jason Siefken\sep et al.}% *not* set by LaTeX's \author
\Subject{Linear Algebra textbook/workbook}
\Keywords{linear algebra\sep vectors\sep mathematics\sep textbook}
\Org{University of Toronto}
\CreatorTool{LaTeX + pdfx.sty with options \pdfxopt}
\Copyright{Jason Siefken}
\WebStatement{https://github.com/siefkenj/IBLLinearAlgebra/}% should be URL to copyright statement on the web
\CoverDisplayDate{2020}
\CoverDate{2020-06-14}% must be in format YYYY-MM-DD or YYYY-MM
\Doi{0.0.0.0}%
%
% setting the color profile, these reproduce the defaults; use your own, if required
%
% RGB is used with PDF/A (4 parameters):
\setRGBcolorprofile{sRGB_IEC61966-2-1_black_scaled.icc}{sRGB_IEC61966-2-1_black_scaled}{sRGB IEC61966 v2.1 with black scaling}{http://www.color.org}
%
% For Adobe Color Profiles, set the directory for your system
%
% e.g. on Mac OS X
% What is it under Windows ?
%
\gdef\ColorProfileDir{./common/}
%
% For available profiles, see file AdobeColorProfiles.tex
% For PDF/X-4p or PDF/X-5pg see file AdobeExternalProfiles.tex
%
% Now you can use the macros defined in those files:
\FOGRAXXXIX
%
% or CMYK is used with PDF/X (4 parameters)
% \setCMYKcolorprofile{\ColorProfileDir coated_FOGRA39L_argl.icc}{Coated FOGRA39}{FOGRA39 (ISO Coated v2 300\%\space (ECI))}{http://www.color.org}
\end{filecontents*}

\documentclass{workbook}

\newcommand{\copyrightdate}{2015--2024}

% pdfx will set color profile etc. information appropriately, so the pdf renders
% consistently across devices. But, it doesn't work with the xelatex-based tectonics
\usepackage{ifxetex}
\usepackage[utf8]{inputenc}
\ifxetex
\else
\usepackage[a-3u]{pdfx}
\hypersetup{hidelinks=true, linkcolor = {0 0 1} }
\fi
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{hyperxmp} % Embed meta data into the PDF
\hypersetup{%
hidelinks=true,
linkcolor = {0 0 1},
% Metadata to be embedded by hyperxmp
pdftitle={Linear Algebra (\jobname)},
pdfauthor={Jason Siefken},
pdfauthortitle={Author},
pdfcopyright={Copyright (C) \copyrightdate, Jason Siefken},
pdfsubject={Linear Algebra textbook/workbook},
pdfkeywords={linear algebra, vectors, mathematics, textbook},
pdfurl={https://github.com/siefkenj/IBLLinearAlgebra/},
pdflicenseurl={https://creativecommons.org/licenses/by-sa/4.0/},
}

%%%
% import all needed packages and macros
%%%
\usepackage[yyyymmdd]{datetime}
\input{common/preamble.tex}

% in non-xelatex engines, hyperref is loaded by `pdfx`. If `pdfx` is not loaded, load it here.
\ifxetex
\usepackage{hyperref}
\hypersetup{hidelinks=true, linkcolor = {0 0 1} }
\else
\fi

\usepackage{breqn}

%%%
% Set up the footers to have the correct copyright notices
%%%

\fancypagestyle{siefken}{%
\rfoot{\footnotesize\it \copyright\,Jason Siefken, 2015--2022 \ \makebox(30,5){\includegraphics[height=1.2em]{by-sa.pdf}}}
\rfoot{\footnotesize\it \copyright\,Jason Siefken, \copyrightdate \ \makebox(30,5){\includegraphics[height=1.2em]{by-sa.pdf}}}
\lfoot{}
\renewcommand{\headrulewidth}{0pt}
}
Expand Down Expand Up @@ -311,7 +263,8 @@




% Needed to get different PDF bookmarks from the TOC entries
\hypersetup{bookmarksdepth=3}

\pagestyle{empty}

Expand All @@ -335,6 +288,14 @@
\end{center}
\newpage
\mbox{}
{
\pagestyle{empty}
\setcounter{tocdepth}{1}
\tableofcontents
\thispagestyle{empty}
}
\newpage
\mbox{}
\newpage
\end{bookonly}

Expand Down Expand Up @@ -7114,7 +7075,7 @@ \subsection*{More Change of Basis}
these vectors have $n$ coordinates.

In general, $[\vec b_i]_{\mathcal B}$ should be the column vector
with zeroes in all coordinates except for a 1 in the $i^\text{th}$
with zeroes in all coordinates except for a 1 in the $i^{\text{th}}$
coordinate.
\end{solution}
\end{parts}
Expand Down Expand Up @@ -8951,8 +8912,8 @@ \section*{Eigenvectors}
=\matc{\lambda_1\\0\\\vdots\\0}.
\]
Therefore, the first column of $P^{-1}BP$ is $\matc{\lambda_1\\0\\\vdots\\0}$.
By similar reasoning, the $i^\text{th}$ column of $P^{-1}BP$ consists
of all zeroes except for $\lambda_i$ in the $i^\text{th}$ position.
By similar reasoning, the $i^{\text{th}}$ column of $P^{-1}BP$ consists
of all zeroes except for $\lambda_i$ in the $i^{\text{th}}$ position.
In other words, $B$ is similar to the diagonal matrix $D$ with
$\lambda_1, \lambda_2, \dots, \lambda_n$ along the diagonal, in that
order.
Expand Down
2 changes: 1 addition & 1 deletion book/workbook.cls
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
\RequirePackage{everypage}
\RequirePackage{xparse}
\RequirePackage{environ}
\RequirePackage[usenames, dvipsnames, cmyk, hyperref]{xcolor}
\RequirePackage[usenames, dvipsnames, rgb, hyperref]{xcolor}
\RequirePackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{breakable}
Expand Down
42 changes: 42 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Base image for LaTeX CI
FROM ghcr.io/xu-cheng/texlive-small:latest
WORKDIR /workdir

# Install additional LaTeX packages
RUN tlmgr update --self
# tlmgr --force install textpos everypage enumitem ifthen tikz wrapfig marginnote mparhack marginfix indextools nicematrix fnpct systeme datatool pgfplots environ tcolorbox tikzfill pdfcol titlesec changepage pdfx datetime fmtcount lipsum mathdesign tikz-cd translations xstring ly1 hyperxmp ifmtarg luacode
RUN tlmgr --force install \
textpos \
everypage \
enumitem \
wrapfig \
marginnote \
mparhack \
marginfix \
indextools \
nicematrix \
fnpct \
systeme \
datatool \
pgfplots \
environ \
tcolorbox \
tikzfill \
pdfcol \
titlesec \
changepage \
pdfx \
datetime \
fmtcount \
lipsum \
mathdesign \
tikz-cd \
translations \
xstring \
ly1 \
hyperxmp \
ifmtarg \
luacode

# Set a custom prompt
ENV PS1="\[\033[01;32m\]IBLLinearAlgebra\[\033[00m\]:\[\033[01;35m\]\w\[\033[00m\] $ "
30 changes: 30 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Continuous Integration

This folder contains files related to continuous integration (CI) for automatically building
and rebuilding the textbook source when needed.

### Building a new version of the Docker image

```bash
docker build . -t siefkenj/build-images:ibllinearalgebra
```

### Run the docker image

```bash
docker run -v `pwd`:/workdir -w /workdir -it --rm siefkenj/build-images:ibllinearalgebra
```

### Publish the docker image

After `docker login`, run:

```bash
docker push siefkenj/build-images:ibllinearalgebra
```

### Copying book source

```bash
rsync -rl --include='*/' --include='*.tex' --include='*.sty' --include='*.png' --include='*.jpg' --include='*.svg' --include="*.cls" --include="images/*" --exclude='*' ../book/ ./book-copy/
```
11 changes: 11 additions & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
ibllinearalgebra:
image: siefkenj/build-images:ibllinearalgebra
volumes:
- ./book-copy:/workdir/book
- ./dist:/workdir/dist
- ../makedist.sh:/workdir/makedist.sh:ro
working_dir: /workdir
stdin_open: true
tty: true
6 changes: 6 additions & 0 deletions ci/prepare-for-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#/bin/bash

rm -rf book-copy

# make a copy of all essential files
rsync -rlv --include='*/' --include='*.tex' --include='*.sty' --include='*.png' --include='*.jpg' --include='*.svg' --include="*.cls" --include="images/*" --exclude='*' ../book/ ./book-copy/
30 changes: 30 additions & 0 deletions ci/verify-all-compiled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

BUILD_DIR=./book-copy
EXIT_CODE=0

for texfile in $BUILD_DIR/linearalgebra*.tex; do
# Get the base name of the file (without path and extension)
basefile=$(basename "$texfile" .tex)

# Check if the corresponding PDF file exists
if [[ ! -f "./dist/$basefile.pdf" ]]; then
# If the PDF file does not exist, cat the corresponding log file
if [[ -f "$BUILD_DIR/$basefile.log" ]]; then
echo "" >&2
echo "" >&2
echo "THERE WAS AN ERROR WHEN BUILDING $basefile.pdf" >&2
echo "Log file for $basefile:" >&2

cat "$BUILD_DIR/$basefile.log" >&2

echo "" >&2
EXIT_CODE=1
else
echo "Log file for $basefile does not exist." >&2
EXIT_CODE=1
fi
fi
done

exit $EXIT_CODE
Binary file modified dist/linearalgebra-book.pdf
Binary file not shown.
Binary file modified dist/linearalgebra-instructor.pdf
Binary file not shown.
Binary file modified dist/linearalgebra-slides.pdf
Binary file not shown.
Binary file modified dist/linearalgebra-solutions.pdf
Binary file not shown.
Binary file modified dist/linearalgebra.pdf
Binary file not shown.

0 comments on commit 1a58ced

Please sign in to comment.