Recommendation: cache `~/.julia/artifacts` in CI services

As many of you are probably already aware, starting from v1.3, Julia is using Artifacts to ship binary packages to the users. You can read more about this in the blog post Reliable and Reproducible Binary Artifacts for Julia Packages.

Since these packages can take some time to download, you may want to cache them to avoid downloading them over and over again. This would also solve occasional failures due to connection problems between the CI service and GitHub, where most of the tarballs reside.

Here are instructions about how to cache artifacts in some popular CI services, feel free to contribute more instructions and I’ll update the post.

Travis CI

You can cache Julia artifacts on Travis with

cache:
  directories:
  - $HOME/.julia/artifacts

AppVeyor

Following these instructions, my understanding is that for AppVeyor this might work:

cache:
  - '%USERPROFILE%\.julia\artifacts'

GitHub Actions

To cache the artifacts in GitHub actions, add the following lines after the setup-julia setup:

      - name: Cache artifacts
        uses: actions/cache@v1
        env:
          cache-name: cache-artifacts
        with:
          path: ~/.julia/artifacts 
          key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
          restore-keys: |
            ${{ runner.os }}-test-${{ env.cache-name }}-
            ${{ runner.os }}-test-
            ${{ runner.os }}-

Final remarks

Note that an extremely large quantity of artifacts can actually increase CI time at least the very first time, but subsequent executions should be faster. Please do report here if you encounter problems due to the use of cache of artifacts on CI services, so that we can understand what may be going wrong.

15 Likes

Thanks a lot for this. I think you are missing a ' at the end of the AppVeyor config.

1 Like

If you’re seeing random errors downloading artifacts in CI right now, it’s because GitHub is having problems right now: https://www.githubstatus.com/incidents/1p369ttzrnqy. This is however a good occasion to recommend again caching artifacts in CI exactly to avoid issues like this one