Skip to content

Commit

Permalink
Adopt Check and Make Workflow from hpmor-de (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
entorb authored Feb 5, 2025
1 parent ca1e9fa commit 75e3690
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 60 deletions.
103 changes: 82 additions & 21 deletions .github/workflows/make.yml → .github/workflows/check-and-make.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
# This workflow builds PDFs and eBooks upon push of new commits.
# Generated assets are uploaded to release WorkInProgress.
# This workflow performs
# check: Quality checks on chapter text and code upon new commits and PRs.
# make: Makes PDFs and eBooks if .tex files have changed.
# upload: Uploads the artifacts to release WorkInProgress, but only for push into main branch.

name: Build HPMOR PDFs and eBooks
name: Check and Make

# This workflow runs upon
# - manual triggering
# - create new PR (check, make)
# - push to main (check, make, upload)

on:
workflow_dispatch: # manual triggering
workflow_dispatch:
pull_request:
branches: ["main"]
push:
branches: [main]
branches: ["main"]

jobs:
build:
check:
runs-on: ubuntu-24.04
outputs:
cache-hit: ${{ steps.cache-lookup.outputs.cache-hit }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1 # 0 if you want to push to repo

- name: Calculate hash on chapters/*.tex
id: calculate-hash
run: |
echo "hash=${{ hashFiles('chapters/*.tex') }}" >> $GITHUB_OUTPUT
touch hash-chapters.txt
- name: Cache lookup
id: cache-lookup
uses: actions/cache@v4
with:
path: hash-chapters.txt
key: chapter-hash-for-ebook-${{ github.ref_name }}-${{ steps.calculate-hash.outputs.hash }}

- name: Preparations
run: ln -s python-requirements.txt requirements.txt

- name: Python set up
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Check chapters for known issues
run: python3 -O scripts/check_chapters.py

- name: Check pre-commit tests
uses: pre-commit/action@v3.0.1

make:
needs: check
# do not run for unchanged tex files
if: needs.check.outputs.cache-hit != 'true'

runs-on: ubuntu-24.04

steps:
Expand Down Expand Up @@ -42,26 +95,16 @@ jobs:
python-version: "3.12"
cache: "pip"

# - name: test ls before
# run: |
# pwd
# ls -al

- name: Check chapters for known issues
run: python3 scripts/check_chapters.py

- name: Check pre-commit tests
uses: pre-commit/action@v3.0.1

- name: Install requirements
- name: Install requirements (apt and python)
run: sh scripts/install_requirements.sh > /dev/null

- name: Print versions
run: |
cat /etc/os-release
xelatex -v
latexmk -v
pandoc -v
calibre --version
pandoc --version
ebook-convert --version
python3 --version
Expand All @@ -80,7 +123,7 @@ jobs:
diff -u -s hpmor-prev.html hpmor.html > hpmor-html-diff.log || :
rm hpmor-prev.html
- name: Test ls after
- name: ls after
run: |
pwd
ls -al
Expand All @@ -92,11 +135,29 @@ jobs:
path: |
./hpmor-html-diff.log
./hpmor.epub
./hpmor.fb2
./hpmor.html
./hpmor.mobi
./hpmor.pdf
retention-days: 14

- name: Upload files to release WorkInProgress
#
# upload to release WorkInProgress
#
upload:
needs: make
# only for push into main branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

runs-on: ubuntu-24.04

steps:
- name: Download eBooks artifact
uses: actions/download-artifact@v4
with:
name: ebooks

- name: Publish eBooks to release WorkInProgress
uses: softprops/action-gh-release@v2
with:
tag_name: WorkInProgress
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/check-pr.yml

This file was deleted.

0 comments on commit 75e3690

Please sign in to comment.