Skip to content

Commit

Permalink
Merge pull request #238 from siefkenj/ci
Browse files Browse the repository at this point in the history
Derive Pretext Sources
  • Loading branch information
siefkenj authored Mar 28, 2024
2 parents 1a58ced + e2a4d92 commit 94e4b97
Show file tree
Hide file tree
Showing 8 changed files with 1,298 additions and 3 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,130 @@ jobs:
run: |
cd ./ci
./verify-all-compiled.sh
pretext_conversion:
runs-on: ubuntu-latest

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

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Run prepare-for-pretext-conversion.sh
run: |
cd ./ci
./prepare-for-pretext-conversion.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: textbook-pretext
path: ci/book-pretext/pretext-output

pretext_build:
runs-on: ubuntu-latest
needs: pretext_conversion

# Run in the pretext docker container
container:
image: oscarlevin/pretext:small

steps:
- name: Echo pretext version
run: pretext support

# fetch the `textbook-pretext` artifact and unzip it
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: textbook-pretext
path: ci/book-pretext/pretext-output

# Build the book
- name: Build pretext book
run: |
cd ci/book-pretext/pretext-output
pretext build web
# List files in the output directory
- name: List files in output directory
run: ls -shR ci/book-pretext/pretext-output/output/web

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: textbook-pretext-output
path: ci/book-pretext/pretext-output/output/web

build_website:
runs-on: ubuntu-latest
# needs pretext_build and build jobs to finish
needs: [pretext_build, build]

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

- name: Download textbook PDFs
uses: actions/download-artifact@v4
with:
name: textbook
path: website/landing-page/assets/nightly-pdf

- name: Download pretext website
uses: actions/download-artifact@v4
with:
name: textbook-pretext-output
path: website/landing-page/assets/textbook

- name: Copy prebuilt files to website
run: |
mkdir -p website/landing-page/assets/pdf
cp ./dist/*.pdf ./website/landing-page/assets/pdf/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: website
path: website/landing-page

deploy_to_github_pages:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
needs: build_website

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: website
path: website

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: "./website"

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ ci/book*
*.xdv
*.log
*.out
*.xmpdata
*.fdb_latexmk
*.swo
*.swn
*.xmpi
draft
testing
html-conversion
newdocumentclass
*-bak
node_modules
slide-conversion
slide-conversion
book-pretext
ci/dist/
book/*pdf
tmp/
5 changes: 3 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Continuous Integration

This folder contains files related to continuous integration (CI) for automatically building
and rebuilding the textbook source when needed.
and rebuilding the textbook source when needed. Look in `.github/workflows/on-pull-request.yml` for
details about how the CI jobs run.

### Building a new version of the Docker image

Expand All @@ -27,4 +28,4 @@ docker push siefkenj/build-images:ibllinearalgebra

```bash
rsync -rl --include='*/' --include='*.tex' --include='*.sty' --include='*.png' --include='*.jpg' --include='*.svg' --include="*.cls" --include="images/*" --exclude='*' ../book/ ./book-copy/
```
```
41 changes: 41 additions & 0 deletions ci/prepare-for-pretext-conversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -e

# Define the repository details
REPO_OWNER="siefkenj"
REPO_NAME="IBLLinearAlgebra-pretext"
BRANCH_NAME="main"

# Create the directory and navigate into it
rm -rf book-pretext
mkdir -p book-pretext
cd book-pretext

# Download the repository zip
URL="https://github.com/$REPO_OWNER/$REPO_NAME/archive/refs/heads/$BRANCH_NAME.zip"
echo "Starting download of $URL"
curl -sS -LJO "$URL"
echo "Download complete."

# Extract the zip file
unzip -q $REPO_NAME-$BRANCH_NAME.zip

# Navigate into the extracted directory
cd $REPO_NAME-$BRANCH_NAME

# Run npm ci
npm ci

# Convert the textbook
npx vite-node src/convert-textbook.ts -i ../../../book/linearalgebra.tex

# File is now written to tmp.out.ptx
mkdir -p pretext-output/source

echo "Moving tmp.out.ptx to pretext-output/source/main.ptx"
mv tmp.out.ptx pretext-output/source/main.ptx

# Move the output to the root level
echo "Moving source files to book-pretext/pretext-output/"
mv pretext-output/ ..
Binary file added website/landing-page/assets/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 94e4b97

Please sign in to comment.