Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. #242

Merged
merged 7 commits into from
Jul 4, 2024
Merged

Misc. #242

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
matrix:
os: [ubuntu-latest]
ghc:
- "8.8"
- "8.10"
- "9.0"
- "9.2"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.hpc
cabal-dev/
cabal.sandbox.config
cabal.project.local
dist*/
docs/templates/out
site_key.txt
Expand All @@ -27,3 +28,6 @@ test/test-snap-exe
.ghc.environment*
/.stack-work/
/stack*.yaml.lock
/.envrc
/.direnv
/haddocks
40 changes: 16 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -23,45 +22,38 @@ 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/`.

## Building with Nix

## Building the testsuite

To build the test suite, run
A Nix shell is provided and can be entered using `nix-shell`.

$ cabal clean
$ cabal configure --enable-tests --enable-library-coverage
$ cabal build
$ cabal install --enable-tests
If using `nix-direnv`, run the following:

From here you can invoke the testsuite by running:
```sh
echo 'use nix' > .envrc && direnv allow
```

$ ./runTestsAndCoverage.sh
## Building the Haddock Documentation

The haddock documentation can either be built for _snap_ using `cabal haddock snap`, or for the git
submodules as well using `cabal haddock-project`.

The testsuite generates an `hpc` test coverage report in `dist/hpc`.
## Building the testsuite

Build and run the test suite using `cabal test all`.

## Roadmap to Understanding Snaplets

Expand Down
17 changes: 16 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion deps/heist
2 changes: 1 addition & 1 deletion deps/io-streams-haproxy
2 changes: 1 addition & 1 deletion deps/snap-core
2 changes: 1 addition & 1 deletion deps/snap-server
2 changes: 1 addition & 1 deletion deps/xmlhtml
59 changes: 59 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 0 additions & 9 deletions init-sandbox.sh

This file was deleted.

2 changes: 2 additions & 0 deletions runTestsAndCoverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
62 changes: 62 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -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
];
}
5 changes: 2 additions & 3 deletions snap.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading