From 73d9eeb5a80af4790711236e45b11ee6e0b25467 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Thu, 14 Nov 2024 11:39:05 +0200 Subject: [PATCH] Improve setup methods related code --- .github/workflows/haskell-ci.yml | 4 +- fixtures/all-versions.github | 44 ++++++++++-------- fixtures/copy-fields-all.github | 44 ++++++++++-------- fixtures/copy-fields-none.github | 44 ++++++++++-------- fixtures/copy-fields-some.github | 44 ++++++++++-------- fixtures/doctest-version.github | 48 +++++++++++--------- fixtures/doctest.github | 48 +++++++++++--------- fixtures/empty-line.github | 44 ++++++++++-------- fixtures/enabled-jobs.github | 44 ++++++++++-------- fixtures/fail-versions.github | 44 ++++++++++-------- fixtures/irc-channels.github | 44 ++++++++++-------- fixtures/messy.github | 44 ++++++++++-------- fixtures/psql.github | 44 ++++++++++-------- fixtures/travis-patch.github | 44 ++++++++++-------- haskell-ci.cabal | 4 +- src/HaskellCI/Config/Grammar.hs | 23 ++++++---- src/HaskellCI/Config/History.hs | 21 ++++++--- src/HaskellCI/Config/Initial.hs | 11 +++-- src/HaskellCI/Config/Type.hs | 6 +-- src/HaskellCI/GitHub.hs | 19 ++++---- src/HaskellCI/GitHub/Yaml.hs | 12 +---- src/HaskellCI/Prelude.hs | 9 ++++ src/HaskellCI/SetupMethod.hs | 38 ++++++++++++++++ test/Tests.hs | 77 +++++++++++++++++++++++--------- 24 files changed, 484 insertions(+), 320 deletions(-) create mode 100644 src/HaskellCI/SetupMethod.hs diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index a86ded0d..b0033e20 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -181,7 +181,7 @@ jobs: - name: cache (tools) uses: actions/cache/restore@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-c0a7f8fa + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e9b3b69 path: ~/.haskell-ci-tools - name: install cabal-plan run: | @@ -209,7 +209,7 @@ jobs: if: always() uses: actions/cache/save@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-c0a7f8fa + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e9b3b69 path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v4 diff --git a/fixtures/all-versions.github b/fixtures/all-versions.github index cc4b8246..a97587fd 100644 --- a/fixtures/all-versions.github +++ b/fixtures/all-versions.github @@ -253,32 +253,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -288,20 +308,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/copy-fields-all.github b/fixtures/copy-fields-all.github index bda77160..4492207a 100644 --- a/fixtures/copy-fields-all.github +++ b/fixtures/copy-fields-all.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/copy-fields-none.github b/fixtures/copy-fields-none.github index 63e23dc0..ee6bc293 100644 --- a/fixtures/copy-fields-none.github +++ b/fixtures/copy-fields-none.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/copy-fields-some.github b/fixtures/copy-fields-some.github index 4a603e13..389b4438 100644 --- a/fixtures/copy-fields-some.github +++ b/fixtures/copy-fields-some.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/doctest-version.github b/fixtures/doctest-version.github index a40f0786..4e3bed88 100644 --- a/fixtures/doctest-version.github +++ b/fixtures/doctest-version.github @@ -253,32 +253,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -288,20 +308,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | @@ -411,7 +417,7 @@ jobs: - name: cache (tools) uses: actions/cache/restore@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e171e27 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-58bfb495 path: ~/.haskell-ci-tools - name: install cabal-plan run: | @@ -430,7 +436,7 @@ jobs: if: always() uses: actions/cache/save@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1e171e27 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-58bfb495 path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v4 diff --git a/fixtures/doctest.github b/fixtures/doctest.github index 2abb6523..274809d0 100644 --- a/fixtures/doctest.github +++ b/fixtures/doctest.github @@ -253,32 +253,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -288,20 +308,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | @@ -411,7 +417,7 @@ jobs: - name: cache (tools) uses: actions/cache/restore@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-2c3ba78a + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ae4cd18b path: ~/.haskell-ci-tools - name: install cabal-plan run: | @@ -430,7 +436,7 @@ jobs: if: always() uses: actions/cache/save@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-2c3ba78a + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ae4cd18b path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v4 diff --git a/fixtures/empty-line.github b/fixtures/empty-line.github index f0a37bbe..9ec20f2d 100644 --- a/fixtures/empty-line.github +++ b/fixtures/empty-line.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/enabled-jobs.github b/fixtures/enabled-jobs.github index 58590c4e..07da5776 100644 --- a/fixtures/enabled-jobs.github +++ b/fixtures/enabled-jobs.github @@ -253,32 +253,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -288,20 +308,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/fail-versions.github b/fixtures/fail-versions.github index 680f55ae..f25586a7 100644 --- a/fixtures/fail-versions.github +++ b/fixtures/fail-versions.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/irc-channels.github b/fixtures/irc-channels.github index fba57f37..3845f126 100644 --- a/fixtures/irc-channels.github +++ b/fixtures/irc-channels.github @@ -135,32 +135,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -170,20 +190,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/messy.github b/fixtures/messy.github index 0a44d5a1..c6505f62 100644 --- a/fixtures/messy.github +++ b/fixtures/messy.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev apt-get install -y fftw3-dev - name: Install GHCup run: | @@ -144,20 +164,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/psql.github b/fixtures/psql.github index 3c554516..58b7e938 100644 --- a/fixtures/psql.github +++ b/fixtures/psql.github @@ -114,32 +114,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -149,20 +169,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/fixtures/travis-patch.github b/fixtures/travis-patch.github index c792e6f6..e5f0845f 100644 --- a/fixtures/travis-patch.github +++ b/fixtures/travis-patch.github @@ -108,32 +108,52 @@ jobs: compilerVersion: 8.6.1 setup-method: ghcup allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.3 + compilerKind: ghc + compilerVersion: 8.4.3 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.2 + compilerKind: ghc + compilerVersion: 8.4.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.4.1 + compilerKind: ghc + compilerVersion: 8.4.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.1 compilerKind: ghc compilerVersion: 8.2.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.1 compilerKind: ghc compilerVersion: 8.0.1 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt-get install run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev - name: Install GHCup run: | mkdir -p "$HOME/.ghcup/bin" @@ -143,20 +163,6 @@ jobs: run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - - name: Install GHC (hvr-ppa) - if: matrix.setup-method == 'hvr-ppa' - run: | - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - name: Install GHC (GHCup) if: matrix.setup-method == 'ghcup' run: | diff --git a/haskell-ci.cabal b/haskell-ci.cabal index e9396dcc..858deeb5 100644 --- a/haskell-ci.cabal +++ b/haskell-ci.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: haskell-ci -version: 0.19.20241111 +version: 0.19.20241114 synopsis: Cabal package script generator for Travis-CI description: Script generator (@haskell-ci@) for @@ -149,6 +149,7 @@ library haskell-ci-internal HaskellCI.Package HaskellCI.ParsecUtils HaskellCI.Prelude + HaskellCI.SetupMethod HaskellCI.Sh HaskellCI.ShVersionRange HaskellCI.TestedWith @@ -238,3 +239,4 @@ test-suite golden , Diff ^>=0.4.0 || ^>=0.5 , tasty ^>=1.4.1 || ^>=1.5 , tasty-golden ^>=2.3.1.1 + , tasty-hunit \ No newline at end of file diff --git a/src/HaskellCI/Config/Grammar.hs b/src/HaskellCI/Config/Grammar.hs index 167ad7e0..17c69e9a 100644 --- a/src/HaskellCI/Config/Grammar.hs +++ b/src/HaskellCI/Config/Grammar.hs @@ -29,12 +29,24 @@ import HaskellCI.Config.Ubuntu import HaskellCI.GrammarDefault import HaskellCI.Newtypes import HaskellCI.OptionsGrammar +import HaskellCI.SetupMethod import HaskellCI.TestedWith ------------------------------------------------------------------------------- -- Grammar ------------------------------------------------------------------------------- +setupMethodsGrammar :: OptionsGrammar c g => PerSetupMethod VersionRange -> g (PerSetupMethod VersionRange) (PerSetupMethod VersionRange) +setupMethodsGrammar def = pure PerSetupMethod + <*> rangeField "hvr-ppa-jobs" (field @"hvrPpa") def + ^^^ metahelp "RANGE" "(Linux) jobs to use hvr-ppa to install ghc" + <*> rangeField "ghcup-jobs" (field @"ghcup") def + ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup to install ghc" + <*> rangeField "ghcup-vanilla-jobs" (field @"ghcupVanilla") def + ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup-vanilla to install ghc" + <*> rangeField "ghcup-prerelease-jobs" (field @"ghcupPrerelease") def + ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup-prerelease to install ghc" + configGrammar :: ( OptionsGrammar c g , c Components @@ -138,15 +150,8 @@ configGrammar = Config ^^^ metahelp "RANGE" "Jobs to additionally build with OSX" <*> booleanFieldDef "ghcup-cabal" (field @"cfgGhcupCabal") defaultConfig ^^^ help "Use (or don't) ghcup to install cabal" - <*> rangeField "hvr-ppa-jobs" (field @"cfgHvrPpaJobs") defaultConfig - ^^^ metahelp "RANGE" "(Linux) jobs to use hvr-ppa to install ghc" - <*> rangeField "ghcup-jobs" (field @"cfgGhcupJobs") defaultConfig - ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup to install ghc" - <*> rangeField "ghcup-vanilla-jobs" (field @"cfgGhcupVanillaJobs") defaultConfig - ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup-vanilla to install ghc" - <*> rangeField "ghcup-prerelease-jobs" (field @"cfgGhcupPrereleaseJobs") defaultConfig - ^^^ metahelp "RANGE" "(Linux) jobs to use ghcup-prerelease to install ghc" - <*> optionalFieldDef "ghcup-version" (field @"cfgGhcupVersion") defaultConfig + <*> blurFieldGrammar (field @"cfgSetupMethods") setupMethodsGrammar defaultConfig + <*> optionalFieldDef "ghcup-version" (field @"cfgGhcupVersion") defaultConfig ^^^ metahelp "VERSION" "ghcup version" <*> monoidalFieldAla "apt" (alaSet' C.NoCommaFSep C.Token') (field @"cfgApt") ^^^ metahelp "PKG" "Additional apt packages to install" diff --git a/src/HaskellCI/Config/History.hs b/src/HaskellCI/Config/History.hs index b3c41225..e2e027b7 100644 --- a/src/HaskellCI/Config/History.hs +++ b/src/HaskellCI/Config/History.hs @@ -12,12 +12,10 @@ import qualified Distribution.Version as C import HaskellCI.Config.Initial import HaskellCI.Config.Type import HaskellCI.Config.Ubuntu +import HaskellCI.SetupMethod import HaskellCI.Compiler (invertVersionRange) -ghcupNormalRange :: VersionRange -ghcupNormalRange = C.laterVersion (mkVersion [8,4,4]) - configHistory :: [([Int], Config -> Config)] configHistory = [ ver 0 19 20240414 := \cfg -> cfg @@ -34,10 +32,19 @@ configHistory = , ver 0 19 20240708 := \cfg -> cfg & field @"cfgGhcupVersion" .~ C.mkVersion [0,1,30,0] , ver 0 19 20241111 := \cfg -> cfg - & field @"cfgHvrPpaJobs" .~ C.earlierVersion (C.mkVersion [8,4]) - & field @"cfgGhcupJobs" .~ C.simplifyVersionRange (C.intersectVersionRanges (C.intersectVersionRanges ghcupNormalRange (C.earlierVersion (C.mkVersion [9,12,0]))) (invertVersionRange (C.withinVersion (C.mkVersion [9,8,3])))) - & field @"cfgGhcupVanillaJobs" .~ C.withinVersion (C.mkVersion [9,8,3]) - & field @"cfgGhcupPrereleaseJobs" .~ C.orLaterVersion (C.mkVersion [9,12,0]) + & field @"cfgSetupMethods" .~ PerSetupMethod + { hvrPpa = C.earlierVersion (C.mkVersion [8,4]) + , ghcup = C.simplifyVersionRange (C.laterVersion (C.mkVersion [8,4,4]) \/ C.earlierVersion (C.mkVersion [9,12,0]) \/ invertVersionRange (C.withinVersion (C.mkVersion [9,8,3]))) + , ghcupVanilla = C.withinVersion (C.mkVersion [9,8,3]) + , ghcupPrerelease = C.orLaterVersion (C.mkVersion [9,12,0]) + } + , ver 0 19 2024114 := \cfg -> cfg + & field @"cfgSetupMethods" .~ PerSetupMethod + { hvrPpa = C.noVersion + , ghcup = invertVersionRange (C.withinVersion (C.mkVersion [9,8,3])) /\ C.earlierVersion (C.mkVersion [9,12]) + , ghcupVanilla = C.withinVersion (C.mkVersion [9,8,3]) + , ghcupPrerelease = C.orLaterVersion (C.mkVersion [9,12]) + } ] where ver x y z = [x, y, z] diff --git a/src/HaskellCI/Config/Initial.hs b/src/HaskellCI/Config/Initial.hs index 067057ca..b310569a 100644 --- a/src/HaskellCI/Config/Initial.hs +++ b/src/HaskellCI/Config/Initial.hs @@ -15,6 +15,7 @@ import HaskellCI.Config.Type import HaskellCI.Config.Ubuntu import HaskellCI.Ghcup import HaskellCI.HeadHackage +import HaskellCI.SetupMethod import HaskellCI.TestedWith -- | This is an "initial" configuration. It's meant to stay immutable. @@ -61,10 +62,12 @@ initialConfig = Config , cfgLinuxJobs = anyVersion , cfgMacosJobs = noVersion , cfgGhcupCabal = True - , cfgHvrPpaJobs = noVersion - , cfgGhcupJobs = C.unionVersionRanges (C.intersectVersionRanges (C.laterVersion (mkVersion [8,10,4])) (C.earlierVersion (mkVersion [9]))) (C.laterVersion (mkVersion [9,0,1])) - , cfgGhcupVanillaJobs = noVersion -- TODO -- include GHC-9.8.3 - , cfgGhcupPrereleaseJobs = C.orLaterVersion (mkVersion ([9,11,0])) + , cfgSetupMethods = PerSetupMethod + { hvrPpa = noVersion + , ghcup = C.unionVersionRanges (C.intersectVersionRanges (C.laterVersion (mkVersion [8,10,4])) (C.earlierVersion (mkVersion [9]))) (C.laterVersion (mkVersion [9,0,1])) + , ghcupVanilla = noVersion -- TODO -- include GHC-9.8.3 + , ghcupPrerelease = C.orLaterVersion (mkVersion ([9,11,0])) + } , cfgGhcupVersion = initialGhcupVersion , cfgApt = mempty , cfgTravisPatches = [] diff --git a/src/HaskellCI/Config/Type.hs b/src/HaskellCI/Config/Type.hs index 4a2328bf..c98f3da5 100644 --- a/src/HaskellCI/Config/Type.hs +++ b/src/HaskellCI/Config/Type.hs @@ -18,6 +18,7 @@ import HaskellCI.Config.Installed import HaskellCI.Config.Jobs import HaskellCI.Config.PackageScope import HaskellCI.Config.Ubuntu +import HaskellCI.SetupMethod import HaskellCI.TestedWith ------------------------------------------------------------------------------- @@ -66,10 +67,7 @@ data Config = Config , cfgLinuxJobs :: !VersionRange , cfgMacosJobs :: !VersionRange , cfgGhcupCabal :: !Bool - , cfgHvrPpaJobs :: !VersionRange - , cfgGhcupJobs :: !VersionRange - , cfgGhcupVanillaJobs :: !VersionRange - , cfgGhcupPrereleaseJobs :: !VersionRange + , cfgSetupMethods :: !(PerSetupMethod VersionRange) , cfgGhcupVersion :: !Version , cfgApt :: S.Set String , cfgTravisPatches :: [FilePath] diff --git a/src/HaskellCI/GitHub.hs b/src/HaskellCI/GitHub.hs index 304746c1..ed701cbf 100644 --- a/src/HaskellCI/GitHub.hs +++ b/src/HaskellCI/GitHub.hs @@ -47,6 +47,7 @@ import HaskellCI.Jobs import HaskellCI.List import HaskellCI.MonadErr import HaskellCI.Package +import HaskellCI.SetupMethod import HaskellCI.Sh import HaskellCI.ShVersionRange import HaskellCI.Tools @@ -153,7 +154,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do let whenWithinGhcRange :: Applicative f => VersionRange -> f () -> f () whenWithinGhcRange vr m = when (any (`compilerWithinGhcRange` vr) allVersions) m - whenWithinGhcRange cfgHvrPpaJobs $ githubRunIf' "Install GHC (hvr-ppa)" "matrix.setup-method == 'hvr-ppa'" envEnv $ do + whenWithinGhcRange (index cfgSetupMethods HVRPPA) $ githubRunIf' "Install GHC (hvr-ppa)" "matrix.setup-method == 'hvr-ppa'" envEnv $ do sh "apt-add-repository -y 'ppa:hvr/ghc'" sh "apt-get update" sh $ "apt-get install -y \"$HCNAME\"" @@ -172,15 +173,15 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do tell_env "HCPKG" "$HCPKG" tell_env "HADDOCK" "$HADDOCK" - whenWithinGhcRange cfgGhcupJobs $ githubRunIf' "Install GHC (GHCup)" "matrix.setup-method == 'ghcup'" envEnv $ do + whenWithinGhcRange (index cfgSetupMethods GHCUP) $ githubRunIf' "Install GHC (GHCup)" "matrix.setup-method == 'ghcup'" envEnv $ do sh $ "\"$HOME/.ghcup/bin/ghcup\" install ghc \"$HCVER\" || (cat \"$HOME\"/.ghcup/logs/*.* && false)" ghcupGhcEnv - whenWithinGhcRange cfgGhcupVanillaJobs $ githubRunIf' "Install GHC (GHCup vanilla)" "matrix.setup-method == 'ghcup-vanilla'" envEnv $ do + whenWithinGhcRange (index cfgSetupMethods GHCUPvanilla) $ githubRunIf' "Install GHC (GHCup vanilla)" "matrix.setup-method == 'ghcup-vanilla'" envEnv $ do sh $ "\"$HOME/.ghcup/bin/ghcup\" -s https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.8.yaml install ghc \"$HCVER\" || (cat \"$HOME\"/.ghcup/logs/*.* && false)" ghcupGhcEnv - whenWithinGhcRange cfgGhcupPrereleaseJobs $ githubRunIf' "Install GHC (GHCup prerelease)" "matrix.setup-method == 'ghcup-prerelease'" envEnv $ do + whenWithinGhcRange (index cfgSetupMethods GHCUPprerelease) $ githubRunIf' "Install GHC (GHCup prerelease)" "matrix.setup-method == 'ghcup-prerelease'" envEnv $ do sh "\"$HOME/.ghcup/bin/ghcup\" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml;" sh $ "\"$HOME/.ghcup/bin/ghcup\" install ghc \"$HCVER\" || (cat \"$HOME\"/.ghcup/logs/*.* && false)" ghcupGhcEnv @@ -266,7 +267,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do let toolsConfigHash :: String toolsConfigHash = take 8 $ BS8.unpack $ Base16.encode $ SHA256.hashlazy $ Binary.runPut $ do Binary.put cfgDoctest - Binary.put cfgGhcupJobs -- GHC location affects doctest, e.g + Binary.put cfgSetupMethods when (doctestEnabled) $ githubUses "cache (tools)" "actions/cache/restore@v4" [ ("key", "${{ runner.os }}-${{ matrix.compiler }}-tools-" ++ toolsConfigHash) @@ -539,11 +540,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do , ghmeSetupMethod = sp } | sp <- [GHCUP, GHCUPvanilla, GHCUPprerelease, HVRPPA] - , compilerWithinGhcRange compiler $ case sp of - GHCUP -> cfgGhcupJobs - GHCUPvanilla -> cfgGhcupVanillaJobs - GHCUPprerelease -> cfgGhcupPrereleaseJobs - HVRPPA -> cfgHvrPpaJobs + , compilerWithinGhcRange compiler $ index cfgSetupMethods sp ] | compiler <- reverse $ toList linuxVersions , compiler /= GHCHead -- TODO: Make this work @@ -565,7 +562,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do -- job to be setup with ghcup isGHCUP :: CompilerVersion -> Bool - isGHCUP v = compilerWithinRange v (RangeGHC /\ Range cfgGhcupJobs) + isGHCUP v = compilerWithinRange v (RangeGHC /\ Range (index cfgSetupMethods GHCUP)) -- step primitives githubRun' :: String -> Map.Map String String -> ShM () -> ListBuilder (Either HsCiError GitHubStep) () diff --git a/src/HaskellCI/GitHub/Yaml.hs b/src/HaskellCI/GitHub/Yaml.hs index a7be74c1..433ca7f9 100644 --- a/src/HaskellCI/GitHub/Yaml.hs +++ b/src/HaskellCI/GitHub/Yaml.hs @@ -9,6 +9,7 @@ import qualified Data.Map.Strict as M import HaskellCI.Compiler import HaskellCI.List +import HaskellCI.SetupMethod import HaskellCI.Sh import HaskellCI.YamlSyntax @@ -42,9 +43,6 @@ data GitHubJob = GitHubJob } deriving (Show) -data SetupMethod = HVRPPA | GHCUP | GHCUPvanilla | GHCUPprerelease - deriving Show - data GitHubMatrixEntry = GitHubMatrixEntry { ghmeCompiler :: CompilerVersion , ghmeAllowFailure :: Bool @@ -129,12 +127,6 @@ instance ToYaml GitHubJob where ] item $ "steps" ~> ylistFilt [] (map toYaml $ filter notEmptyStep ghjSteps) -instance ToYaml SetupMethod where - toYaml HVRPPA = "hvr-ppa" - toYaml GHCUP = "ghcup" - toYaml GHCUPvanilla = "ghcup-vanilla" - toYaml GHCUPprerelease = "ghcup-prerelease" - instance ToYaml GitHubMatrixEntry where toYaml GitHubMatrixEntry {..} = ykeyValuesFilt [] [ "compiler" ~> fromString (dispGhcVersion ghmeCompiler) @@ -150,7 +142,7 @@ instance ToYaml GitHubStep where for_ ghsIf $ \if_ -> item $ "if" ~> fromString if_ case ghsStep of - Left GitHubRun {..} -> do + Left GitHubRun {..} -> do item $ "run" ~> fromString (shlistToString ghsRun) item $ "env" ~> mapToYaml ghsEnv diff --git a/src/HaskellCI/Prelude.hs b/src/HaskellCI/Prelude.hs index b2491678..5a8137a8 100644 --- a/src/HaskellCI/Prelude.hs +++ b/src/HaskellCI/Prelude.hs @@ -101,6 +101,15 @@ findMaybe f = foldr (\a b -> f a <|> b) Nothing equivVersionRanges :: C.VersionRange -> C.VersionRange -> Bool equivVersionRanges = on (==) C.asVersionIntervals +-- | Functional dependency variant of @Representable@ class. +class Representable i f | f -> i where + tabulate :: (i -> a) -> f a + index :: f a -> i -> a + +instance Representable a ((->) a) where + tabulate = id + index = ($) + ------------------------------------------------------------------------------- -- Orphans ------------------------------------------------------------------------------- diff --git a/src/HaskellCI/SetupMethod.hs b/src/HaskellCI/SetupMethod.hs new file mode 100644 index 00000000..d5534287 --- /dev/null +++ b/src/HaskellCI/SetupMethod.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE OverloadedStrings #-} +module HaskellCI.SetupMethod ( + SetupMethod (..), + PerSetupMethod (..), +) where + +import HaskellCI.Prelude +import HaskellCI.YamlSyntax + +data SetupMethod = HVRPPA | GHCUP | GHCUPvanilla | GHCUPprerelease + deriving (Eq, Ord, Enum, Bounded, Show) + +instance ToYaml SetupMethod where + toYaml HVRPPA = "hvr-ppa" + toYaml GHCUP = "ghcup" + toYaml GHCUPvanilla = "ghcup-vanilla" + toYaml GHCUPprerelease = "ghcup-prerelease" + +data PerSetupMethod a = PerSetupMethod + { hvrPpa :: a + , ghcup :: a + , ghcupVanilla :: a + , ghcupPrerelease :: a + } + deriving (Show, Functor, Foldable, Traversable, Generic, Binary) + +instance Representable SetupMethod PerSetupMethod where + index f HVRPPA = hvrPpa f + index f GHCUP = ghcup f + index f GHCUPvanilla = ghcupVanilla f + index f GHCUPprerelease = ghcupPrerelease f + + tabulate f = PerSetupMethod + { hvrPpa = f HVRPPA + , ghcup = f GHCUP + , ghcupVanilla = f GHCUPvanilla + , ghcupPrerelease = f GHCUPprerelease + } diff --git a/test/Tests.hs b/test/Tests.hs index add7f169..043c87d6 100644 --- a/test/Tests.hs +++ b/test/Tests.hs @@ -1,44 +1,79 @@ {-# LANGUAGE ViewPatterns #-} module Main (main) where -import Prelude () -import Prelude.Compat +import HaskellCI hiding (main) +import HaskellCI.Prelude -import HaskellCI hiding (main) - -import Control.Arrow (first) import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff) -import Distribution.Utils.Generic (fromUTF8BS) import System.Directory (setCurrentDirectory) import System.FilePath (addExtension) import Test.Tasty (TestName, TestTree, defaultMain, testGroup) import Test.Tasty.Golden.Advanced (goldenTest) +import Test.Tasty.HUnit (assertEqual, testCase, (@?=)) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS8 +import qualified Distribution.Version as C import qualified System.Console.ANSI as ANSI +import HaskellCI.Config.History +import HaskellCI.SetupMethod + main :: IO () main = do setCurrentDirectory "fixtures/" - defaultMain $ testGroup "fixtures" - [ fixtureGoldenTest "all-versions" - , fixtureGoldenTest "empty-line" - , fixtureGoldenTest "fail-versions" - , fixtureGoldenTest "irc-channels" - , fixtureGoldenTest "messy" - , fixtureGoldenTest "psql" - , fixtureGoldenTest "travis-patch" - , fixtureGoldenTest "enabled-jobs" - , fixtureGoldenTest "doctest" - , fixtureGoldenTest "doctest-version" - , testGroup "copy-fields" - [ fixtureGoldenTest "copy-fields-all" - , fixtureGoldenTest "copy-fields-some" - , fixtureGoldenTest "copy-fields-none" + defaultMain $ testGroup "haskell-ci" + [ testGroup "fixtures" + [ fixtureGoldenTest "all-versions" + , fixtureGoldenTest "empty-line" + , fixtureGoldenTest "fail-versions" + , fixtureGoldenTest "irc-channels" + , fixtureGoldenTest "messy" + , fixtureGoldenTest "psql" + , fixtureGoldenTest "travis-patch" + , fixtureGoldenTest "enabled-jobs" + , fixtureGoldenTest "doctest" + , fixtureGoldenTest "doctest-version" + , testGroup "copy-fields" + [ fixtureGoldenTest "copy-fields-all" + , fixtureGoldenTest "copy-fields-some" + , fixtureGoldenTest "copy-fields-none" + ] + ] + , testGroup "setup-methods" + -- we test that haskell-ci default configuration setup-methods + -- * span all possible GHC version + -- * have only one setup-method per version, i.e. setup-methods have disjoint GHC versions spans + -- + [ testCase "span-whole-range" $ do + let methods :: PerSetupMethod C.VersionRange + methods = cfgSetupMethods defaultConfig + + let vr = simplify $ foldr (\/) C.noVersion methods + + vr @?= C.anyVersion + + , testCase "disjoint" $ do + let methods :: PerSetupMethod VersionRange + methods = cfgSetupMethods defaultConfig + + let indices :: [(SetupMethod,SetupMethod)] + indices = pairs [minBound .. maxBound] + + for_ indices $ \(i, j) -> do + let x = index methods i + let y = index methods j + assertEqual (show (i, j)) C.noVersion (simplify (x /\ y)) ] ] +simplify :: VersionRange -> VersionRange +simplify = C.fromVersionIntervals . C.toVersionIntervals + +pairs :: [a] -> [(a,a)] +pairs [] = [] +pairs (x:xs) = map ((,) x) xs ++ pairs xs + -- | -- @ -- travisFromConfigFile ::