mirror of
https://github.com/julia-actions/cache.git
synced 2026-02-12 01:16:54 +08:00
Avoid corrupting existing cloned Julia registries (#102)
* Reproduce add-julia-registry issue * Skip registries restore when already present * Expand ~ * Refactor paths step to use bash array
This commit is contained in:
51
.github/workflows/CI.yml
vendored
51
.github/workflows/CI.yml
vendored
@@ -214,3 +214,54 @@ jobs:
|
||||
logs_dir = joinpath(first(DEPOT_PATH), "logs")
|
||||
@assert !isempty(readdir(logs_dir))
|
||||
|
||||
test-save-cloned-registry:
|
||||
needs: [generate-key]
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
cache-name: ${{ steps.cache-name.outputs.cache-name }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
- name: Set cache-name
|
||||
id: cache-name
|
||||
run: |
|
||||
echo "cache-name=${{ needs.generate-key.outputs.cache-name }}-${{ github.job }}" >>"$GITHUB_OUTPUT"
|
||||
- name: Save cache
|
||||
uses: ./
|
||||
with:
|
||||
cache-name: ${{ steps.cache-name.outputs.cache-name }}
|
||||
# Cannot require a successful cache delete on forked PRs as the permissions for actions is limited to read
|
||||
delete-old-caches: ${{ github.event.pull_request.head.repo.fork && 'false' || 'required' }}
|
||||
- name: Add General registry clone
|
||||
shell: julia --color=yes {0}
|
||||
run: |
|
||||
using Pkg
|
||||
Pkg.Registry.add("General")
|
||||
env:
|
||||
JULIA_PKG_SERVER: ""
|
||||
# Set the registry worktree to an older state to simulate the cache storing an old version of the registry.
|
||||
- name: Use outdated General worktree
|
||||
run: git -C ~/.julia/registries/General reset --hard HEAD~20
|
||||
|
||||
test-restore-cloned-registry:
|
||||
needs: [test-save-cloned-registry]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
||||
- name: Add General registry clone
|
||||
shell: julia --color=yes {0}
|
||||
run: |
|
||||
using Pkg
|
||||
Pkg.Registry.add("General")
|
||||
env:
|
||||
JULIA_PKG_SERVER: ""
|
||||
- name: Restore cache
|
||||
uses: ./
|
||||
with:
|
||||
cache-name: ${{ needs.test-save-cloned-registry.outputs.cache-name }}
|
||||
# Cannot require a successful cache delete on forked PRs as the permissions for actions is limited to read
|
||||
delete-old-caches: ${{ github.event.pull_request.head.repo.fork && 'false' || 'required' }}
|
||||
- name: Test registry is not corrupt
|
||||
shell: julia --color=yes {0}
|
||||
run: |
|
||||
using Pkg
|
||||
Pkg.Registry.update()
|
||||
|
||||
Reference in New Issue
Block a user