Optimizations #1418
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: Build & test (dev) | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build-with-stack: | |
| if: github.event.pull_request.draft != true | |
| name: Build and test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| stack-paths: | | |
| ~/.stack | |
| ~/.ghc | |
| - os: windows-latest | |
| stack-paths: | | |
| ~\AppData\Roaming\stack | |
| ~\AppData\Local\Programs\stack\x86_64-windows | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Extract resolver | |
| id: extract | |
| shell: bash | |
| run: bash ./.github/scripts/extract_resolver_and_flags_for_stack.sh | |
| env: | |
| CABAL_FILE: jbeam-edit.cabal | |
| - name: Cache global Stack dependencies | |
| uses: actions/[email protected] | |
| with: | |
| path: ${{ matrix.stack-paths }} | |
| key: >- | |
| stack-${{ matrix.os }}-${{ | |
| steps.extract.outputs.resolver | |
| }}-${{ | |
| hashFiles('stack.yaml', 'stack.yaml.lock') | |
| }} | |
| restore-keys: | | |
| stack-${{ matrix.os }}-${{ steps.extract.outputs.resolver }}- | |
| - name: Set up GHC with Stack | |
| run: stack setup | |
| - name: Build project | |
| run: stack build --fast --hpack-force --lock-file=error-on-write | |
| - name: Check that .cabal file has not changed except hpack comment | |
| shell: bash | |
| run: bash ./.github/scripts/check_cabal_file.sh | |
| - name: Run tests | |
| run: stack test --fast --coverage | |
| - name: Make sure test coverage is more than 80% | |
| shell: bash | |
| run: | | |
| GHC=$(ghc --numeric-version) | |
| TIX_FILE=$(find .stack-work -path "$GHC/*/jbeam-edit-test.tix") | |
| COVERAGE=$(stack hpc report "$TIX_FILE" 2>&1 | grep "expressions used" | awk '{print $1}' | sed 's/%//') | |
| echo "Coverage: $COVERAGE" | |
| if [[ $COVERAGE -lt 70 ]]; then | |
| echo "coverage too low" | |
| exit 1 | |
| fi | |
| - name: Prepare coverage report | |
| if: | | |
| startsWith(matrix.os, 'ubuntu-') | |
| run: | | |
| set -x | |
| GHC=$(stack ghc -- --numeric-version) | |
| mkdir -p coverage | |
| cp -r $(find .stack-work/install -path "*/$GHC/hpc") coverage/ | |
| - name: Upload artifact | |
| if: | | |
| startsWith(matrix.os, 'ubuntu-') && | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/master' | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: coverage | |
| - name: Deploy to GitHub Pages | |
| env: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| if: | | |
| startsWith(matrix.os, 'ubuntu-') && | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/master' | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| generate-matrix: | |
| name: Generate matrix from cabal | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract the tested GHC versions | |
| id: set-matrix | |
| uses: kleidukos/[email protected] | |
| with: | |
| cabal-file: jbeam-edit.cabal | |
| ubuntu-version: 24.04 | |
| version: 0.1.9.1 | |
| build-with-cabal: | |
| if: github.event.pull_request.draft != true | |
| name: Build and test with Cabal (GHC ${{ matrix.ghc }}) | |
| needs: generate-matrix | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Get Cabal version | |
| run: | | |
| cabal_version=$(apt-cache show cabal-install | awk '/^Version:/ { split($2, a, "-"); print a[1] }') | |
| echo "$cabal_version" | |
| echo "cabal-version=${cabal_version}" >>"$GITHUB_OUTPUT" | |
| id: cabal-version | |
| - name: Set up GHC ${{ matrix.ghc }} and Cabal | |
| id: setup-ghc | |
| uses: haskell-actions/[email protected] | |
| with: | |
| ghc-version: ${{ matrix.ghc }} | |
| cabal-version: latest | |
| # cabal-version: ${{ steps.cabal-version.outputs.cabal-version }} | |
| - name: Log GHC and Cabal outputs | |
| run: |- | |
| echo "GHC Version: ${{ steps.setup-ghc.outputs.ghc-version }}" | |
| echo "Cabal Version: ${{ steps.setup-ghc.outputs.cabal-version }}" | |
| echo "Cabal Store Path: ${{ steps.setup-ghc.outputs.cabal-store }}" | |
| echo "get-tested latest: ${{ matrix.newest }}" | |
| echo "get-tested oldest: ${{ matrix.oldest }}" | |
| - name: Configure with oldest dependencies (GHC oldest version) | |
| if: | | |
| matrix.oldest == true && | |
| matrix.newest == false | |
| run: cabal configure --project-file cabal.project.ci --prefer-oldest | |
| - name: Freeze and check dependencies | |
| env: | |
| CABAL_PROJECT: cabal.project.ci | |
| shell: bash | |
| run: bash ./.github/scripts/freeze_dependencies.sh | |
| - name: Cache Cabal store and build artifacts | |
| uses: actions/[email protected] | |
| with: | |
| path: | | |
| ${{ steps.setup-ghc.outputs.cabal-store }} | |
| dist-newstyle | |
| key: >- | |
| ${{ | |
| runner.os | |
| }}-cabal-${{ | |
| matrix.ghc | |
| }}-${{ | |
| hashFiles('**/dist-newstyle/**/plan.json') | |
| }} | |
| restore-keys: | | |
| ${{ runner.os }}-cabal-${{ matrix.ghc }}- | |
| - name: Build project (GHC ${{ steps.setup-ghc.outputs.ghc-version }}) | |
| run: cabal build --project-file cabal.project.ci all | |
| - name: Run tests (GHC ${{ steps.setup-ghc.outputs.ghc-version }}) | |
| run: cabal test --project-file cabal.project.ci |