Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Oct 26, 2023
1 parent 4e9435c commit bbdb1ef
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 111 deletions.
23 changes: 0 additions & 23 deletions .github/dependabot.yml

This file was deleted.

132 changes: 85 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,76 @@ concurrency:

env:
NPROC: '2' # Number of Julia processes to run the notebooks
PYTHON_VER: '3.11'

jobs:
CI:
execute:
runs-on: ubuntu-latest
permissions:
packages: write
container:
image: julia:1.9.3
env:
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: auto
JULIA_CONDAPKG_BACKEND: 'Null'
JULIA_CI: 'true'
GKSwstype: '100' # Null GR backend for Plots.jl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VER }}
- name: Install Python deps
run: python -m pip install --no-cache-dir -r requirements.txt
- name: Cache Julia deps
uses: actions/cache@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Get docker image hash
id: hash
run: echo "id=${{ hashFiles('requirements.txt', 'Project.toml', 'Manifest.toml', 'src/**', 'env.Dockerfile') }}" >> "$GITHUB_OUTPUT"
- name: Set image name
run: echo "IMG=ghcr.io/${{ github.repository }}:${{ steps.hash.outputs.id }}" >> "$GITHUB_ENV"
- name: Build and load Docker container
uses: docker/build-push-action@v5
path: |
~/.julia/artifacts
~/.julia/compiled
~/.julia/packages
~/.julia/environments
key: ${{ runner.os }}-juliacontainer-${{ hashFiles('src/**','Project.toml', 'Manifest.toml')}}
restore-keys: |
${{ runner.os }}-juliacontainer-
- name: Install Julia deps
env:
PYTHON: ${{ env.pythonLocation }}/python
JULIA_PYTHONCALL_EXE: ${{ env.pythonLocation }}/python
run: |
julia --color=yes -e 'using Pkg; Pkg.add(["PrettyTables", "Literate"])'
julia --project=@. --color=yes -e 'using Pkg; Pkg.activate("."); Pkg.instantiate(); Pkg.gc()'
- name: Run program
env:
JULIA_PROJECT: '@.'
run: julia --color=yes -p ${{ env.NPROC }} literate.jl
- name: Upload Results
uses: actions/upload-artifact@v3
with:
context: .
file: 'env.Dockerfile'
tags: ${{ env.IMG }}
load: true
cache-from: type=registry,ref=${{ env.IMG }}
- name: Push Docker container
uses: docker/build-push-action@v5
name: notebooks
path: docs/
retention-days: 1

render:
needs: execute
runs-on: ubuntu-latest
# store success output flag for the ci job
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download notebooks
uses: actions/download-artifact@v3
with:
context: .
file: 'env.Dockerfile'
tags: ${{ env.IMG }}
push: true
cache-from: type=registry,ref=${{ env.IMG }}
cache-to: type=inline
- name: Build notebooks with ${{ env.NPROC }} processes
run: >
docker run --rm -e JULIA_PROJECT=@. -w /tmp -v ${{ github.workspace }}:/tmp
${{ env.IMG }}
julia --color=yes -p ${{ env.NPROC }} literate.jl
- name: Retake ownership
run: sudo chown -R $USER docs/
name: notebooks
path: out/
- name: Display structure of downloaded files
run: ls -R
working-directory: out
- name: Copy back built notebooks
run: cp --verbose -rf out/* docs/
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
Expand All @@ -69,24 +93,38 @@ jobs:
- name: Build website
shell: micromamba-shell {0}
run: jupyter-book build docs/
- name: Push Docker container
uses: docker/build-push-action@v5
with:
context: .
file: 'env.Dockerfile'
tags: ${{ env.IMG }}
push: true
cache-from: type=registry,ref=${{ env.IMG }}
cache-to: type=inline
- name: Upload pages artifact
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-pages-artifact@v2
with:
path: docs/_build/html
- name: Set output flag
id: setoutput
run: echo "success=true" >> $GITHUB_OUTPUT

# CI conclusion for GitHub status check
# https://brunoscheufler.com/blog/2022-04-09-the-required-github-status-check-that-wasnt
CI:
needs: render
if: always()
runs-on: ubuntu-latest
steps:
# pass step only when output of previous jupyter-book job is set
# in case at least one of the execution fails, jupyter-book is skipped
# and the output will not be set, which will then cause the ci job to fail
- run: |
passed="${{ needs.render.outputs.success }}"
if [[ $passed == "true" ]]; then
echo "Tests passed"
exit 0
else
echo "Tests failed"
exit 1
fi
deploy:
name: Deploy to GitHub pages
needs: CI
needs: render
if: ${{ github.ref == 'refs/heads/main'}}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Julia
uses: julia-actions/setup-julia@v1
- name: Convert literate notebooks to Markdown
- name: Convert literate notebooks to markdown files
shell: julia --color=yes {0}
working-directory: ${{ env.DIR }}
run: |
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ concurrency:

env:
APP_ID: '189113' # https://github.com/apps/wen-wei-s-pr-bot
IMG_NAME: 'app:test'

jobs:
update-manifest:
Expand All @@ -27,20 +26,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and load docker image
uses: docker/build-push-action@v5
with:
context: .
file: 'env.Dockerfile'
tags: ${{ env.IMG_NAME }}
load: true
target: base
- name: Setup Julia
uses: julia-actions/setup-julia@v1
- name: Update Julia dependencies
run: >
docker run --rm -e JULIA_PKG_PRECOMPILE_AUTO=0
-w /tmp -v ${{ github.workspace }}:/tmp
${{ env.IMG_NAME }}
julia --color=yes --project=@. -e 'import Pkg; Pkg.update()'
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
Expand Down
26 changes: 0 additions & 26 deletions env.Dockerfile

This file was deleted.

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
}
}

0 comments on commit bbdb1ef

Please sign in to comment.