diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index b7685264..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,87 +0,0 @@ -name: "CI" -on: - push: - branches: - - main - pull_request: - -jobs: - build-test: - name: "Build & test" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - repository: input-output-hk/quickcheck-dynamic - # On pull_request events, we want to check out the latest commit of the - # PR, which is different to github.ref (the default, which would point - # to a "fake merge" commit). On push events, the default is fine as it - # refers to the pushed commit. - ref: ${{ github.event.pull_request.head.sha || github.ref }} - # Also ensure we have all history with all tags - fetch-depth: 0 - - - name: Prepare nix - uses: cachix/install-nix-action@v31 - with: - extra_nix_config: | - accept-flake-config = true - log-lines = 1000 - - - name: Github cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle - uses: actions/cache@v4 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: | - cabal-${{ runner.os }}-${{ hashFiles('cabal.project', 'default.nix', 'shell.nix') }} - restore-keys: | - cabal-${{ runner.os }}-${{ hashFiles('cabal.project', 'default.nix', 'shell.nix') }} - - - name: Enter nix shell - uses: nicknovitski/nix-develop@v1 - - - name: Formatting - run: - fourmolu --mode check . - - - name: Build - run: | - cabal update - cabal build all --ghc-options=-Werror - - - name: Test - run: - cabal test all - - - name: Documentation (Haddock) - run: | - .github/workflows/ci-haddock.sh - - - name: Upload Documentation - uses: actions/upload-artifact@v4 - with: - name: haddocks - path: ./docs - - documentation: - name: Documentation - needs: [build-test] - runs-on: ubuntu-latest - steps: - - name: Download generated documentation - uses: actions/download-artifact@v4 - with: - name: haddocks - path: docs - - - name: Publish Documentation - if: github.event_name == 'push' - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN || github.token }} - publish_dir: docs/ - enable_jekyll: true - force_orphan: true diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml new file mode 100644 index 00000000..b6105b4c --- /dev/null +++ b/.github/workflows/haskell-ci.yml @@ -0,0 +1,105 @@ +name: Haskell-CI +permissions: + contents: read + +on: + push: + branches: + - 'main' + pull_request: + branches: + - 'main' + schedule: + - cron: 0 0 * * * + workflow_dispatch: + inputs: + nightly: + description: Run with the same settings as a nightly build + type: boolean + default: false + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check-formatting: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: install fourmolu + run: | + wget https://github.com/fourmolu/fourmolu/releases/download/v0.17.0.0/fourmolu-0.17.0.0-linux-x86_64 + chmod +x fourmolu-0.17.0.0-linux-x86_64 + mv fourmolu-0.17.0.0-linux-x86_64 fourmolu + - run: ./fourmolu -c . + + test-with-cabal: + name: Haskell-CI - Linux - ${{ matrix.ghc-version }} + + strategy: + matrix: + ghc-version: [latest, 9.12, "9.10", 9.8, 9.6, 9.4, 9.2, 9.0, "8.10"] + os: [ubuntu-latest] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - name: Set NIGHTLY environment variable if the job was triggered by the scheduler + if: "${{ github.event_name == 'schedule' + || contains(github.event.pull_request.title, 'nightly') + || contains(github.event.pull_request.title, 'NIGHTLY') + || github.event_name == 'workflow_dispatch' && github.event.inputs.nightly }}" + run: | + echo "NIGHTLY=true" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + with: + ghc-version: ${{matrix.ghc-version}} + - uses: actions/cache/restore@v4 + with: + key: ${{ matrix.os }}-${{ matrix.ghc-version }}-${{ github.sha }} + path: ~/.cabal/store + restore-keys: ${{ matrix.os }}-${{ matrix.ghc-version }}- + - run: cabal build all + - run: cabal test all + + - name: Documentation (Haddock) + if: "${{ matrix.ghc-version == 'latest' }}" + run: | + .github/workflows/ci-haddock.sh + + - name: Upload Documentation + if: "${{ matrix.ghc-version == 'latest' }}" + uses: actions/upload-artifact@v4 + with: + name: haddocks + path: ./docs + + - uses: actions/cache/save@v4 + with: + key: ${{ matrix.os }}-${{ matrix.ghc-version }}-${{ github.sha }} + path: ~/.cabal/store + + documentation: + name: Documentation + needs: [test-with-cabal] + runs-on: ubuntu-latest + steps: + - name: Download generated documentation + uses: actions/download-artifact@v4 + with: + name: haddocks + path: docs + + - name: Publish Documentation + if: github.event_name == 'push' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN || github.token }} + publish_dir: docs/ + enable_jekyll: true + force_orphan: true diff --git a/quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs b/quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs index 0b41933e..ec01cbf7 100644 --- a/quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs +++ b/quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs @@ -592,9 +592,11 @@ keepTryingUntil n g p = do shrinkDLTest :: DynLogicModel s => DynLogic s -> DynLogicTest s -> [DynLogicTest s] shrinkDLTest _ (Looping _) = [] shrinkDLTest d tc = - [ test | as' <- shrinkScript d (getScript tc), let pruned = pruneDLTest d as' - test = makeTestFromPruned d pruned, - -- Don't shrink a non-executable test case to an executable one. + [ test + | as' <- shrinkScript d (getScript tc) + , let pruned = pruneDLTest d as' + test = makeTestFromPruned d pruned + , -- Don't shrink a non-executable test case to an executable one. case (tc, test) of (DLScript _, _) -> True (_, DLScript _) -> False @@ -619,10 +621,10 @@ shrinkScript = shrink' initialAnnotatedState [TestSeqStep (unsafeCoerceVar var := act') ss | Some act'@ActionWithPolarity{} <- computeShrinkAction s act] ++ [ TestSeqStep step ss' | ss' <- - shrink' - (nextStateStep step s) - (stepDLStep d s step) - ss + shrink' + (nextStateStep step s) + (stepDLStep d s step) + ss ] nonstructural _ _ TestSeqStop = [] diff --git a/quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs b/quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs index daccbbcf..5c801da8 100644 --- a/quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs +++ b/quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs @@ -286,7 +286,8 @@ instance Show Polarity where show PosPolarity = "+" show NegPolarity = "-" -data ActionWithPolarity state a = Eq (Action state a) => +data ActionWithPolarity state a + = Eq (Action state a) => ActionWithPolarity { polarAction :: Action state a , polarity :: Polarity