Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A shortcut action to cache Julia artifacts, packages, and registries.

License

NotificationsYou must be signed in to change notification settings

julia-actions/cache

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A shortcut action to cache Julia depot contents to reduce GitHub Actions running time.

Usage

An example workflow that uses this action might look like this:

name:CIon:[push, pull_request]# needed to allow julia-actions/cache to delete old caches that it has createdpermissions:actions:writecontents:readjobs:test:runs-on:ubuntu-lateststeps:    -uses:actions/checkout@v6    -uses:julia-actions/setup-julia@v2    -uses:julia-actions/cache@v2    -uses:julia-actions/julia-buildpkg@v1    -uses:julia-actions/julia-runtest@v1

By default all depot directories called out below are cached.

Requirements

  • jq: This action usesjq to parse JSON. For GitHub-hosted runners,jq is installed by default. On self-hosted runners and custom containers, ifjq is not already available, this action will automatically usedcarbone/install-jq-action to installjq (Note:dcarbone/install-jq-action requires thatcurl is installed; this may not always be the case in custom containers and self-hosted runners).
  • bash: This action requiresbash. For GitHub-hosted runnersbash is installed by default. Self-hosted runners will need to ensure thatbash is installed and available on thePATH.

Optional Inputs

  • cache-name - The cache key prefix. Defaults tojulia-cache;workflow=${{ github.workflow }};job=${{ github.job }}. The key body automatically includes the OS and, unless disabled withinclude-matrix, the matrix vars. Include any other parameters/details in this prefix to ensure one unique cache key per concurrent job type.
  • include-matrix - Whether to include the matrix values when constructing the cache key. Defaults totrue.
  • depot - Path to a Juliadepot directory where cached data will be saved to and restored from. Defaults to the first depot inJULIA_DEPOT_PATH if specified. Otherwise, defaults to~/.julia.
  • cache-artifacts - Whether to cache the depot'sartifacts directory. Defaults totrue.
  • cache-packages - Whether to cache the depot'spackages directory. Defaults totrue.
  • cache-registries - Whether to cache the depot'sregistries directory. Defaults totrue.
  • cache-compiled - Whether to cache the depot'scompiled directory. Defaults totrue.
  • cache-scratchspaces - Whether to cache the depot'sscratchspaces directory. Defaults totrue.
  • cache-logs - Whether to cache the depot'slogs directory. Defaults totrue. Helps auto-Pkg.gc() keep the cache small.
  • delete-old-caches - Whether to delete old caches for the given key. Defaults totrue.
  • token - AGitHub PAT. Defaults togithub.token. Requiresrepo scope to enable the deletion of old caches.

Outputs

  • cache-hit - A boolean value to indicate an exact match was found for the primary key. Returns "" when the key is new. Forwarded from actions/cache.
  • cache-paths - A list of paths (as a newline-separated string) that were cached.
  • cache-key - The cache key that was used for this run.

How It Works

This action is a wrapper aroundhttps://github.com/actions/cache.In summary, this action stores the files in the aforementioned paths in one compressed file when running for the first time.This cached file is then restored upon the second run, and afterwards resaved under a new key, and the previous cache deleted.The benefit of caching is that downloading one big file is quicker than downloading many different files from many different locationsand precompiling them.

By default, this action removes caches that were previously made by jobs on the same branch with the same restore key.GitHub automatically removes old caches after a certain period or when the repository cache allocation is full.It is, however, more efficient to explicitly remove old caches to improve caching for less frequently run jobs.

For more information about GitHub caching generically, for example how to manually delete caches, seethis GitHub documentation page.

Cache keys

The cache key that the cache will be saved as is based on:

  • Thecache-name input
  • All variables in thematrix (unless disabled viainclude-matrix: 'false')
  • Therunner.os (may be in the matrix too, but included for safety)
  • The run id
  • The run attempt number

Note

If there is job concurrency that is not fully defined by a matrix you should ensure thatcache-name isunique for each concurrent job, otherwise caching may not be effective.

Cache Retention

This action automatically deletes old caches that match the first 4 fields of the above key:

  • Thecache-name input
  • All variables in thematrix (unless disabled viainclude-matrix: 'false')
  • Therunner.os (may be in the matrix too, but included for safety)

Which means your caches files will not grow needlessly. GitHub also deletes cache files after7 days of not being accessed, and there is a limit of 10 GB for the total size of cache files associated to each repository.

Note

To allow deletion of caches you will likely need togrant the following permissionsto theGITHUB_TOKEN by adding this to your GitHub actions workflow:

permissions:actions:writecontents:read

(Note this won't work for fork PRs but should once merged)Or provide a token withrepo scope via thetoken input option.Seehttps://cli.github.com/manual/gh_cache_delete

To disable deletion set inputdelete-old-caches: 'false'.

Caching even if an intermediate job fails

Just likethe basic actions/cache workflow, this action has a cache restore step, and also a save step which runs after the workflow completes.By default, if any job in the workflow fails, the entire workflow will be stopped, and the cache will not be saved.

Due to current limitations in GitHub Actions syntax, there is no built-in option for this action to save the cache even if the job fails.However, it does output information which you can feed intoactions/cache yourself to achieve the same effect.For example, this workflow will ensure that the cache is saved if a step fails (but skipping it if the cache was hit, i.e. there's no need to cache it again).

steps:      -uses:actions/checkout@v4      -name:Load Julia packages from cacheid:julia-cacheuses:julia-actions/cache@v2# do whatever you want here (that might fail)      -name:Save Julia depot cache on cancel or failureid:julia-cache-saveif:cancelled() || failure()uses:actions/cache/save@v4with:path:|            ${{ steps.julia-cache.outputs.cache-paths }}key:${{ steps.julia-cache.outputs.cache-key }}

Cache Garbage Collection

Caches are restored and re-saved after every run, retaining the state of the depot throughout runs.Their size will be regulated like a local depot automatically by the automaticPkg.gc() functionality thatclears out old content, which is made possible because the/log contents are cached.

Third Party Notice

This action is built aroundactions/cache and includes parts of that action.actions/cache has been released under the following licence:

The MIT License (MIT)

Copyright (c) 2018 GitHub, Inc. and contributors

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.


[8]ページ先頭

©2009-2025 Movatter.jp