Skip to content

Commit

Permalink
py venv
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Mar 27, 2024
1 parent 60ecb24 commit f4cb152
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
JULIA_CONDAPKG_BACKEND: 'Null'
JULIA_CI: 'true'
NBCACHE: '.cache'
VENV: '.venv'

jobs:
CI:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
linkcheck:
env:
DIR: 'docs'
VENV: '.venv'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -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)
Expand All @@ -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

0 comments on commit f4cb152

Please sign in to comment.