Haskell CI #7306
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Haskell CI | |
| on: | |
| push: | |
| pull_request: | |
| schedule: | |
| # Everyday at 4:00 AM UTC | |
| - cron: "0 4 * * *" | |
| jobs: | |
| build: | |
| name: build | |
| defaults: | |
| run: | |
| shell: devx {0} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| # TODO: Add ghc910 when input-output-hk/devx is fixed | |
| compiler-nix-name: [ghc96, ghc98, ghc912] | |
| include: | |
| # We want a single job, because macOS runners are scarce. | |
| - os: macos-latest | |
| compiler-nix-name: ghc96 | |
| env: | |
| # Increment this value to "invalidate" the cabal cache. Be sure to do this | |
| # after updating dependencies (Hackage or chap) | |
| CABAL_CACHE_VERSION: 2 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Install GHC and Cabal | |
| uses: input-output-hk/actions/devx@latest | |
| with: | |
| platform: | |
| ${{ (runner.os == 'Linux' && 'x86_64-linux') || | |
| (runner.os == 'macOS' && runner.arch == 'X64' && 'x86_64-darwin') || | |
| (runner.os == 'macOS' && runner.arch == 'ARM64' && 'aarch64-darwin') | |
| }} | |
| target-platform: "" | |
| compiler-nix-name: ${{ matrix.compiler-nix-name }} | |
| minimal: false | |
| # enable IOG-full flavour to bring in all the crypto libraries we need. | |
| iog-full: true | |
| - name: Export devx environment variables | |
| run: | | |
| echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH_FOR_TARGET" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_PATH_FOR_TARGET=$PKG_CONFIG_PATH_FOR_TARGET" >> $GITHUB_ENV | |
| echo "NIX_LDFLAGS=$NIX_LDFLAGS" >> $GITHUB_ENV | |
| echo "LD_LIBRARY_PATH=$(echo $NIX_LDFLAGS | tr ' ' '\n' | grep '^-L' | sed 's/^-L//' | tr '\n' ':')" >> $GITHUB_ENV | |
| - name: cache cabal | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cabal-devx/packages | |
| ~/.cabal-devx/store | |
| key: ${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.compiler-nix-name }}-${{ hashFiles('**/*.cabal', '**/cabal.project', '**/cabal.project.freeze') }} | |
| restore-keys: ${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.compiler-nix-name }}- | |
| - name: cabal update | |
| run: | | |
| export PATH="/usr/bin:$PATH" | |
| cabal update | |
| - name: cabal build dependencies | |
| run: | | |
| export PATH="/usr/bin:$PATH" | |
| cabal build all -j --enable-tests --only-dependencies | |
| - name: cabal build | |
| run: | | |
| export PATH="/usr/bin:$PATH" | |
| cabal build all -j --enable-tests | |
| - name: postgres init | |
| run: | | |
| # Set up environment | |
| PG_DIR="$(mktemp -d)" | |
| DB_DIR="${PG_DIR}/db" | |
| DBUSER=$(whoami) | |
| DBNAME=$DBUSER | |
| # Pass environment to subsequent steps | |
| echo "PG_DIR=${PG_DIR}" >> "$GITHUB_ENV" | |
| echo "DB_DIR=${DB_DIR}" >> "$GITHUB_ENV" | |
| echo "DBUSER=${DBUSER}" >> "$GITHUB_ENV" | |
| # Start postgres | |
| ./scripts/postgresql-test.sh \ | |
| -s "$PG_DIR" \ | |
| -d "$DB_DIR" \ | |
| -u "$DBUSER" \ | |
| -n "$DBNAME" \ | |
| start | |
| - name: cabal test | |
| run: | | |
| export PATH="/usr/bin:$PATH" | |
| # Create pgpass file | |
| export PGPASSFILE="${PG_DIR}/pgpass-testing" | |
| echo "${PG_DIR}:5432:$DBUSER:$DBUSER:*" > $PGPASSFILE | |
| chmod 600 $PGPASSFILE | |
| # Run tests | |
| cabal test all -j1 | |
| - name: postgres shutdown | |
| if: ${{ always() }} | |
| run: | | |
| ./scripts/postgresql-test.sh -d "$DB_DIR" stop |