Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Sep 1, 2024
1 parent be15b9c commit 3a56cc8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ jobs:
uses: actions/cache@v4
id: cache-julia
with:
path: |
~/.julia
!~/.julia/registries
path: ~/.julia
key: ${{ runner.os }}-julia-${{ env.CACHE_NUM }}-${{ steps.read_toml.outputs.value }}-${{ steps.hash.outputs.value }}
restore-keys: |
${{ runner.os }}-julia-${{ env.CACHE_NUM }}-${{ steps.read_toml.outputs.value }}-
- name: Install Julia packages
if: ${{ !contains(runner.name, 'GitHub Actions') || steps.cache-julia.outputs.cache-hit != 'true' }}
if: ${{ runner.environment == 'self-hosted' || steps.cache-julia.outputs.cache-hit != 'true' }}
shell: julia --color=yes {0}
run: |
using Pkg, Dates
Expand Down Expand Up @@ -90,7 +88,7 @@ jobs:
id: nb-cache
with:
path: ${{ env.NBCACHE }}
key: ${{ runner.os }}-notebook-${{ hashFiles(env.NB) }}-${{ needs.setup.outputs.hash }}
key: ${{ runner.os }}-notebook-${{ env.CACHE_NUM }}-${{ needs.setup.outputs.hash }}-${{ hashFiles(env.NB) }}
- name: Setup Python
uses: actions/setup-python@v5
if: ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
Expand All @@ -115,12 +113,10 @@ jobs:
with:
version: ${{ steps.read_toml.outputs.value }}
- name: Restore Julia packages
if: ${{ steps.nb-cache.outputs.cache-hit != 'true' && contains(runner.name, 'GitHub Actions')}}
if: ${{ runner.environment == 'github-hosted' && steps.nb-cache.outputs.cache-hit != 'true'}}
uses: actions/cache/restore@v4
with:
path: |
~/.julia
!~/.julia/registries
path: ~/.julia
key: ${{ runner.os }}-julia-${{ env.CACHE_NUM }}-${{ steps.read_toml.outputs.value }}-${{ needs.setup.outputs.hash }}
restore-keys: |
${{ runner.os }}-julia-${{ env.CACHE_NUM }}-${{ steps.read_toml.outputs.value }}-
Expand All @@ -133,32 +129,25 @@ jobs:
with:
path: ${{ env.NBCACHE }}
key: ${{ steps.nb-cache.outputs.cache-primary-key }}
- name: Convert artifact Name
id: art
run: echo "name=$(echo ${{ env.NB }} | sed 's/\//-/g')" >> "$GITHUB_OUTPUT"
- name: Upload Notebook
uses: actions/upload-artifact@v4
with:
name: notebook-${{ steps.art.outputs.name }}
name: ${{ steps.nb-cache.outputs.cache-primary-key }}
path: ${{ env.NBCACHE }}
retention-days: 1

render:
needs: execute
runs-on: ubuntu-latest
env:
UV_SYSTEM_PYTHON: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download notebooks
uses: actions/download-artifact@v4
with:
path: ${{ env.NBCACHE }}/
pattern: notebook-*
pattern: ${{ runner.os }}-notebook-*
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R ${{ env.NBCACHE }}
- name: Copy back built notebooks
run: cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/
- name: Setup Python
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/clear-main-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Clear main caches
on:
workflow_dispatch:

jobs:
cleanup:
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.event.repository.default_branch }}
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Update Julia dependencies
env:
JULIA_PKG_PRECOMPILE_AUTO: '0'
run: julia --project=@. --color=yes -e 'import Pkg; Pkg.update()'
run: julia --project=@. --color=yes -e 'using 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

0 comments on commit 3a56cc8

Please sign in to comment.