Skip to content

Commit

Permalink
Make GH Actions less reliant on TL mirror availability
Browse files Browse the repository at this point in the history
  • Loading branch information
zauguin committed Feb 28, 2023
1 parent e8149d2 commit 2fc2a43
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/main.yaml
Expand Up @@ -13,6 +13,23 @@ on:
# requests get tested even if their branch comes from a fork.

jobs:
# Update the TeX Live tree if necessary
texlive-cache:
runs-on: ubuntu-20.04
name: Update TeX Live
outputs:
cache_key: ${{ steps.texlive.outputs.cache_key }}
steps:
# Boilerplate
- name: Checkout repository
uses: actions/checkout@v3
- name: Install TeX Live
id: texlive
uses: zauguin/install-texlive@v3
with:
# List the required TeX Live packages in a separate file to allow reuse in
# different workflows.
package_file: .github/tl_packages
# The l3build job contains the actual work. We misuse the matrix mechanism to
# create three jobs which only differ in minimal elements.
# For tags we do not run this since we run the release job instead.
Expand Down Expand Up @@ -72,18 +89,20 @@ jobs:
l3build_cmd: cd required && l3build doc -q -H --show-log-on-error
artifact_name: Documentation
name: ${{ matrix.name }}
needs: texlive-cache
steps:
# Boilerplate
- name: Checkout repository
uses: actions/checkout@v3
# We need Ghostscript for dvips and XeTeX tests.
- run: sudo apt-get update && sudo apt-get install ghostscript
- name: Install TeX Live
uses: zauguin/install-texlive@v2
- name: Restore TeX Live from cache
uses: actions/cache/restore@v3
with:
# List the required TeX Live packages in a separate file to allow reuse in
# different workflows.
package_file: .github/tl_packages
path: ~/texlive
key: ${{ needs.texlive-cache.outputs.cache_key }}
fail-on-cache-miss: true
- run: echo $HOME/texlive/bin/x86_64-linux >> $GITHUB_PATH
- name: Run l3build
run: ${{ matrix.l3build_cmd }}
# Now we create the artifacts: There are two cases where this happens.
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/trigger.yaml
@@ -0,0 +1,55 @@
name: Manually refresh caches

on:
workflow_dispatch:
inputs:
repository:
default: ctan
description: 'Repository URL'
required: false
type: string
delete-old:
default: false
description: 'Delete all caches'
required: false
type: boolean

jobs:
rebuild-cache:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Clean old caches
run: |
gh extension install actions/gh-actions-cache
REPO="${{ github.repository }}"
BRANCH="${{ github.ref }}"
HASH_KEY="texlive-0-${{ hashFiles(".github/tl_packages") }}-"
DATE="$(date -I)"
if ${{ inputs.delete-old }}
then
HASH_KEY="$HASH_KEY-$DATE"
fi
set +e
gh actions-cache list -R "$REPO" -B "$BRANCH" --key "$HASH_KEY" | cut -f 1 | while read -r cacheKey
do
gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install TeX Live
id: texlive
uses: zauguin/install-texlive@v3
with:
# List the required TeX Live packages in a separate file to allow reuse in
# different workflows.
accept-stale: false
repository: ${{ inputs.repository }}
package_file: .github/tl_packages

0 comments on commit 2fc2a43

Please sign in to comment.