|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Trigger the workflow on push or pull request, but only for the main branch |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + cabal: |
| 11 | + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest] |
| 16 | + cabal: ["3.4.0.0"] |
| 17 | + ghc: ["8.8.4", "8.10.4", "9.0.1"] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' |
| 22 | + |
| 23 | + - name: Prepare environment |
| 24 | + run: .github/workflows/setup_ci_env.sh |
| 25 | + |
| 26 | + - name: Configure environment |
| 27 | + run: | |
| 28 | + git config --global http.sslVerify false |
| 29 | + echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH" |
| 30 | + echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" |
| 31 | + echo "NIX_SSL_CERT_FILE=$cert_file" >> "$GITHUB_ENV" |
| 32 | + cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt |
| 33 | + env |
| 34 | +
|
| 35 | + - name: Configure Darwin Nixpkgs |
| 36 | + if: matrix.os == 'macos-latest' |
| 37 | + run: | |
| 38 | + echo 'NIX_PATH="nixpkgs=channel:nixpkgs-21.05-darwin"' >> "$GITHUB_ENV" |
| 39 | +
|
| 40 | + - name: Configure Linux Nixpkgs |
| 41 | + if: matrix.os == 'ubuntu-latest' |
| 42 | + run: | |
| 43 | + echo 'NIX_PATH="nixpkgs=channel:nixos-21.05"' >> "$GITHUB_ENV" |
| 44 | +
|
| 45 | + - name: Set GHC version for Nix |
| 46 | + run: | |
| 47 | + if [[ ${{matrix.ghc}} == '8.8.4' ]] |
| 48 | + then echo "GHC='884'" >> "$GITHUB_ENV" |
| 49 | + elif [[ ${{matrix.ghc}} == '8.10.4' ]] |
| 50 | + then echo "GHC='8104'" >> "$GITHUB_ENV" |
| 51 | + elif [[ ${{matrix.ghc}} == '9.0.1' ]] |
| 52 | + then echo "GHC='901'" >> "$GITHUB_ENV" |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Install Nix |
| 56 | + run: ./.github/workflows/install-nix.sh |
| 57 | + |
| 58 | + - name: Configure |
| 59 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal update && cabal configure --enable-tests --disable-benchmarks --test-show-details=direct --disable-optimization --with-compiler="ghc-${{ matrix.ghc }}"' .github/workflows/shell.nix |
| 60 | + |
| 61 | + - name: Freeze |
| 62 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal freeze' .github/workflows/shell.nix |
| 63 | + |
| 64 | + - uses: actions/cache@v2 |
| 65 | + name: Cache ~/.cabal/store |
| 66 | + with: |
| 67 | + path: ~/.cabal/store |
| 68 | + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}- |
| 69 | + |
| 70 | + - name: Installing dependencies |
| 71 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make deps' .github/workflows/shell.nix |
| 72 | + |
| 73 | + - name: Running hlint |
| 74 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/hlint-runner.sh' .github/workflows/shell.nix |
| 75 | + |
| 76 | + - name: Running stylish-haskell |
| 77 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/stylish-haskell-runner.sh' .github/workflows/shell.nix |
| 78 | + |
| 79 | + - name: Build |
| 80 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make build' .github/workflows/shell.nix |
| 81 | + |
| 82 | + - name: Test |
| 83 | + run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal test all' .github/workflows/shell.nix |
0 commit comments