Skip to content

Commit

Permalink
Ci (#260)
Browse files Browse the repository at this point in the history
* CI

* CI
  • Loading branch information
sosiristseng authored Oct 4, 2023
1 parent 3f719d0 commit e9e3279
Show file tree
Hide file tree
Showing 36 changed files with 136 additions and 1,208 deletions.
29 changes: 0 additions & 29 deletions .github/Dockerfile

This file was deleted.

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

This file was deleted.

104 changes: 83 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,80 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write

env:
NPROC: '2' # Number of Julia processes to run the notebooks
IMAGE: 'app:test'
NPROC: '2' # Number of Julia processes to run the notebooks
PYTHON_VER: '3.11'
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
GKSwstype: '100'

jobs:
CI:
execute:
container:
image: julia:1.9.3
runs-on: ubuntu-latest
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 }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
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:
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 --color=yes setup.jl
- name: Build notebooks with ${{ env.NPROC }} processes
run: docker run --rm -w /tmp -v ${{ github.workspace }}:/tmp -e JULIA_PROJECT=@. ${{ env.IMAGE }} julia --color=yes -p ${{ env.NPROC }} literate.jl
- name: Take ownership
run: sudo chown -R $USER docs/
env:
JULIA_PROJECT: '@.'
run: julia --color=yes -p ${{ env.NPROC }} literate.jl
- name: Upload notebooks
uses: actions/upload-artifact@v3
with:
name: notebooks
path: docs
retention-days: 1

jupyter-book:
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:
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:
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 All @@ -54,10 +93,33 @@ jobs:
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: jupyter-book
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.jupyter-book.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: jupyter-book
if: ${{ github.ref == 'refs/heads/main'}}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
Expand Down
37 changes: 21 additions & 16 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,45 @@ concurrency:
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
JULIA_CPU_TARGET: 'generic;haswell,clone_all'
JULIA_NUM_THREADS: 'auto'
JULIA_CONDAPKG_BACKEND: 'Null'
JULIA_PKG_PRECOMPILE_AUTO: '0'
JULIA_PROJECT: '@.'

jobs:
update-manifest:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
container:
image: julia:1.9.3
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 -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
Loading

0 comments on commit e9e3279

Please sign in to comment.