Skip to content

Commit

Permalink
Try turning the test job into a matrix build
Browse files Browse the repository at this point in the history
This should reduce the latency of CI, since it will do all the tests for
all the packages in parallel. It also makes it easier and faster to
retry if the tests for one package fail.
  • Loading branch information
michaelpj committed Jun 11, 2023
1 parent 8176fb8 commit 914f77d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 179 deletions.
8 changes: 3 additions & 5 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
cabal:
description: "Cabal version"
required: false
default: "3.8.1.0"
default: "3.10"
os:
description: "Operating system: Linux, Windows or macOS"
required: true
Expand Down Expand Up @@ -57,11 +57,9 @@ runs:
- if: inputs.shorten-hls == 'true'
name: Workaround shorten binary names
run: |
sed -i.bak -e 's/haskell-language-server/hls/g' \
-e 's/haskell_language_server/hls/g' \
sed -i.bak -e 's/executable haskell-language-server/executable hls/g' \
-e 's/haskell-language-server:haskell-language-server/haskell-language-server:hls/g' \
haskell-language-server.cabal cabal.project
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
src/**/*.hs exe/*.hs
shell: bash

- name: Retrieving `cabal.project` Hackage timestamp
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
{ "package": "haskell-language-server", "excluded_ghcs" : [] }
, { "package": "hie-compat", "excluded_ghcs" : [] }
, { "package": "shake-bench", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-graph", "excluded_ghcs" : [] }
, { "package": "ghcide", "excluded_ghcs" : [] }
, { "package": "ghcide-bench", "excluded_ghcs" : [] }
, { "package": "ghcide-test-utils", "excluded_ghcs" : [] }
, { "package": "hls-plugin-api", "excluded_ghcs" : [] }
, { "package": "hls-test-utils", "excluded_ghcs" : [] }
, { "package": "hls-cabal-plugin", "excluded_ghcs" : [] }
, { "package": "hls-cabal-fmt-plugin", "excluded_ghcs" : [] }
, { "package": "hls-tactics-plugin", "excluded_ghcs" : ["9.2", "9.4", "9.6"] }
, { "package": "hls-stylish-haskell-plugin", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-fourmolu-plugin", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-class-plugin", "excluded_ghcs" : [] }
, { "package": "hls-eval-plugin", "excluded_ghcs" : ["9.4"] }
, { "package": "hls-explicit-imports-plugin", "excluded_ghcs" : [] }
, { "package": "hls-refine-imports-plugin", "excluded_ghcs" : [] }
, { "package": "hls-hlint-plugin", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-rename-plugin", "excluded_ghcs" : [] }
, { "package": "hls-retrie-plugin", "excluded_ghcs" : [] }
, { "package": "hls-haddock-comments-plugin", "excluded_ghcs" : ["9.2", "9.4", "9.6"] }
, { "package": "hls-splice-plugin", "excluded_ghcs" : [] }
, { "package": "hls-floskell-plugin", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-pragmas-plugin", "excluded_ghcs" : [] }
, { "package": "hls-module-name-plugin", "excluded_ghcs" : [] }
, { "package": "hls-ormolu-plugin", "excluded_ghcs" : ["9.6"] }
, { "package": "hls-call-hierarchy-plugin", "excluded_ghcs" : [] }
, { "package": "hls-alternate-number-format-plugin", "excluded_ghcs" : [] }
, { "package": "hls-qualify-imported-names-plugin", "excluded_ghcs" : [] }
, { "package": "hls-code-range-plugin", "excluded_ghcs" : [] }
, { "package": "hls-change-type-signature-plugin", "excluded_ghcs" : [] }
, { "package": "hls-stan-plugin", "excluded_ghcs" : [ "9.0", "9.2", "9.4", "9.6"] }
, { "package": "hls-gadt-plugin", "excluded_ghcs" : [] }
, { "package": "hls-explicit-fixity-plugin", "excluded_ghcs" : [] }
, { "package": "hls-explicit-record-fields-plugin", "excluded_ghcs" : [] }
, { "package": "hls-refactor-plugin", "excluded_ghcs" : [] }
, { "package": "hls-overloaded-record-dot-plugin", "excluded_ghcs" : ["8.10", "9.0"] }
]
213 changes: 39 additions & 174 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ jobs:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }}
ghcs: ${{ steps.ghcs.outputs.ghcs }}
ghcs: ${{ steps.matrix-inputs.outputs.ghcs }}

steps:
# Need the repo checked out in order to read the file
# Need the repo checked out in order to read the files
- uses: actions/checkout@v3
- id: ghcs
run: echo "ghcs=$(cat ./.github/workflows/supported-ghc-versions.json)" >> $GITHUB_OUTPUT

- id: matrix-inputs
run: |
echo "ghcs=$(cat ./.github/workflows/supported-ghc-versions.json)" >> $GITHUB_OUTPUT
- id: skip_check
uses: fkirc/[email protected]
with:
Expand All @@ -35,30 +38,17 @@ jobs:
, "**/LICENSE"
, "**.nix"
, "flake.lock"
, "**/README.md"
, "FUNDING.yml"
, "**.yml"
, "**.yaml"
, ".circleci/**"
, "**/stack*.yaml"
, ".gitlab-ci.yaml"
, ".gitlab/**"
]'
# If we only change ghcide downstream packages we have not test ghcide itself
- id: skip_ghcide_check
uses: fkirc/[email protected]
with:
cancel_others: false
paths_ignore: '[ "hls-test-utils/**"
, "plugins/**"
, "src/**"
, "exe/**"
, "test/**"
, "shake-bench/**"
, ".github/**"
]'

test:
if: needs.pre_job.outputs.should_skip != 'true'
needs:
- pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ${{ matrix.os }}
strategy:
# We don't want to fail fast.
Expand All @@ -71,27 +61,31 @@ jobs:
ghc: ${{ fromJSON(needs.pre_job.outputs.ghcs) }}
os:
- ubuntu-latest
- macOS-latest
- windows-latest
# Mark which GHC versions on which platforms we want to test.
include:
# Test all supported versions, but only on ubuntu and windows
- os: ubuntu-latest
test: true
- os: windows-latest
test: true
#- macOS-latest
#- windows-latest

steps:
- uses: actions/checkout@v3

- name: Determine packages to build
run: |
SELECTED_PKGS=$(cat ./.github/workflows/packages.json | jq -c '[.[] | select(any(.excluded_ghcs[] ; contains("${{ matrix.ghc }}")) | not) | .package]')
ALL_PKGS=$(cat ./.github/workflows/packages.json | jq -c '[.[] | .package]')
COMBINED="{ \"all\": $ALL_PKGS, \"selected\": $SELECTED_PKGS }"
EXCLUDED=$(echo $COMBINED | jq -c '.all-.selected')
echo "Will build the following packages:"
echo $SELECTED_PKGS
echo "Excluded the following packages due the GHC version:"
echo $EXCLUDED
echo "SELECTED_PKGS=$SELECTED_PKGS" >> "$GITHUB_ENV"
shell: bash

- uses: ./.github/actions/setup-build
with:
ghc: ${{ matrix.ghc }}
os: ${{ runner.os }}

- name: Build
run: cabal build

- name: Set test options
# run the tests without parallelism, otherwise tasty will attempt to run
# all functional test cases simultaneously which causes way too many hls
Expand All @@ -107,151 +101,22 @@ jobs:
path: "**/.tasty-rerun-log*"
key: v1-${{ runner.os }}-${{ matrix.ghc }}-test-log-${{ github.sha }}

- if: matrix.test
name: Test hls-graph
run: cabal test hls-graph --test-options="$TEST_OPTS"

- if: needs.pre_job.outputs.should_skip_ghcide != 'true' && matrix.test
name: Test ghcide
# run the tests without parallelism to avoid running out of memory
run: cabal test ghcide --test-options="$TEST_OPTS" || cabal test ghcide --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-plugin-api
run: cabal test hls-plugin-api --test-options="$TEST_OPTS" || cabal test hls-plugin-api --test-options="$TEST_OPTS"

- if: matrix.test
name: Test func-test suite
env:
HLS_TEST_EXE: hls
HLS_WRAPPER_TEST_EXE: hls-wrapper
run: cabal test func-test --test-options="$TEST_OPTS" || cabal test func-test --test-options="$TEST_OPTS"
- name: Build packages
run: |
PKGS=$(echo $SELECTED_PKGS | jq -r '.[]')
cabal build $PKGS
shell: bash

- if: matrix.test
name: Test wrapper-test suite
name: Test packages
# For the func and wrapper tests
env:
HLS_TEST_EXE: hls
HLS_WRAPPER_TEST_EXE: hls-wrapper
run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper"

- if: matrix.test
name: Test hls-refactor-plugin
run: cabal test hls-refactor-plugin --test-options="$TEST_OPTS" || cabal test hls-refactor-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
name: Test hls-floskell-plugin
run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-class-plugin
run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-pragmas-plugin
run: cabal test hls-pragmas-plugin --test-options="$TEST_OPTS" || cabal test hls-pragmas-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-eval-plugin
run: cabal test hls-eval-plugin --test-options="$TEST_OPTS" || cabal test hls-eval-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.2' && matrix.ghc != '9.4' && matrix.ghc != '9.6'
name: Test hls-haddock-comments-plugin
run: cabal test hls-haddock-comments-plugin --test-options="$TEST_OPTS" || cabal test hls-haddock-comments-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-splice-plugin
run: cabal test hls-splice-plugin --test-options="$TEST_OPTS" || cabal test hls-splice-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
name: Test hls-stylish-haskell-plugin
run: cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS" || cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
name: Test hls-ormolu-plugin
run: cabal test hls-ormolu-plugin --test-options="$TEST_OPTS" || cabal test hls-ormolu-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
name: Test hls-fourmolu-plugin
run: cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS" || cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.2' && matrix.ghc != '9.4' && matrix.ghc != '9.6'
name: Test hls-tactics-plugin test suite
run: cabal test hls-tactics-plugin --test-options="$TEST_OPTS" || cabal test hls-tactics-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-refine-imports-plugin test suite
run: cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-explicit-imports-plugin test suite
run: cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-call-hierarchy-plugin test suite
run: cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.os != 'windows-latest'
name: Test hls-rename-plugin test suite
run: cabal test hls-rename-plugin --test-options="$TEST_OPTS" || cabal test hls-rename-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
name: Test hls-hlint-plugin test suite
run: cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || cabal test hls-hlint-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.0' && matrix.ghc != '9.2' && matrix.ghc != '9.4' && matrix.ghc != '9.6'
name: Test hls-stan-plugin test suite
run: cabal test hls-stan-plugin --test-options="$TEST_OPTS" || cabal test hls-stan-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-module-name-plugin test suite
run: cabal test hls-module-name-plugin --test-options="$TEST_OPTS" || cabal test hls-module-name-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-alternate-number-format-plugin test suite
run: cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" || cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-qualify-imported-names-plugin test suite
run: cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" || cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-code-range-plugin test suite
run: cabal test hls-code-range-plugin --test-options="$TEST_OPTS" || cabal test hls-code-range-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-change-type-signature test suite
run: cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-gadt-plugin test suit
run: cabal test hls-gadt-plugin --test-options="$TEST_OPTS" || cabal test hls-gadt-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-explicit-fixity-plugin test suite
run: cabal test hls-explicit-fixity-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-fixity-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-explicit-record-fields-plugin test suite
run: cabal test hls-explicit-record-fields-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-record-fields-plugin --test-options="$TEST_OPTS"

## version needs to be limited since the tests depend on cabal-fmt which only builds using specific ghc versions
- if: matrix.test && matrix.ghc == '8.10'
name: Test hls-cabal-fmt-plugin test suite
run: cabal test hls-cabal-fmt-plugin --flag=isolateTests --test-options="$TEST_OPTS" || cabal test hls-cabal-fmt-plugin --flag=isolateTests --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-cabal-plugin test suite
run: cabal test hls-cabal-plugin --test-options="$TEST_OPTS" || cabal test hls-cabal-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-retrie-plugin test suite
run: cabal test hls-retrie-plugin --test-options="$TEST_OPTS" || cabal test hls-retrie-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '8.10' && matrix.ghc != '9.0'
name: Test hls-overloaded-record-dot-plugin test suite
run: cabal test hls-overloaded-record-dot-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-overloaded-record-dot-plugin --test-options="$TEST_OPTS"


run: |
PKGS=$(echo $SELECTED_PKGS | jq -r '.[]')
cabal test $PKGS --test-options="$TEST_OPTS"
shell: bash

test_post_job:
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ghcide/src/Control/Concurrent/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module Control.Concurrent.Strict
,module Control.Concurrent.Extra
) where




import Control.Concurrent.Extra hiding (modifyVar, modifyVar',
modifyVar_)
import qualified Control.Concurrent.Extra as Extra
Expand Down

0 comments on commit 914f77d

Please sign in to comment.