|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Checks the build scripts, builds the site, and verifies every link in it. |
| 4 | +# The weekly run catches external links that have rotted since the last change. |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [master] |
| 8 | + pull_request: |
| 9 | + workflow_dispatch: |
| 10 | + schedule: |
| 11 | + - cron: "41 4 * * 1" |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + UPSTREAM: https://github.com/lambda-discipline/lambda-discipline |
| 22 | + UPSTREAM_BRANCH: master |
| 23 | + |
| 24 | +jobs: |
| 25 | + lint: |
| 26 | + name: Format, lint and types |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: "3.13" |
| 33 | + cache: pip |
| 34 | + cache-dependency-path: requirements*.txt |
| 35 | + - run: pip install -r requirements-dev.txt |
| 36 | + # black, ruff, mypy and the file hygiene hooks, as configured in |
| 37 | + # .pre-commit-config.yaml. |
| 38 | + - run: pre-commit run --all-files --show-diff-on-failure --color always |
| 39 | + |
| 40 | + build: |
| 41 | + name: Build and check links |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Clone the language repository |
| 47 | + run: git clone --depth 1 --branch "$UPSTREAM_BRANCH" "$UPSTREAM" .cache/lambda-discipline |
| 48 | + |
| 49 | + - name: Install Rust |
| 50 | + # Installs the version the language repository's rust-toolchain.toml asks for. |
| 51 | + working-directory: .cache/lambda-discipline |
| 52 | + run: rustup toolchain install |
| 53 | + |
| 54 | + - uses: Swatinem/rust-cache@v2 |
| 55 | + with: |
| 56 | + workspaces: .cache/lambda-discipline |
| 57 | + |
| 58 | + - uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.13" |
| 61 | + cache: pip |
| 62 | + cache-dependency-path: requirements*.txt |
| 63 | + |
| 64 | + - run: pip install -r requirements.txt |
| 65 | + |
| 66 | + - name: Build the site |
| 67 | + run: python build.py --no-update |
| 68 | + |
| 69 | + - uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: site |
| 72 | + path: _site |
| 73 | + include-hidden-files: true |
| 74 | + |
| 75 | + - name: Restore the link checker's cache |
| 76 | + uses: actions/cache@v4 |
| 77 | + with: |
| 78 | + path: .lycheecache |
| 79 | + key: lychee-${{ github.sha }} |
| 80 | + restore-keys: lychee- |
| 81 | + |
| 82 | + - name: Check links |
| 83 | + # Settings are in lychee.toml. --root-dir resolves links such as |
| 84 | + # /reference/ against the built site instead of the live one. |
| 85 | + uses: lycheeverse/lychee-action@v2 |
| 86 | + with: |
| 87 | + lycheeVersion: v0.24.2 |
| 88 | + args: --root-dir "${{ github.workspace }}/_site" _site |
| 89 | + fail: true |
| 90 | + jobSummary: true |
| 91 | + env: |
| 92 | + # Authenticated requests avoid GitHub's rate limit for links to it. |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments