From 6aecbdccfb65443576f8858e1d5b3b4d115e7100 Mon Sep 17 00:00:00 2001 From: Lukas Burk Date: Mon, 30 Oct 2023 21:20:51 +0100 Subject: [PATCH] Update workflows --- .github/workflows/fix-figure-paths.yaml | 1 + .github/workflows/pr-slide-check.yaml | 103 ++++++++++++++++++ .../render-lecture-slide-status.yaml | 2 +- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-slide-check.yaml diff --git a/.github/workflows/fix-figure-paths.yaml b/.github/workflows/fix-figure-paths.yaml index 416189e0..1a02f125 100644 --- a/.github/workflows/fix-figure-paths.yaml +++ b/.github/workflows/fix-figure-paths.yaml @@ -5,6 +5,7 @@ on: workflow_dispatch: push: branches: [main, master] + paths: ['slides/**'] name: fix-figure-paths diff --git a/.github/workflows/pr-slide-check.yaml b/.github/workflows/pr-slide-check.yaml new file mode 100644 index 00000000..d37aa58f --- /dev/null +++ b/.github/workflows/pr-slide-check.yaml @@ -0,0 +1,103 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Source version of this workflow lives in https://github.com/slds-lmu/lecture_service +# Please only update by copying from there to avoid divergences +# - attempts slide compilation +# - compares compiled slides against slides-pdf/ +# - compiles a markdown tables and appends it to the pull request that triggered it. +# .. for only this particular lecture repo. +on: + workflow_dispatch: + pull_request: + paths: ['style/**', 'slides/**', 'latex-math/**'] + +name: pr-slide-check + +jobs: + pr-slide-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + pull-requests: write # Write to PRs + steps: + # Clone lecture checker repo in the current directory + # We need lecture repo to be a sub directory of this for reasons (can optimize this once stable + working) + - name: Checkout lecture service repo + uses: actions/checkout@v4 + with: + repository: slds-lmu/lecture_service + # Don't show progress bar, very verbose for large repos + show-progress: false + + # Most reliable way I've found to get the repo name and use it as a parameter for the checkout action + # see https://stackoverflow.com/a/75513916/409362 + # If the repo is named slds-lmu/lecture_i2ml, we only need the "lecture_i2ml" part. + - name: Save repository name to env var (without org) + id: repo-basename + run: | + echo "value=$(basename ${{ github.repository }})" >> $GITHUB_OUTPUT + shell: bash + + - name: Checkout this lecture repo + uses: actions/checkout@v4 + with: + # Clone lecture repo in subdirectory of the same name + path: ${{ steps.repo-basename.outputs.value }} + # translates to e.g.: path: "lecture_i2ml" + # No need for git history + # 0 indicates all history for all branches and tags, 1 is shallow (and default) + fetch-depth: 1 + + # Standard R/pandoc/latex setup steps + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + - uses: r-lib/actions/setup-tinytex@v2 + - run: tlmgr --version + # Caching the R library requires to save its path beforehand, could hard-code but meh + - name: Get R library dir for caching + id: r-cache + run: | + echo "dir=$(Rscript --quiet -e 'cat(.libPaths()[[1]])')" >> $GITHUB_OUTPUT + - name: Restore R package cache + uses: actions/cache@v3 + with: + path: ${{ steps.r-cache.outputs.dir }} + key: ${{ runner.os }}-r-${{inputs.cache-version }}-${{ hashFiles('scripts/install_r_deps.R') }} + restore-keys: ${{ runner.os }}-r-${{inputs.cache-version }}- + + # Setting up the lecture checking requirements: + # 1) R packages + - name: Install R packages + run: make install-r + # 2) latex dependencies, incl output list of installed pkgs (optional) + - name: Install additional LaTeX packages + run: | + make install-tex + tlmgr list --only-installed + # 3) Installing diff-pdf and diff-pdf-visually (only automated for ubuntu so far) + - name: Install diff-pdf and diff-pdf-visually + run: make install-tools-ubuntu + + - name: Install the service package + run: make install-service + + # Uncomment / move to get a tmux ssh session for interactive debugging + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + + # Run the main thing: compiles slides, checks against slides-pdf/* + - name: Check slides and build markdown table + run: make table + + # Take the markdown document with the tables rendered in the previous step + # and add it as a comment to the PR that triggered this action. + # The comment_tag is there such that the comment can be updated after + # a potential re-run of the action. + # https://github.com/thollander/actions-comment-pull-request + - name: PR comment with file + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: slide_status_pr.md + comment_tag: slide_check diff --git a/.github/workflows/render-lecture-slide-status.yaml b/.github/workflows/render-lecture-slide-status.yaml index 1ee5b62b..22757c1f 100644 --- a/.github/workflows/render-lecture-slide-status.yaml +++ b/.github/workflows/render-lecture-slide-status.yaml @@ -12,7 +12,7 @@ on: # Probably makes most sense to only run this workflow when slides change # Also added the workflow itself to trigger a run if it changes # Comment out to run on every commit - paths: ['style/**', 'slides/**', 'slides-pdf/*.pdf', '.github/workflows/render-lecture-slide-status.yaml'] + paths: ['style/**', 'slides/**', 'slides-pdf/*.pdf', 'latex-math/**', '.github/workflows/render-lecture-slide-status.yaml'] name: render-lecture-slide-status