# 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:** 18\
**Page:** 4

<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:** [January 31, 2021, 9:44pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/61 "2021-01-31T21:44:27Z")

</div>

> [@MA\_Laforge](#):
>
> I tried adding `xvfb-run` as was done in Gtk.jl’s `ci.yml`

You copied it wrong: the lines

> <https://github.com/JuliaGraphics/Gtk.jl/blob/b61cb23845f5784ca6232b3f9afed40f1f91f065/.github/workflows/ci.yml#L55-L56>

go under the `julia-actions/julia-runtest` step, not under `codecov/codecov-action`

> [@MA\_Laforge](#):
>
> Missing `libgtk-3-dev` maybe?

`Gtk.jl` uses the JLL package providing the GTK library, so no need to install anything else in the environment

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 31, 2021, 10:04pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/62 "2021-01-31T22:04:08Z")

</div>

Thanks a bunch.

That was it. I have a bit of trouble understanding how `ci.yml` is structured, but I see now (at least for this example).

> [@giordano](#):
>
> `Gtk.jl` uses the JLL package providing the GTK library, so no need to install anything else in the environment

Good to know! That makes things much easier. Thanks.

---

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [February 17, 2021, 3:48am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/63 "2021-02-17T03:48:42Z")

</div>

Is there any way to install Julia package from the private github repository using GitHub Actions?  
I tried the following code, but got errors.

```julia
- run: |
          julia --project=. -e '
            using Pkg
            Pkg.add(url="https://github.com/zhangliye/mariutil.git")'

```

The errors are as follows.

```julia
Run julia --project=. -e '
    Cloning git-repo `https://github.com/zhangliye/mariutil.git`
ERROR: failed to clone from https://github.com/zhangliye/mariutil.git, error: GitError(Code:EUSER, Class:Callback, Aborting, user cancelled credential request.)
Stacktrace:
 [1] pkgerror(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:52
 [2] clone(::Pkg.Types.Context, ::String, ::String; header::Nothing, credentials::Nothing, kwargs::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:isbare,),Tuple{Bool}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/GitTools.jl:153
 [3] #ensure_clone#3 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/GitTools.jl:112 [inlined]
 [4] handle_repo_add!(::Pkg.Types.Context, ::Pkg.Types.PackageSpec) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:597

```

---

<div class="post-metadata">

**Author:** ![vtjeng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vtjeng/32/3787_2.png) [@vtjeng](https://discourse.julialang.org/u/vtjeng)\
**Post date:** [March 19, 2021, 2:39am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/64 "2021-03-19T02:39:27Z")

</div>

I just set this up for my package, [MIPVerify.jl](https://github.com/vtjeng/MIPVerify.jl/blob/master/.github/workflows/CI.yml) - it was really easy to follow the instructions; thanks Dilum!

However, one downside of using Github actions is that each of the matrix jobs appears as a separate status check.

![image](https://global.discourse-cdn.com/julialang/original/3X/d/3/d3c8020580753435ed927136f5a3d469e7b7a986.png)

This is a lot noisier than Travis, which was a single status check:

![image](https://global.discourse-cdn.com/julialang/original/3X/4/d/4da5e746f52a7dd9266efaabd9fefd09a5ba4ab5.png)

[Status check for a matrix jobs · community · Discussion #26822 · GitHub](https://github.community/t/status-check-for-a-matrix-jobs/127354/6) would allow me to summarize all the status checks in a single check, but the rest of the checks are still displayed; has anyone found a way to have just a single status check summarizing the status of all the different matrix jobs?

---

<div class="post-metadata">

**Author:** ![vtjeng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vtjeng/32/3787_2.png) [@vtjeng](https://discourse.julialang.org/u/vtjeng)\
**Post date:** [March 19, 2021, 2:42am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/65 "2021-03-19T02:42:26Z")

</div>

@dilumaluthge - comparing your `ci.yml` file with [the one in `Documenter.jl`](https://github.com/JuliaDocs/Documenter.jl/blob/master/.github/workflows/CI.yml#L42-L47), you have an additional line

```julia
      - uses: julia-actions/julia-buildpkg@v1

```

I’ve looked through [what the action does](https://github.com/julia-actions/julia-buildpkg), but don’t understand when it’s necessary and when it isn’t. What is it doing here?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 19, 2021, 7:12am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/66 "2021-04-19T07:12:58Z")

</div>

I need a bit of help with environment variables in Github Actions. Specifically, I am transitioning StanRun.jl from Travis to Github Actions, and have a two-job script: `install_stan` downloads and compiles Stan, and `test` runs the tests as usual.

I would like to make an environment variable `JULIA_CMDSTAN_HOME` available from the first job to the second, but it doesn’t seem to be available no matter what I do, the latest I tried is have the first job

```yaml
- run: echo "JULIA_CMDSTAN_HOME=$JULIA_CMDSTAN_HOME" >> $GITHUB_ENV

```

and then the second

```yaml
- uses: julia-actions/julia-runtest@v1
  env:
    JULIA_CMDSTAN_HOME: ${{ env.JULIA_CMDSTAN_HOME }}

```

The whole script is here, help would be appreciated.  
[https://github.com/tpapp/StanRun.jl/blob/2ab969b43caf02f7f23a5fa5c786a7b242fbd636/.github/workflows/CI.yml](https://github.com/tpapp/StanRun.jl/blob/2ab969b43caf02f7f23a5fa5c786a7b242fbd636/.github/workflows/CI.yml)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 19, 2021, 7:37am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/67 "2021-04-19T07:37:27Z")

</div>

I don’t think environment variables are preserved between steps, but you can write to the local filesystem.

So something like

```julia
run: echo "JULIA_CMDSTAN_HOME=$JULIA_CMDSTAN_HOME" > stan.txt

```

then in Julia

```julia
ENV["JULIA_CMDSTAN_HOME"] = read("stan.txt", String)

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 19, 2021, 9:02am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/68 "2021-04-19T09:02:16Z")

</div>

> [@Tamas\_Papp](#):
>
> and then the second
> 
> ```julia
> - uses: julia-actions/julia-runtest@v1
> env:
> JULIA_CMDSTAN_HOME: ${{ env.JULIA_CMDSTAN_HOME }}
> 
> ```

I don’t think you need this, cf [Workflow commands for GitHub Actions - GitHub Docs](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable).

---

<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:** [April 19, 2021, 10:26am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/69 "2021-04-19T10:26:14Z")

</div>

You can set the environment variable in the global scope:

```nohighlight
env:
  JULIA_CMDSTAN_HOME: ~/cmdstan-2.26.1/

```

e.g. at line 12, before the jobs, and you’re done for all the jobs

---

<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:** [April 19, 2021, 10:42am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/70 "2021-04-19T10:42:04Z")

</div>

May be put it as a global environment variable in github itself? In the same way as it is usually done with `DOCUMENTER_KEY` and the like?

```julia
env:
    JULIA_CMDSTAN_HOME: ${{ secrets.JULIA_CMDSTAN_HOME }}

```

It abuses slightly `secrets` mechanism, but why not?

---

<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:** [April 19, 2021, 11:58am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/71 "2021-04-19T11:58:43Z")

</div>

> [@Skoffer](#):
>
> May be put it as a global environment variable in github itself?

Which is what I said in the message above?

---

<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:** [April 19, 2021, 12:06pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/72 "2021-04-19T12:06:49Z")

</div>

Not exactly, in your scenario, if someone wants to update the value of the variable he needs to edit `CI.yml`, in my proposal he needs to change a variable in the GitHub environment, which is easier I suppose since it can be done through a web interface without PR.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 20, 2021, 9:04am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/73 "2021-04-20T09:04:59Z")

</div>

Thanks everyone for the help. I finally managed to set it up ([here](https://github.com/tpapp/StanRun.jl/blob/master/.github/workflows/CI.yml)). This is what I learned in the process:

1. Github Actions has artifacts and a cache for similar purposes, but the compiled binary is huge and it was actually faster to compile it for each job.
2. Environment variables do not persist across jobs.
3. Files do not persist across jobs.
4. Environment variable expansion can be fragile if used to generate other environment variables.

The workaround for the last part is the `run: echo "VAR=value" >> $GITHUB_ENV` trick mentioned in the docs. The `${{ ... }}` expansion may or may not work, eg you cannot use it to generate another environment variable.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 14, 2021, 2:16pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/74 "2021-05-14T14:16:55Z")

</div>

Has anyone figured out how to allow `nightly` to fail, like `allow-failure` on Travis? I found this issue but my I am not sure if a solution exists:

[https://github.com/actions/toolkit/issues/399](https://github.com/actions/toolkit/issues/399)

---

<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:** [May 26, 2021, 12:36am UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/76 "2021-05-26T00:36:41Z")

</div>

A link to the action log instead of a partial screenshot would be more useful to see what’s going on.

Also, this issue should be discussed in its own thread

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [August 19, 2021, 5:36pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/77 "2021-08-19T17:36:08Z")

</div>

Hello, quick question.

Should we use Github Actions CI or [travis-ci.com](http://travis-ci.com)? I just migrated from [travis-ci.org](http://travis-ci.org) to the .com counterpart, but documentation seems to hang infinitely.

Wondering if I should troubleshoot or simply migrate to Githib Actions?

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 19, 2021, 5:57pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/78 "2021-08-19T17:57:40Z")

</div>

[travis-ci.com](http://travis-ci.com) does not have free services for OSS projects anymore (they give you a one-time allotment of credits and when that’s used that’s it, unless you manage to get a special OSS exemption by talking to their support staff), so many people (including me) have moved to GitHub Actions.

---

<div class="post-metadata">

**Author:** ![tiago](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiago/32/22567_2.png) [@tiago](https://discourse.julialang.org/u/tiago)\
**Post date:** [September 18, 2021, 5:24pm UTC](https://discourse.julialang.org/t/easy-workflow-file-for-setting-up-github-actions-ci-for-your-julia-package/49765/79 "2021-09-18T17:24:46Z")

</div>

I have the same error but with the `Documenter.jl` package. I’ve already install it in the package environment but the error still persists. What did you do the fix this?

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