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

You copied it wrong: the lines

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

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

2 Likes

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).

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

1 Like

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

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

The errors are as follows.

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

I just set this up for my package, MIPVerify.jl - 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

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

image

Status check for a matrix jobs ¡ community ¡ Discussion #26822 ¡ GitHub 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?

@dilumaluthge - comparing your ci.yml file with the one in Documenter.jl, you have an additional line

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

I’ve looked through what the action does, but don’t understand when it’s necessary and when it isn’t. What is it doing here?

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

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

and then the second

- 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

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

So something like

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

then in Julia

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

I don’t think you need this, cf Workflow commands for GitHub Actions - GitHub Docs.

1 Like

You can set the environment variable in the global scope:

env:
  JULIA_CMDSTAN_HOME: ~/cmdstan-2.26.1/

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

2 Likes

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?

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

It abuses slightly secrets mechanism, but why not?

Which is what I said in the message above?

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.

Thanks everyone for the help. I finally managed to set it up (here). 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.

1 Like

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

2 Likes

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

2 Likes

Hello, quick question.

Should we use Github Actions CI or travis-ci.com? I just migrated from travis-ci.org to the .com counterpart, but documentation seems to hang infinitely.

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

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.

2 Likes

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?