diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fda7450..732353c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ env: JULIA_CONDAPKG_BACKEND: 'Null' JULIA_CI: 'true' NBCACHE: '.cache' + VENV: '.venv' jobs: CI: @@ -28,19 +29,25 @@ jobs: uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 - id: cp + id: setup-python with: python-version: '3.x' - - name: Cache pip dependencies + - name: Cache virtualenv uses: actions/cache@v4 - id: cache-py - if: ${{ contains(runner.name, 'GitHub Actions') }} + id: cache-venv with: - path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-pip-${{ steps.cp.outputs.python-version }}-${{ hashFiles('requirements.txt') }} - - name: Install pip dependencies if cache miss - if: ${{ steps.cache-py.outputs.cache-hit != 'true' }} - run: pip install -r requirements.txt + key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }} + path: ${{ env.VENV }} + - name: Install Python dependencies + if: ${{ steps.cache-venv.outputs.cache-hit != 'true' }} + run: | + python -m venv ${{ env.VENV }} + source ${{ env.VENV }}/bin/activate + python -m pip install -r requirements.txt + - name: Add venv to PATH + run: | + echo "${{ env.VENV }}/bin" >> $GITHUB_PATH + echo "VIRTUAL_ENV=${{ env.VENV }}" >> $GITHUB_ENV - name: Cache executed notebooks uses: actions/cache@v4 id: cache-nb @@ -70,7 +77,7 @@ jobs: - name: Install Julia packages if: ${{ !contains(runner.name, 'GitHub Actions') || steps.cache-julia.outputs.cache-hit != 'true' }} env: - PYTHON: ${{ env.pythonLocation }}/python + PYTHON: ${{ steps.setup-python.outputs.python-path }} run: julia --color=yes instantiate.jl - name: Save Julia packages uses: actions/cache/save@v4 diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index d1a315e..f23dcb5 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -19,6 +19,7 @@ jobs: linkcheck: env: DIR: 'docs' + VENV: '.venv' runs-on: ubuntu-latest steps: - name: Checkout @@ -27,11 +28,12 @@ jobs: uses: julia-actions/setup-julia@v1 - name: Convert literate notebooks to ipynb files shell: julia --color=yes {0} + working-directory: ${{ env.DIR }} run: | import Pkg Pkg.add("Literate") using Literate - for (root, dirs, files) in walkdir("docs") + for (root, dirs, files) in walkdir(pwd()) for file in files if endswith(file, ".jl") nb = joinpath(root, file) @@ -41,18 +43,24 @@ jobs: end - name: Setup Python uses: actions/setup-python@v5 - id: cp + id: setup-python with: python-version: '3.x' - - name: Cache pip dependencies + - name: Cache virtualenv uses: actions/cache@v4 - id: cache-py + id: cache-venv with: - save-always: 'true' - path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-pip-${{ steps.cp.outputs.python-version }}-${{ hashFiles('requirements.txt') }} - - name: Install pip dependencies if cache miss - if: ${{ steps.cache-py.outputs.cache-hit != 'true' }} - run: pip install -r requirements.txt + key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }} + path: ${{ env.VENV }} + - name: Install Python dependencies + if: ${{ steps.cache-venv.outputs.cache-hit != 'true' }} + run: | + python -m venv ${{ env.VENV }} + source ${{ env.VENV }}/bin/activate + python -m pip install -r requirements.txt + - name: Add venv to PATH + run: | + echo "${{ env.VENV }}/bin" >> $GITHUB_PATH + echo "VIRTUAL_ENV=${{ env.VENV }}" >> $GITHUB_ENV - name: Build website run: jupyter-book build ${DIR} --builder linkcheck