diff --git a/.github/Dockerfile b/.github/Dockerfile deleted file mode 100644 index 35e9adf..0000000 --- a/.github/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM julia:1.9.3 as julia -FROM python:3.12.0-slim as base - -# Julia config -ENV JULIA_CI true -ENV JULIA_NUM_THREADS "auto" -# Let PythonCall use built-in python -ENV JULIA_CONDAPKG_BACKEND "Null" -ENV JULIA_CPU_TARGET "generic;haswell,clone_all" -ENV JULIA_PATH /usr/local/julia/ -ENV JULIA_DEPOT_PATH /srv/juliapkg/ -ENV PATH ${JULIA_PATH}/bin:${PATH} -COPY --from=julia ${JULIA_PATH} ${JULIA_PATH} - -FROM base - -WORKDIR /work - -# Python dependencies. e.g. matplotlib -COPY requirements.txt ./ -RUN pip install --no-cache-dir nbconvert -r requirements.txt - -# Julia environment -COPY Project.toml Manifest.toml ./ -COPY src/ src -RUN julia --project="" --color=yes -e 'import Pkg; Pkg.add("IJulia")' && \ - julia --project=@. --color=yes -e 'import Pkg; Pkg.instantiate(); Pkg.resolve(); Pkg.precompile()' diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 231bdbe..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" - open-pull-requests-limit: 1 - schedule: - interval: "daily" - labels: - - "automerge" - - package-ecosystem: "github-actions" - directory: "/" - open-pull-requests-limit: 1 - schedule: - interval: "daily" - labels: - - "automerge" - - package-ecosystem: "docker" - directory: "/.github" - open-pull-requests-limit: 1 - schedule: - interval: "daily" - labels: - - "automerge" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e0d3f6..9486fbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 @@ -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/ diff --git a/.github/workflows/update-manifest.yml b/.github/workflows/update-manifest.yml index 1aa3a5d..2494d39 100644 --- a/.github/workflows/update-manifest.yml +++ b/.github/workflows/update-manifest.yml @@ -8,7 +8,6 @@ on: branches: - main paths: - - .github/Dockerfile - .github/workflows/update-manifest.yml concurrency: @@ -16,8 +15,8 @@ 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 jobs: update-manifest: @@ -25,31 +24,37 @@ jobs: 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 diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..639b62b --- /dev/null +++ b/renovate.json @@ -0,0 +1,9 @@ +{ + "extends": [ + "config:recommended", + ":automergeMajor" + ], + "git-submodules": { + "enabled": true + } +}