name: Julia

on:
  push:

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-20.04]
        julia-version: ['1']

    runs-on: ${{ matrix.os }}

    env:
      # Set `JULIA_PKG_SERVER` to the empty string so that the registry will
      # be fetched using git instead of the package server (to avoid delays).
      JULIA_PKG_SERVER: ""

    steps:
      - name: Environment setup
        uses: actions/checkout@v2
      - name: Julia setup
        uses: julia-actions/setup-julia@latest
        with:
          version: ${{ matrix.julia-version }}
      - name: Julia test and style
        run: |
          make info
          make -j2
          export JULIA_LIBCEED_LIB=$(find $PWD/lib -name "libceed.*")
          pushd julia/LibCEED.jl
          [[ "$GITHUB_REF" =~ ^refs/(heads/release|tags/).* ]] || julia --project -e 'import Pkg; Pkg.build(); Pkg.test("LibCEED"; coverage=true, test_args=["--run-dev-tests"])'
          unset JULIA_LIBCEED_LIB && julia --project -e 'import Pkg; Pkg.build(); Pkg.test("LibCEED")'
          julia --project=.style/ -e 'import Pkg; Pkg.instantiate()' && julia --project=.style/ .style/ceed_style.jl && git diff --exit-code src test examples
