From 8f08602cf63ecd32f90769df3f437b9164044beb Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Sat, 11 Feb 2023 20:32:34 -0500 Subject: [PATCH 1/3] GHC 9.6 compatibility - -XTypeInType is deprecated - skip failing JS test on Windows Cf. https://github.com/haskell/cabal/pull/8754#issuecomment-1435535763 - deal with lift2A in Prelude since base-4.18 (GHC 9.6) - disable everfailing Backpack tests (cherry picked from commit 87ac120385665d819580dd0ace80570c111a3e7b) --- Cabal-syntax/src/Distribution/Utils/Structured.hs | 1 - cabal-install/src/Distribution/Client/VCS.hs | 4 ++++ .../PackageTests/Backpack/Includes2/setup-external.test.hs | 2 +- .../Backpack/Includes2/setup-per-component.test.hs | 2 +- .../PackageTests/Backpack/Includes3/setup-external-ok.test.hs | 2 +- cabal-testsuite/PackageTests/JS/JsSources/js-arch.test.hs | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cabal-syntax/src/Distribution/Utils/Structured.hs b/Cabal-syntax/src/Distribution/Utils/Structured.hs index 5327ed6a427..ca3147710c8 100644 --- a/Cabal-syntax/src/Distribution/Utils/Structured.hs +++ b/Cabal-syntax/src/Distribution/Utils/Structured.hs @@ -7,7 +7,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE TypeInType #-} -- | -- -- Copyright: (c) 2019 Oleg Grenrus diff --git a/cabal-install/src/Distribution/Client/VCS.hs b/cabal-install/src/Distribution/Client/VCS.hs index 8b0a95462da..aca3f4b109f 100644 --- a/cabal-install/src/Distribution/Client/VCS.hs +++ b/cabal-install/src/Distribution/Client/VCS.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE NamedFieldPuns, RecordWildCards, RankNTypes #-} @@ -53,8 +54,11 @@ import Distribution.Version ( mkVersion ) import qualified Distribution.PackageDescription as PD +#if !MIN_VERSION_base(4,18,0) import Control.Applicative ( liftA2 ) +#endif + import Control.Exception ( throw, try ) import Control.Monad.Trans diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs index fb6843f5a52..3e4577aecfa 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs @@ -1,7 +1,7 @@ import Test.Cabal.Prelude main = setupAndCabalTest $ do skipUnlessGhcVersion ">= 8.1" - ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.*" + ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" expectBrokenIf ghc 7987 $ do withPackageDb $ do withDirectory "mylib" $ setup_install_with_docs ["--ipid", "mylib-0.1.0.0"] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs index 1f01eff1efa..5196d404f65 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs @@ -2,7 +2,7 @@ import Test.Cabal.Prelude main = setupTest $ do -- No cabal test because per-component is broken with it skipUnlessGhcVersion ">= 8.1" - ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.*" + ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" expectBrokenIf ghc 7987 $ withPackageDb $ do let setup_install' args = setup_install_with_docs (["--cabal-file", "Includes2.cabal"] ++ args) diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs index bea7f9a089d..d7ae9a1921d 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs @@ -3,7 +3,7 @@ import Data.List import qualified Data.Char as Char main = setupAndCabalTest $ do skipUnlessGhcVersion ">= 8.1" - ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.*" + ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" expectBrokenIf ghc 7987 $ withPackageDb $ do containers_id <- getIPID "containers" diff --git a/cabal-testsuite/PackageTests/JS/JsSources/js-arch.test.hs b/cabal-testsuite/PackageTests/JS/JsSources/js-arch.test.hs index 612c9829cde..1fed749bdb8 100644 --- a/cabal-testsuite/PackageTests/JS/JsSources/js-arch.test.hs +++ b/cabal-testsuite/PackageTests/JS/JsSources/js-arch.test.hs @@ -3,6 +3,7 @@ import Test.Cabal.Prelude main = setupAndCabalTest $ do skipUnlessGhcVersion ">= 9.6" skipUnlessJavaScript + skipIfWindows res <- cabal' "v2-run" ["demo"] assertOutputContains "Hello JS!" res From eb2b8b8793d4f40a0c3750d9f082433c4349fea5 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Wed, 22 Feb 2023 13:59:49 -0500 Subject: [PATCH 2/3] CI: update actions/cache to v3 (cherry picked from commit 91393b4cc2fcaa29449b4c4c668e453aec6da68c) --- .github/workflows/changelogs.yml | 2 +- .github/workflows/quick-jobs.yml | 4 ++-- .github/workflows/validate.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/changelogs.yml b/.github/workflows/changelogs.yml index 0ee8da9fda3..425e5117188 100644 --- a/.github/workflows/changelogs.yml +++ b/.github/workflows/changelogs.yml @@ -29,7 +29,7 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path run: | echo "$HOME/.cabal/bin" >> $GITHUB_PATH - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: ~/.cabal/store key: linux-store-changelogs diff --git a/.github/workflows/quick-jobs.yml b/.github/workflows/quick-jobs.yml index 633c9842fe8..c36db9bd689 100644 --- a/.github/workflows/quick-jobs.yml +++ b/.github/workflows/quick-jobs.yml @@ -24,7 +24,7 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path run: | echo "$HOME/.cabal/bin" >> $GITHUB_PATH - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: ~/.cabal/store key: linux-store-meta @@ -65,7 +65,7 @@ jobs: - name: Set PATH run: | echo "$HOME/.cabal/bin" >> $GITHUB_PATH - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: ~/.cabal/store key: linux-store-doctest diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 317870c0fd1..96e28f298dc 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -78,7 +78,7 @@ jobs: # # See https://github.com/haskell/cabal/pull/8739 for why Windows is excluded - if: ${{ runner.os != 'Windows' }} - uses: actions/cache@v2 + uses: actions/cache@v3 with: # validate.sh uses a special build dir path: | @@ -234,7 +234,7 @@ jobs: # As we are reusing the cached build dir from the previous step # the generated artifacts are available here, # including the cabal executable and the test suite - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ${{ steps.setup-haskell.outputs.cabal-store }} From 8dc322116554e577a4a8f05364f110a46bccd747 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Wed, 22 Feb 2023 14:01:08 -0500 Subject: [PATCH 3/3] CI: add validation against GHC pre-release (currently: 9.6alpha3) Had to block lib/cli-suite tests on Windows, see discussion starting here: - https://github.com/haskell/cabal/pull/8754#issuecomment-1435025848 (cherry picked from commit 9e9a8658b245aa4baf8983bbeab656a6e4692213) --- .github/workflows/validate.yml | 128 +++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 96e28f298dc..48f10d09e91 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -187,6 +187,134 @@ jobs: if: matrix.cli != 'false' run: sh validate.sh $FLAGS -s cli-suite + # The job below is a copy-paste of validate with the necessary tweaks + # to make all work with an upcoming GHC. Those tweaks include: + # - ghcup needs the prerelease channel activated + # - allow-newer for base libraries and Cabal* libraries + # - (sometimes) disabling some parts on Windows because it's hard to figure + # out why they fail + validate-prerelease: + name: Validate ${{ matrix.os }} ghc-prerelease + runs-on: ${{ matrix.os }} + outputs: + GHC_FOR_RELEASE: ${{ format('["{0}"]', env.GHC_FOR_RELEASE) }} + strategy: + matrix: + os: ["ubuntu-20.04", "macos-latest", "windows-latest"] + + steps: + + - uses: actions/checkout@v3 + + # See https://github.com/haskell/cabal/pull/8739 + - name: Sudo chmod to permit ghcup to update its cache + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + sudo ls -lah /usr/local/.ghcup/cache + sudo mkdir -p /usr/local/.ghcup/cache + sudo ls -lah /usr/local/.ghcup/cache + sudo chown -R $USER /usr/local/.ghcup + sudo chmod -R 777 /usr/local/.ghcup + fi + + - name: ghcup + run: | + ghcup --version + ghcup config set cache true + ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml + ghcup install ghc --set 9.6.0.20230210 + ghcup install cabal --set latest + ghc --version + cabal update + + # See the following link for a breakdown of the following step + # https://github.com/haskell/actions/issues/7#issuecomment-745697160 + # + # See https://github.com/haskell/cabal/pull/8739 for why Windows is excluded + - if: ${{ runner.os != 'Windows' }} + uses: actions/cache@v3 + with: + # validate.sh uses a special build dir + path: | + ${{ steps.setup-haskell.outputs.cabal-store }} + dist-* + key: ${{ runner.os }}-${{ matrix.ghc }}-20220419-${{ github.sha }} + restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-20220419- + + - name: Work around git problem https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 (cabal PR #8546) + run: | + git config --global protocol.file.allow always + + # The '+exe' constraint below is important, otherwise cabal-install + # might decide to build the library but not the executable which is + # what we need. + - name: Install cabal-plan + run: | + cd $(mktemp -d) + cabal install cabal-plan --constraint='cabal-plan +exe' --allow-newer + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + + # The tool is not essential to the rest of the test suite. If + # hackage-repo-tool is not present, any test that requires it will + # be skipped. + # We want to keep this in the loop but we don't want to fail if + # hackage-repo-tool breaks or fails to support a newer GHC version. + - name: Install hackage-repo-tool + continue-on-error: true + run: | + cd $(mktemp -d) + cabal install hackage-repo-tool + + # Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs + - name: Install Autotools + if: runner.os == 'macOS' + run: | + brew install automake + + - name: Allow newer boot libraries + run: | + echo "allow-newer: base, template-haskell, ghc-prim, Cabal-syntax, Cabal-described, Cabal, cabal-install-solver, cabal-install" >> cabal.project.validate + + - name: Set validate inputs + run: | + FLAGS="${{ env.COMMON_FLAGS }}" + if [[ "${{ matrix.cli }}" == "false" ]]; then + FLAGS="$FLAGS --lib-only" + fi + echo "FLAGS=$FLAGS" >> $GITHUB_ENV + + - name: Validate print-config + run: sh validate.sh $FLAGS -s print-config + + - name: Validate print-tool-versions + run: sh validate.sh $FLAGS -s print-tool-versions + + - name: Validate build + run: sh validate.sh $FLAGS -s build + + - name: Validate lib-tests + env: + # `rawSystemStdInOut reports text decoding errors` + # test does not find ghc without the full path in windows + GHCPATH: ${{ steps.setup-haskell.outputs.ghc-exe }} + run: sh validate.sh $FLAGS -s lib-tests + + - name: Validate lib-suite + # see https://github.com/haskell/cabal/pull/8754#issuecomment-1435025848 + # for discussion about the trouble on Windows + if: ${{ runner.os != 'Windows' }} + run: sh validate.sh $FLAGS -s lib-suite + + - name: Validate cli-tests + if: matrix.cli != 'false' + run: sh validate.sh $FLAGS -s cli-tests + + - name: Validate cli-suite + # see https://github.com/haskell/cabal/pull/8754#issuecomment-1435025848 + # for discussion about the trouble on Windows + if: ( runner.os != 'Windows' ) && ( matrix.cli != 'false' ) + run: sh validate.sh $FLAGS -s cli-suite + validate-old-ghcs: name: Validate old ghcs ${{ matrix.extra-ghc }} runs-on: ubuntu-20.04