Tip: use Julia as custom shell in GitHub Actions

This isn’t maybe very well-known, but in GitHub Actions you can run commands using custom shells, including julia.

For example, in a package I always want to test on CI a package using the latest development revision of a dependency. You can achieve this with a step like:

      - name: Install extra dependency on main branch
        shell: julia --color=yes --project=. {0}
        run: |
          using Pkg
          Pkg.add(PackageSpec(; name="AnExtraPackage", rev="main"))

This isn’t much different from the standard

      - name: Install extra dependency on main branch
        run: |
          julia --project=. -e 'using Pkg; Pkg.add(PackageSpec(; name="AnExtraPackage", rev="main"))'

but using the custom shell makes it nicer to write a multiline Julia script.

35 Likes

Does it work with ]add APackage@1.2.3?

No because ]add... isn’t valid Julia syntax (ERROR: syntax: unexpected "]"). You could use the pkg"..." string literal, but its usage is frowned upon in scripts, because the syntax may break.

1 Like