From 8f019a984f2e80a54328f2068a5369a38b92b421 Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Tue, 23 Apr 2024 16:40:18 +0200 Subject: [PATCH] Update workflow file --- .github/workflows/cabal.project.local.haskell | 7 -- .github/workflows/haskell.yml | 116 ++++++++++++------ 2 files changed, 77 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/cabal.project.local.haskell diff --git a/.github/workflows/cabal.project.local.haskell b/.github/workflows/cabal.project.local.haskell deleted file mode 100644 index f834144..0000000 --- a/.github/workflows/cabal.project.local.haskell +++ /dev/null @@ -1,7 +0,0 @@ -ignore-project: False - -tests: True -benchmarks: True - -program-options - ghc-options: -Werror \ No newline at end of file diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 07d6b22..8db4760 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -1,33 +1,36 @@ name: Haskell CI -# Limit concurrent runs of this workflow within a single PR -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - on: push: branches: [ "main" ] pull_request: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: contents: read jobs: + # Build and test build: - runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.3", "9.8.1"] - cabal: ["3.10.2.0"] + ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2"] + cabal: ["3.10.3.0"] os: [ubuntu-latest, windows-latest, macOS-latest] + timeout-minutes: 60 + steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Haskell id: setup-haskell @@ -35,22 +38,21 @@ jobs: with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - cabal-update: false + cabal-update: true - - name: "Configure cabal.project.local" + - name: Configure the build run: | - cp .github/workflows/cabal.project.local.haskell cabal.project.local - - - name: Cabal update - run: cabal update + cabal configure --enable-tests --enable-benchmark --ghc-options="-Werror" --ghc-options="-fno-ignore-asserts" + cat cabal.project.local - name: Record cabal dependencies id: record-deps run: | cabal build all --dry-run - - name: Cache cabal store - uses: actions/cache@v3 + - name: "Restore cache" + uses: actions/cache/restore@v4 + id: restore-cabal-cache env: cache-name: cache-cabal-build with: @@ -62,13 +64,38 @@ jobs: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}- - name: Install cabal dependencies + id: build-dependencies run: cabal build --only-dependencies --enable-tests --enable-benchmarks all + - name: "Save cache" + uses: actions/cache/save@v4 + id: save-cabal-cache + # Note: cache-hit will be set to true only when cache hit occurs for the + # exact key match. For a partial key match via restore-keys or a cache + # miss, it will be set to false. + if: steps.build-dependencies.outcome == 'success' && steps.restore-cabal-cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }} + - name: Build - run: cabal build --enable-tests --enable-benchmarks all + run: cabal build all + + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable + - name: Set test timeout (Unix) + if: ${{ startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS') }} + run: | + echo "TASTY_TIMEOUT=5m" >> "$GITHUB_ENV" + + # https://github.com/actions/runner/issues/2281#issuecomment-1326748709 + - name: Set test timeout (Windows) + if: ${{ startsWith(matrix.os, 'windows') }} + run: | + echo "TASTY_TIMEOUT=5m" >> "$env:GITHUB_ENV" - name: Run tests - run: cabal test all + run: | + cabal test --test-show-details=direct all # Check formatting for Haskell files stylish-haskell: @@ -77,13 +104,23 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.2.8"] - cabal: ["3.10.2.0"] + ghc: ["9.6.4"] + cabal: ["3.10.3.0"] os: [ubuntu-latest] + # Fix the index-state so we can get proper caching effects. Change this to a + # more recent time if you want to use a newer version of stylish-haskell, or + # if you want stylish-haskell to use updated dependencies. + # + # We use this environment variable in the primary key of our caches, and as + # an argument to cabal install. This ensures that we never rebuild + # dependencies because of newly uploaded packages unless we want to. + env: + hackage-index-state: "2024-04-10T14:36:07Z" + steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install system dependencies (apt-get) run: | @@ -105,19 +142,17 @@ jobs: run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH - name: Cache cabal store - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-cabal-stylish with: path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ env.hackage-index-state }} restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}- ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}- - name: Install stylish-haskell - run: cabal install stylish-haskell --constraint 'stylish-haskell == 0.14.4.0' + run: cabal install --ignore-project --index-state="${{ env.hackage-index-state }}" stylish-haskell --constraint 'stylish-haskell == 0.14.6.0' - name: Record stylish-haskell version run: | @@ -126,7 +161,7 @@ jobs: - name: Run stylish-haskell run: | - ./scripts/format-stylish.sh -p . -d + ./scripts/format-stylish.sh git diff --exit-code # Check formatting for cabal files @@ -136,13 +171,18 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.2.8"] - cabal: ["3.10.2.0"] + ghc: ["9.6.4"] + cabal: ["3.10.3.0"] os: [ubuntu-latest] + # See the comment on the hackage-index-state environment variable for the + # stylish-haskell job. + env: + hackage-index-state: "2024-04-10T14:36:07Z" + steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install system dependencies (apt-get) run: | @@ -164,19 +204,17 @@ jobs: run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH - name: Cache cabal store - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-cabal-cabal-fmt with: path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ env.hackage-index-state }} restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}- ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}- - name: Install cabal-fmt - run: cabal install cabal-fmt --constraint 'cabal-fmt == 0.1.6' + run: cabal install --ignore-project cabal-fmt --index-state="${{ env.hackage-index-state }}" --constraint 'cabal-fmt == 0.1.11' - name: Record cabal-fmt version run: | @@ -195,13 +233,13 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.2.8"] - cabal: ["3.10.2.0"] + ghc: ["9.6.4"] + cabal: ["3.10.3.0"] os: [ubuntu-latest] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Haskell id: setup-haskell