Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run in a container #145

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions .github/dependabot.yml

This file was deleted.

89 changes: 59 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,43 @@ permissions:
env:
TIMEOUT: '-1' # nbconvert timeout
EXTRA_ARGS: '' # Extra arguments for nbconvert
IMAGE: 'app:test'
PYTHON_VER: '3.11'

jobs:
setup:
container:
image: julia:1.9.3
env:
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and cache Docker container
uses: docker/build-push-action@v5
- name: Setup Python
uses: actions/setup-python@v4
with:
context: .
file: '.github/Dockerfile'
tags: ${{ env.IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max
python-version: ${{ env.PYTHON_VER }}
- name: Cache Julia deps
uses: actions/cache@v3
with:
path: |
~/.julia/artifacts
~/.julia/compiled
~/.julia/packages
key: ${{ runner.os }}-juliacontainer-${{ hashFiles('Manifest.toml')}}
restore-keys: |
${{ runner.os }}-juliacontainer-
- name: Install Julia packages
env:
PYTHON: ${{ env.pythonLocation }}/python
JULIA_PYTHONCALL_EXE: ${{ env.pythonLocation }}/python
run: |
julia --project="" --color=yes -e 'using Pkg; Pkg.add(["IJulia"])'
julia --project=@. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile(); Pkg.gc()'
- name: List notebooks as a JSON array
id: set-matrix
working-directory: docs
Expand All @@ -51,6 +68,12 @@ jobs:
# Notebooks need to be executed
notebook: ${{ fromJSON(needs.setup.outputs.matrix) }}
runs-on: ubuntu-latest
container:
image: julia:1.9.3
env:
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -63,35 +86,41 @@ jobs:
with:
path: ${{ steps.file.outputs.name }}
key: ${{ runner.os }}-notebook-${{ hashFiles(steps.file.outputs.name, 'requirements.txt', 'Project.toml', 'Manifest.toml', 'src/**', '.github/Dockerfile') }}
- name: Set up Docker Buildx
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: docker/setup-buildx-action@v3
- name: Restore Docker container
- name: Setup Python
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: docker/build-push-action@v5
uses: actions/setup-python@v4
with:
context: .
file: '.github/Dockerfile'
tags: ${{ env.IMAGE }}
cache-from: type=gha
load: true
- name: Get Julia version
python-version: ${{ env.PYTHON_VER }}
- name: Install Python deps
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
id: julia
run: echo "ver=$(docker run ${{ env.IMAGE }} julia -e 'print(VERSION.minor)')" >> "$GITHUB_OUTPUT"
- name: Julia precompile
run: |
python -m pip install --no-cache-dir nbconvert
python -m pip install --no-cache-dir -r requirements.txt
- name: Cache Julia deps
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: docker run -w /tmp -v ${{ github.workspace }}:/tmp ${{ env.IMAGE }} julia --project=@. --color=yes -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
- name: Install IJulia kernel
uses: actions/cache@v3
with:
path: |
~/.julia/artifacts
~/.julia/compiled
~/.julia/packages
key: ${{ runner.os }}-juliacontainer-${{ hashFiles('Manifest.toml')}}
restore-keys: |
${{ runner.os }}-juliacontainer-
- name: Install Julia packages
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: docker run -w /tmp -v ${{ github.workspace }}:/tmp ${{ env.IMAGE }} julia --project="" --color=yes -e 'import IJulia; IJulia.installkernel("Julia", "--project=@.")'
env:
PYTHON: ${{ env.pythonLocation }}/python
JULIA_PYTHONCALL_EXE: ${{ env.pythonLocation }}/python
run: |
julia --project="" --color=yes -e 'using Pkg; Pkg.add(["IJulia"]); import IJulia; IJulia.installkernel("Julia", "--project=@.")'
julia --project=@. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile(); Pkg.gc()'
- name: Execute Notebook
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: >
docker run -w /tmp -v ${{ github.workspace }}:/tmp ${{ env.IMAGE }}
jupyter nbconvert --to notebook --execute --inplace ${{ env.EXTRA_ARGS }}
--ExecutePreprocessor.timeout=${{ env.TIMEOUT }}
--ExecutePreprocessor.kernel_name=julia-1.${{ steps.julia.outputs.ver }}
--ExecutePreprocessor.kernel_name=julia-1.$(julia -e 'print(VERSION.minor)')
docs/${{ matrix.notebook }}
- name: Cache notebook
uses: actions/cache/save@v3
Expand Down Expand Up @@ -131,7 +160,7 @@ jobs:
environment-file: jupyterbook.yml
init-shell: bash
cache-environment: true
post-cleanup: 'all'
post-cleanup: all
- name: Build website
shell: micromamba-shell {0}
run: jupyter-book build docs/
Expand Down
39 changes: 22 additions & 17 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,53 @@ on:
branches:
- main
paths:
- .github/Dockerfile
- .github/workflows/update-manifest.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DFILE: '.github/Dockerfile'
IMAGE_NAME: 'app:test'
PYTHON_VER: '3.11'
APP_ID: '189113' # https://github.com/apps/wen-wei-s-pr-bot

jobs:
update-manifest:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
container:
image: julia:1.9.3
env:
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
JULIA_PKG_PRECOMPILE_AUTO: '0'
JULIA_PROJECT: '@.'
steps:
- name: Install Git
run: apt update && apt install -y git
- name: Set safe directory
run: git config --global --add safe.directory '*'
- name: Checkout
uses: actions/checkout@v4
- name: Build and cache Docker container
uses: docker/build-push-action@v5
- name: Setup Python
uses: actions/setup-python@v4
with:
target: base
context: .
file: ${{ env.DFILE }}
tags: ${{ env.IMAGE_NAME }}
load: true
python-version: ${{ env.PYTHON_VER }}
- name: Update Julia dependencies
run: >
docker run
--workdir=/tmp -v ${{ github.workspace }}:/tmp
-e JULIA_PKG_PRECOMPILE_AUTO=0
${{ env.IMAGE_NAME }}
julia --color=yes --project=@. -e "import Pkg; Pkg.update()"
env:
PYTHON: ${{ env.pythonLocation }}/python
JULIA_PYTHONCALL_EXE: ${{ env.pythonLocation }}/python
run: julia --color=yes --project=@. -e "import Pkg; Pkg.update()"
# Authenticate with a custom GitHub APP
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens
- name: Generate token for PR
uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.APP_ID }} # https://github.com/apps/wen-wei-s-pr-bot
app_id: ${{ env.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create Pull Request
id: cpr
Expand Down
9 changes: 9 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"config:recommended",
":automergeMajor"
],
"git-submodules": {
"enabled": true
}
}