Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Dec 14, 2023
1 parent 2bf60a2 commit 4728760
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 57 deletions.
3 changes: 0 additions & 3 deletions .dockerignore

This file was deleted.

7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ updates:
interval: daily
labels:
- automerge
- package-ecosystem: pip
directory: "/"
open-pull-requests-limit: 1
schedule:
interval: daily
labels:
- automerge
35 changes: 21 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ concurrency:
cancel-in-progress: true

env:
NPROC: '2' # Number of Julia processes to run the notebooks
NPROC: '3' # Number of Julia processes to run the notebooks
PY_VER: '3.12'
CACHE_NUM: '1'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
Expand All @@ -24,12 +25,20 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
- name: Setup Python
uses: actions/setup-python@v5
id: cp
with:
environment-file: environment.yml
cache-environment: true
post-cleanup: all
python-version: ${{ env.PY_VER }}
- name: Cache pip
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ steps.cp.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
- name: Install python packages
if: ${{ steps.cache-pip.outputs.cache-hit != 'true' }}
run: pip install -r requirements.txt
- name: Read Julia version
uses: SebRollen/[email protected]
id: read_toml
Expand All @@ -41,9 +50,9 @@ jobs:
wget -O /tmp/jill.sh https://raw.githubusercontent.com/abelsiqueira/jill/main/jill.sh
bash /tmp/jill.sh --version ${{ steps.read_toml.outputs.value }} -y
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Restore Julia packages
- name: Cache Julia packages
uses: actions/cache/restore@v3
id: cache
id: cache-julia
with:
path: |
~/.julia
Expand All @@ -52,26 +61,24 @@ jobs:
restore-keys: |
${{ runner.os }}-julia-${{ env.CACHE_NUM }}-
- name: Install Julia packages
shell: micromamba-shell {0}
if: ${{ steps.cache-julia.outputs.cache-hit != 'true' }}
run: |
julia --color=yes -e 'using Pkg; Pkg.add(["PrettyTables", "Literate"])'
julia --project=@. --color=yes -e 'using Pkg, Dates; Pkg.instantiate(); Pkg.gc(collect_delay=Day(1))'
julia --project=@. --color=yes -e 'using Pkg, Dates; Pkg.instantiate(); Pkg.resolve(); Pkg.precompile(); Pkg.gc(collect_delay=Day(0))'
- name: Save Julia packages
uses: actions/cache/save@v3
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
if: ${{ steps.cache-julia.outputs.cache-hit != 'true' }}
with:
path: |
~/.julia
!~/.julia/registries
key: ${{ steps.cache.outputs.cache-primary-key }}
key: ${{ steps.cache-julia.outputs.cache-primary-key }}
- name: Run program
shell: micromamba-shell {0}
env:
JULIA_PROJECT: '@.'
GKSwstype: '100'
run: julia --color=yes -p ${{ env.NPROC }} literate.jl
- name: Build website
shell: micromamba-shell {0}
run: jupyter-book build docs/
- name: Upload pages artifact
if: ${{ github.ref == 'refs/heads/main' }}
Expand Down
41 changes: 19 additions & 22 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@ on:

env:
DIR: 'docs'
PY_VER: '3.12'

jobs:
linkcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
id: cp
with:
python-version: ${{ env.PY_VER }}
- name: Cache pip
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ steps.cp.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
- name: Install python packages
if: ${{ steps.cache-pip.outputs.cache-hit != 'true' }}
run: pip install -r requirements.txt
- name: Setup Julia
uses: julia-actions/setup-julia@v1
- name: Convert literate notebooks to markdown files
Expand All @@ -33,28 +48,10 @@ jobs:
for (root, dirs, files) in walkdir(pwd())
for file in files
if endswith(file, ".jl")
Literate.markdown(joinpath(root, file); mdstrings=true, flavor = Literate.CommonMarkFlavor())
nb = joinpath(root, file)
Literate.notebook(nb, dirname(nb); mdstrings=true, execute=false)
end
end
end
- name: Restore lychee cache
id: restore-cache
uses: actions/cache/restore@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Lychee Checker
uses: lycheeverse/[email protected]
id: lychee
with:
fail: true
args: '--accept 200,204,429 --verbose --no-progress --cache --max-cache-age 1d ${{ env.DIR }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save lychee cache
uses: actions/cache/save@v3
if: always()
with:
path: .lycheecache
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: Check links
run: jupyter-book build ${DIR} --builder linkcheck
2 changes: 2 additions & 0 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
uses: actions/checkout@v4
- name: Setup Julia
uses: julia-actions/setup-julia@v1
with:
version: '1'
- name: Update Julia dependencies
env:
JULIA_PKG_PRECOMPILE_AUTO: '0'
Expand Down
10 changes: 0 additions & 10 deletions environment.yml

This file was deleted.

12 changes: 4 additions & 8 deletions literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using PrettyTables
end

basedir = "docs"
config = Dict("mdstrings" => true, "execute" => true, "flavor" => Literate.CommonMarkFlavor())
config = Dict("mdstrings" => true, "execute" => true)

nbs = String[]

Expand All @@ -21,9 +21,7 @@ end

# Execute the notebooks in worker processes
ts = pmap(nbs; on_error=ex->NaN) do nb
cd(dirname(nb)) do
@elapsed Literate.markdown(basename(nb); config)
end
@elapsed Literate.notebook(nb, dirname(nb); config)
end

pretty_table([nbs ts], header=["Notebook", "Elapsed (s)"])
Expand All @@ -34,12 +32,10 @@ for (nb, t) in zip(nbs, ts)
println("Debugging notebook: ", nb)
try
withenv("JULIA_DEBUG" => "Literate") do
cd(dirname(nb)) do
Literate.markdown(basename(nb); config)
end
Literate.notebook(nb, dirname(nb); config)
end
catch e
println("An error occured: ", e)
println(e)
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# matplotlib==3.8.2
jupyter-book==0.15.1
docutils!=0.18.*,!=0.19.*

0 comments on commit 4728760

Please sign in to comment.