self-hosted (#94) #386
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| JULIA_CI: 'true' | |
| JULIA_CONDAPKG_BACKEND: 'Null' | |
| JULIA_CONDAPKG_OFFLINE: 'true' | |
| # JULIA_CPU_TARGET: 'generic;icelake-server,clone_all;znver3,clone_all' | |
| JULIA_NUM_THREADS: '2' | |
| NBCACHE: '.cache' | |
| LITERATE_PROC: '6' | |
| PY_VER: '3.14' | |
| jobs: | |
| CI: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| id: setup-python | |
| with: | |
| python-version: ${{ env.PY_VER }} | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install Python dependencies | |
| run: uv pip install --system -r requirements.txt | |
| - name: Read Julia version | |
| id: julia-version | |
| run: python -c 'import tomllib; from pathlib import Path; print("value=", tomllib.loads(Path("Manifest.toml").read_text())["julia_version"], sep="")' >> "$GITHUB_OUTPUT" | |
| - name: Get hashes | |
| id: hash | |
| run: | | |
| echo "value=${{ hashFiles('Project.toml', 'Manifest.toml', 'src/**') }}" >> "$GITHUB_OUTPUT" | |
| echo "nb=${{ hashFiles('docs/**/*.jl', 'docs/**/*.ipynb') }}" >> "$GITHUB_OUTPUT" | |
| - name: Cache executed notebooks | |
| uses: actions/cache@v5 | |
| id: cache-nb | |
| with: | |
| path: | | |
| ${{ env.NBCACHE }}/**/*.ipynb | |
| ${{ env.NBCACHE }}/**/*.sha | |
| key: notebook-${{ steps.hash.outputs.value }}-${{ steps.hash.outputs.nb }} | |
| restore-keys: | | |
| notebook-${{ steps.hash.outputs.value }}- | |
| - name: Setup Julia | |
| uses: julia-actions/setup-julia@v2 | |
| if: ${{ steps.cache-nb.outputs.cache-hit != 'true' }} | |
| with: | |
| version: ${{ steps.julia-version.outputs.value }} | |
| arch: ${{ runner.arch }} | |
| - name: Restore Julia packages | |
| uses: actions/cache/restore@v5 | |
| if: ${{ steps.cache-nb.outputs.cache-hit != 'true' && runner.environment == 'github-hosted'}} | |
| id: cache-julia | |
| with: | |
| path: ~/.julia | |
| key: ${{ runner.os }}-julia-${{ steps.julia-version.outputs.value }}-${{ steps.hash.outputs.value }} | |
| restore-keys: | | |
| ${{ runner.os }}-julia-${{ steps.julia-version.outputs.value }} | |
| - name: Install Julia packages | |
| if: ${{ steps.cache-nb.outputs.cache-hit != 'true' && (runner.environment == 'self-hosted' || steps.cache-julia.outputs.cache-hit != 'true') }} | |
| shell: julia --color=yes --project=@. {0} | |
| run: | | |
| using Pkg, Dates | |
| Pkg.instantiate() | |
| Pkg.precompile() | |
| if ENV["RUNNER_ENVIRONMENT"] == "github-hosted" | |
| Pkg.gc(;collect_delay=Day(0)) | |
| end | |
| - name: Save Julia packages | |
| uses: actions/cache/save@v5 | |
| if: ${{ steps.cache-nb.outputs.cache-hit != 'true' && runner.environment == 'github-hosted' && steps.cache-julia.outputs.cache-hit != 'true' }} | |
| with: | |
| path: ~/.julia | |
| key: ${{ steps.cache-julia.outputs.cache-primary-key }} | |
| - name: Run notebooks | |
| if: ${{ steps.cache-nb.outputs.cache-hit != 'true' }} | |
| run: julia --project=@. --color=yes -p ${{ env.LITERATE_PROC }} .github/ci.jl | |
| - name: Copy back built notebooks | |
| run: cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/ | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 'lts/*' | |
| - name: Build website | |
| env: | |
| BASE_URL: /${{ github.event.repository.name }} | |
| run: | | |
| npm install -g "jupyter-book" | |
| jupyter-book build --html --strict | |
| - name: Upload pages artifact | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: './_build/html' | |
| # Deployment job | |
| deploy: | |
| name: Deploy to GitHub pages and Notebook branch | |
| needs: CI | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| # Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
| permissions: | |
| pages: write # to deploy to Pages | |
| id-token: write # to verify the deployment originates from an appropriate source | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |