# Easy workflow file for setting up GitHub Actions CI for your Julia package

**URL:** https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765
**Category:** Tooling
**Tags:** ci, github-actions
**Created:** [November 8, 2020, 3:09am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765 "2020-11-08T03:09:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)
#### Post date: [November 8, 2020, 3:09am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/1 "2020-11-08T03:09:37Z")

</div>

Travis CI no longer offers unlimited free minutes for public open-source repositories.

However, GitHub Actions continues to offer unlimited free minutes for public open-source repositories.

To set up GitHub Actions CI on your repository, simply create a new file named `.github/workflows/ci.yml` with the following contents.

When you do so, you should:

1. **Edit** the line that looks like `'1.3'` to reflect the minimum Julia version supported by your package. For example, if your package requires Julia 1.5 or greater, edit that line to look like `'1.5'`.
2. **Change** `MYPACKAGE` to the name of your package.

Here are the contents of the `.github/workflows/ci.yml` file:

```yaml
name: CI
on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master
    tags: '*'
jobs:
  test:
    name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        version:
          - '1.3' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
          - '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
          - 'nightly'
        os:
          - ubuntu-latest
        arch:
          - x64
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - 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 }}-
      - uses: julia-actions/julia-buildpkg@v1
      - uses: julia-actions/julia-runtest@v1
      - uses: julia-actions/julia-processcoverage@v1
      - uses: codecov/codecov-action@v1
        with:
          file: lcov.info
  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: '1'
      - run: |
          julia --project=docs -e '
            using Pkg
            Pkg.develop(PackageSpec(path=pwd()))
            Pkg.instantiate()'
      - run: |
          julia --project=docs -e '
            using Documenter: doctest
            using MYPACKAGE
            doctest(MYPACKAGE)' # change MYPACKAGE to the name of your package
      - run: julia --project=docs docs/make.jl
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

```

I used the excellent [PkgTemplates.jl](https://github.com/invenia/PkgTemplates.jl) package to generate this file.

Specifically, I used the [“A More Complicated Example”](https://invenia.github.io/PkgTemplates.jl/stable/user/#A-More-Complicated-Example-1) example from the  
[PkgTemplates User Guide](https://invenia.github.io/PkgTemplates.jl/stable/user/).

---

<div class="post-metadata">

### Author: ![bilderbuchi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bilderbuchi/32/13562_2.png) [@bilderbuchi](https://discourse.julialang.org/u/bilderbuchi)
#### Post date: [November 8, 2020, 9:00am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/2 "2020-11-08T09:00:49Z")

</div>

Having recently set up GH actions for a python project, I’m curious: are you intentionally not using the current version cache@v2?

---

<div class="post-metadata">

### Author: ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)
#### Post date: [November 8, 2020, 9:09am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/3 "2020-11-08T09:09:25Z")

</div>

Where one can read what `v2`, `v1`, `latest` etc means for different actions?

```julia
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1

```

---

<div class="post-metadata">

### Author: ![bilderbuchi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bilderbuchi/32/13562_2.png) [@bilderbuchi](https://discourse.julialang.org/u/bilderbuchi)
#### Post date: [November 8, 2020, 1:49pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/4 "2020-11-08T13:49:18Z")

</div>

I would start looking in the release notes/changelog of the respective action, e.g. via its GitHub marketplace entry.

---

<div class="post-metadata">

### Author: ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)
#### Post date: [November 13, 2020, 5:05pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/5 "2020-11-13T17:05:46Z")

</div>

Is there a possibility to have _more than one thread_ per job in GitHub Actions?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [November 13, 2020, 5:09pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/6 "2020-11-13T17:09:55Z")

</div>

You can add

```yaml
env:
  JULIA_NUM_THREADS: 2

```

at the top-level of your YAML file

---

<div class="post-metadata">

### Author: ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)
#### Post date: [November 13, 2020, 5:18pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/7 "2020-11-13T17:18:15Z")

</div>

> [@giordano](#):
>
> ```julia
> env:
> JULIA_NUM_THREADS: 2
> 
> ```

great, thank you, that works

---

<div class="post-metadata">

### Author: ![ElectronicTeaCup](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/electronicteacup/32/12647_2.png) [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)
#### Post date: [November 20, 2020, 10:24am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/8 "2020-11-20T10:24:42Z")

</div>

Thanks for the post, this works great. Just one thing though, for the documentation I get:

```nohighlight
ERROR: ArgumentError: Package JSON3 not found in current path:
- Run `import Pkg; Pkg.add("JSON3")` to install the JSON3 package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:893
Error: Process completed with exit code 1.

```

Is this just something I have to add to my packages environment and it’ll go through?

---

<div class="post-metadata">

### Author: ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)
#### Post date: [November 20, 2020, 11:37am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/9 "2020-11-20T11:37:02Z")

</div>

Whoops, I had a typo. I’ve fixed the original post.

Replace `MYPACKAGE` with the name of your package.

---

<div class="post-metadata">

### Author: ![ElectronicTeaCup](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/electronicteacup/32/12647_2.png) [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)
#### Post date: [November 20, 2020, 11:52am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/10 "2020-11-20T11:52:09Z")

</div>

> [@dilumaluthge](#):
>
> `# change MYPACKAGE to the name of your packag`

Awesome, thanks for the fix!

---

<div class="post-metadata">

### Author: ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)
#### Post date: [November 29, 2020, 2:02pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/11 "2020-11-29T14:02:48Z")

</div>

Shouldn’t this also work for pull requests from forks? Any idea why [https://github.com/JuliaDiff/DiffResults.jl/pull/20](https://github.com/JuliaDiff/DiffResults.jl/pull/20) isn’t triggering GHA CI?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [November 29, 2020, 2:41pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/12 "2020-11-29T14:41:58Z")

</div>

Because by default actions cannot trigger other actions, so CompatHelper action doesn’t trigger CI action. You can manually push (or amend) the commit, also closing/reopening the PR might work.

For a more long-term solution set up ab SSH deploy key, see [https://github.com/JuliaRegistries/CompatHelper.jl/blob/ccf7ef4c4c36e6f4bd45071e4ae7e721b77b82e6/README.md#12-set-up-the-ssh-deploy-key-optional](https://github.com/JuliaRegistries/CompatHelper.jl/blob/ccf7ef4c4c36e6f4bd45071e4ae7e721b77b82e6/README.md#12-set-up-the-ssh-deploy-key-optional)

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 29, 2020, 2:50pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/13 "2020-11-29T14:50:28Z")

</div>

I read about this change in Travis. However, in all my repository, things are working fine including macOS builds. Should I change to Github actions?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [November 29, 2020, 2:54pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/14 "2020-11-29T14:54:16Z")

</div>

> [@Ronis\_BR](#):
>
> However, in all my repository, things are working fine including macOS builds.

Likely because you haven’t finished yet your free credits: [Travis CI - Test and Deploy with Confidence](https://travis-ci.com/account/plan)

> [@Ronis\_BR](#):
>
> Should I change to Github actions?

That’s up to you. If you like Travis and are willing to pay for it (or try to apply for free OSS credits, good luck with that) you can stick with it

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 29, 2020, 3:00pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/15 "2020-11-29T15:00:39Z")

</div>

> [@giordano](#):
>
> Likely because you haven’t finished yet your free credits: [Travis CI - Test and Deploy with Confidence](https://travis-ci.com/account/plan)

Ah! That’s sad. Thanks for the information. I think I will just remove macOS.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [November 29, 2020, 3:02pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/16 "2020-11-29T15:02:31Z")

</div>

> [@Ronis\_BR](#):
>
> I think I will just remove macOS.

All other platforms will drain your free credits, too

---

<div class="post-metadata">

### Author: ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)
#### Post date: [November 29, 2020, 3:20pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/17 "2020-11-29T15:20:21Z")

</div>

Are there advantages/disadvantages to combining the Documentation workflow with the CI workflow?

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 29, 2020, 5:36pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/18 "2020-11-29T17:36:29Z")

</div>

Since we do not have something like `allow-failure` as in Travis, how can I make it in GitHub Actions? Create two actions?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [November 29, 2020, 6:21pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/19 "2020-11-29T18:21:52Z")

</div>

The documentation of the events and badges for the Github actions is not that clear. What do you guys use for the events for the badges for passing tests, building documentations, and coverage?

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 29, 2020, 6:31pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/20 "2020-11-29T18:31:20Z")

</div>

I am using something like this for passing tests:

```julia
[![Build status](https://github.com/JuliaSpace/SatelliteToolbox.jl/workflows/CI/badge.svg)](https://github.com/JuliaSpace/SatelliteToolbox.jl/actions)

```

And created two actions `ci.yml` and `ci-nightly.yml`, because the latter can fail. I did not change the badges for accessing documentation.

[Next page](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765.md?page=2)
