From 0a02e3d9205975a0c6c1579a04e0af3801b682c1 Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:13:33 -0700 Subject: [PATCH 1/7] Update CI --- .github/workflows/ci.yml | 1 - snap.cabal | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50a77235..bc36844f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,6 @@ jobs: matrix: os: [ubuntu-latest] ghc: - - "8.8" - "8.10" - "9.0" - "9.2" diff --git a/snap.cabal b/snap.cabal index 261758d6..71ff2f68 100644 --- a/snap.cabal +++ b/snap.cabal @@ -35,12 +35,11 @@ bug-reports: https://github.com/snapframework/snap/issues category: Web, Snap tested-with: - GHC == 8.8.4 GHC == 8.10.7 GHC == 9.0.2 GHC == 9.2.8 - GHC == 9.4.5 - GHC == 9.6.5 + GHC == 9.4.8 + GHC == 9.6.6 GHC == 9.8.2 GHC == 9.10.1 From 63122bb39c090facd638b694f8ec5f63728f6cfb Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:41:26 -0700 Subject: [PATCH 2/7] Update readme and remove bit rot --- README.md | 34 ++++++++-------------------------- init-sandbox.sh | 9 --------- runTestsAndCoverage.sh | 2 ++ 3 files changed, 10 insertions(+), 35 deletions(-) delete mode 100755 init-sandbox.sh diff --git a/README.md b/README.md index 155693cd..96870f92 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Snap Framework [![Hackage Status](https://img.shields.io/hackage/v/snap.svg)](https://hackage.haskell.org/package/snap) -============== +# Snap Framework [![Hackage Status](https://img.shields.io/hackage/v/snap.svg)](https://hackage.haskell.org/package/snap) [![GitHub CI](https://github.com/snapframework/snap/workflows/CI/badge.svg)](https://github.com/snapframework/snap/actions) @@ -23,45 +22,28 @@ be a part of this package. As of version 1.0, the snap command-line utility is no longer provided by this package. It is now provided by the package [`snap-templates`](https://github.com/snapframework/snap-templates). -Building snap -============= +# Building snap After you clone the repository, change to the newly created snap directory and run git submodule update --init --recursive - ./init-sandbox.sh - cabal install + cabal build all (You may want to look at pull.sh or pullLatestMaster.sh.) -This updates all the Snap Framework dependencies to the correct version, -creates a sandbox, and installs everything. The snap library is built using +This updates all the Snap Framework dependencies to the correct version. +The snap library is built using [Cabal](http://www.haskell.org/cabal/) and [Hackage](http://hackage.haskell.org/packages/hackage.html). ## Building the Haddock Documentation -The haddock documentation can be built using 'cabal haddock'. - -The docs get put in `dist/doc/html/`. - +The haddock documentation can either be built for _snap_ using `cabal haddock snap`, or for the git +submodules as well using `cabal haddock-project`. ## Building the testsuite -To build the test suite, run - - $ cabal clean - $ cabal configure --enable-tests --enable-library-coverage - $ cabal build - $ cabal install --enable-tests - -From here you can invoke the testsuite by running: - - $ ./runTestsAndCoverage.sh - - -The testsuite generates an `hpc` test coverage report in `dist/hpc`. - +Build and run the test suite using `cabal test all`. ## Roadmap to Understanding Snaplets diff --git a/init-sandbox.sh b/init-sandbox.sh deleted file mode 100755 index fe260175..00000000 --- a/init-sandbox.sh +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -cabal sandbox init -cabal sandbox add-source deps/io-streams -cabal sandbox add-source deps/io-streams-haproxy -cabal sandbox add-source deps/snap-core -cabal sandbox add-source deps/snap-server -cabal sandbox add-source deps/xmlhtml -cabal sandbox add-source deps/heist diff --git a/runTestsAndCoverage.sh b/runTestsAndCoverage.sh index d3db0baa..703ee342 100755 --- a/runTestsAndCoverage.sh +++ b/runTestsAndCoverage.sh @@ -2,6 +2,8 @@ set -e +# NB: This script has bit rotted and will not work unless one is using GHC 8.2.2. + # # All directory variables relative to project root # DIR=dist-newstyle/hpc # From 8c56b9938aa232fa2305bee2fa4f103752f7569d Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:44:16 -0700 Subject: [PATCH 3/7] Add Nix shell --- .gitignore | 2 ++ README.md | 10 +++++++++ shell.nix | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 29decb17..05dcc49a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ test/test-snap-exe .ghc.environment* /.stack-work/ /stack*.yaml.lock +/.envrc +/.direnv diff --git a/README.md b/README.md index 96870f92..afdab57d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,16 @@ The snap library is built using [Cabal](http://www.haskell.org/cabal/) and [Hackage](http://hackage.haskell.org/packages/hackage.html). +## Building with Nix + +A Nix shell is provided and can be entered using `nix-shell`. + +If using `nix-direnv`, run the following: + +```sh +echo 'use nix' > .envrc && direnv allow +``` + ## Building the Haddock Documentation The haddock documentation can either be built for _snap_ using `cabal haddock snap`, or for the git diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..772f24de --- /dev/null +++ b/shell.nix @@ -0,0 +1,62 @@ +{ + ghcVersion ? "9.8.2", + nixpkgs ? + builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/56fc115880db6498245adecda277ccdb33025bc2.tar.gz"; + sha256 = "0svpqk4zsx104n4m6zgizl4ybxy0j6kxfs1v32p2f1whp0ix6cfg"; + }, + system ? builtins.currentSystem, +}: let + pkgs = import nixpkgs {inherit system;}; + + inherit (pkgs) haskell; + + ghcVersionNix = builtins.replaceStrings ["."] [""] ghcVersion; + + hs = pkgs.haskell.packages."ghc${ghcVersionNix}".extend (final: prev: { + # Disable tests to avoid dependency cycle. + http-streams = haskell.lib.dontCheck prev.http-streams; + # Disable broken tests (forkIO nrOfRunning fails). + threads = haskell.lib.dontCheck prev.threads; + }); + + haskell-language-server-wrapper = pkgs.haskell-language-server.override { + haskellPackages = hs; + supportedGhcVersions = [ghcVersionNix]; + }; + + haskell-language-server-bin = pkgs.writeShellScriptBin "haskell-language-server" '' + exec ${haskell-language-server-wrapper}/bin/haskell-language-server-${ghcVersion} "$@" + ''; + + project = hs.extend (final: prev: { + heist = final.callCabal2nix "heist" deps/heist {}; + io-streams = final.callCabal2nix "io-streams" deps/io-streams {}; + io-streams-haproxy = final.callCabal2nix "io-streams-haproxy" deps/io-streams-haproxy {}; + snap = final.callCabal2nix "snap" ./. {}; + snap-core = final.callCabal2nix "snap-core" deps/snap-core {}; + snap-server = final.callCabal2nix "snap-server" deps/snap-server {}; + xmlhtml = final.callCabal2nix "xmlhtml" deps/xmlhtml {}; + }); +in + project.shellFor { + packages = ps: + with ps; [ + heist + io-streams + io-streams-haproxy + snap + snap-core + snap-server + xmlhtml + ]; + + doBenchmark = true; + + nativeBuildInputs = with pkgs; [ + cabal-install + haskell-language-server-bin + haskell-language-server-wrapper + pandoc + ]; + } From 80a0b0d0b5fd5f83f40e922425148acafbe5fc78 Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:44:32 -0700 Subject: [PATCH 4/7] Update cabal.project --- .gitignore | 1 + cabal.project | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 05dcc49a..15e5754b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ .hpc cabal-dev/ cabal.sandbox.config +cabal.project.local dist*/ docs/templates/out site_key.txt diff --git a/cabal.project b/cabal.project index e879b1f2..66cef503 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,18 @@ packages: . -optional-packages: deps/heist deps/io-streams deps/io-streams-haproxy deps/snap-core deps/snap-server deps/xmlhtml +optional-packages: + deps/heist + deps/io-streams + deps/io-streams-haproxy + deps/snap-core + deps/snap-server + deps/xmlhtml + +package * + ghc-options: -j2 -haddock + +program-options + ghc-options: -j4 +RTS -A128m -n2m -RTS + +tests: True +benchmarks: True From 7cb7f2119ba0a06cb2cfc4c753c5d1e2df83a4ec Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:44:49 -0700 Subject: [PATCH 5/7] Add hie.yaml --- hie.yaml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 hie.yaml diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 00000000..92cbf34f --- /dev/null +++ b/hie.yaml @@ -0,0 +1,59 @@ +cradle: + cabal: + # snap + - path: "src" + component: "lib:snap" + + - path: "test/suite" + component: "snap:test:testsuite" + + # heist + - path: "deps/heist/src" + component: "lib:heist" + + - path: "deps/heist/test/suite" + component: "heist:test:testsuite" + + # io-streams + - path: "deps/io-streams/src" + component: "lib:io-streams" + + - path: "deps/io-streams/test" + component: "io-streams:test:testsuite" + + # io-streams-haproxy + - path: "deps/io-streams-haproxy/src" + component: "lib:io-streams-haproxy" + + - path: "deps/io-streams/test" + component: "io-streams-haproxy:test:testsuite" + + # snap-core + - path: "deps/snap-core/src" + component: "lib:snap-core" + + - path: "deps/snap-core/test" + component: "snap-core:test:testsuite" + + # snap-server + - path: "deps/snap-server/src" + component: "lib:snap-server" + + - path: "deps/snap-server/test" + component: "snap-server:test:testsuite" + + - path: "deps/snap-server/pong" + component: "snap-server:exe:snap-test-pong-server" + + - path: "deps/snap-server/testserver" + component: "snap-server:exe:snap-test-server" + + - path: "deps/snap-server/benchmark" + component: "snap-server:benchmark:benchmark" + + # xmlhtml + - path: "deps/xmlhtml/src" + component: "lib:xmlhtml" + + - path: "deps/xmlhtml/test" + component: "xmlhtml:test:testsuite" From a463b7c9cb86231f739209293b7467661d9ee39b Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:45:12 -0700 Subject: [PATCH 6/7] Ignore haddocks --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 15e5754b..9f87353c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ test/test-snap-exe /stack*.yaml.lock /.envrc /.direnv +/haddocks From c14cf3cc566b9d87cd1ad2ed2a1794802c63ff83 Mon Sep 17 00:00:00 2001 From: cydparser Date: Thu, 4 Jul 2024 16:45:24 -0700 Subject: [PATCH 7/7] Update submodule commits --- deps/heist | 2 +- deps/io-streams-haproxy | 2 +- deps/snap-core | 2 +- deps/snap-server | 2 +- deps/xmlhtml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deps/heist b/deps/heist index fb1c8188..c83c54b6 160000 --- a/deps/heist +++ b/deps/heist @@ -1 +1 @@ -Subproject commit fb1c8188fd346ccd30f095af53654c4af8e7f83c +Subproject commit c83c54b680b7b3bb87df2283ecb80aacde1be82e diff --git a/deps/io-streams-haproxy b/deps/io-streams-haproxy index d7f918d4..9be3b32b 160000 --- a/deps/io-streams-haproxy +++ b/deps/io-streams-haproxy @@ -1 +1 @@ -Subproject commit d7f918d4c462ac25a98563a3c88624c738962952 +Subproject commit 9be3b32ba0dd6b03b0b945f301c5382db79eeda7 diff --git a/deps/snap-core b/deps/snap-core index 64b0fb20..aec49845 160000 --- a/deps/snap-core +++ b/deps/snap-core @@ -1 +1 @@ -Subproject commit 64b0fb20f456fd5a4f9884bb3e9d37ec440ccfd4 +Subproject commit aec49845421ff1bb6fa8b4eb273f67e7e3c9b2fb diff --git a/deps/snap-server b/deps/snap-server index 51c90f6a..a3a6e5ff 160000 --- a/deps/snap-server +++ b/deps/snap-server @@ -1 +1 @@ -Subproject commit 51c90f6aae6117e92d47cc1f896721463e89e8e8 +Subproject commit a3a6e5ff161e66322a1eb260b5d393a3d2c8c3ca diff --git a/deps/xmlhtml b/deps/xmlhtml index 6d46a3e4..588b5bd3 160000 --- a/deps/xmlhtml +++ b/deps/xmlhtml @@ -1 +1 @@ -Subproject commit 6d46a3e4a2c9ee8f55fd434fdc468021fc6cf4d1 +Subproject commit 588b5bd3daf0a5000eeab96febc1783c711dd818