Skip to content
Merged
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
50 changes: 9 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
name: "Build"

permissions:
contents: read
pages: write
id-token: write

name: "Test"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

push:
jobs:
build:
tests:
runs-on: ubuntu-latest
container:
image: "docker://ghcr.io/chrisdone/hell-build:2025-03-04@sha256:ca21e3be038cf1f10fa18306123b4d5f0e2009fe8938cea3afcef7f900bbea71"

env:
# For the ~/.stack root.
HOME: /root/
STACK_ROOT: /root/.stack

# This can be both of these, depending on whether it's a PR or
# main. GitHub Actions is weird.
#
# * "GIT_BRANCH=refs/heads/main"
# * "GIT_BRANCH=cd/2024-08-28-check-examples"
#
GIT_BRANCH: ${{ github.head_ref || github.ref }}

steps:
- run: |
git clone https://github.com/chrisdone/hell /tmp/hell && \
cd /tmp/hell && \
git checkout $GIT_BRANCH
- run: |
cd /tmp/hell && stack build --fast
- run: |
cd /tmp/hell && stack exec hell scripts/check-examples.hell
- run: |
cd /tmp/hell && HOME=/home/chris/ stack exec hell scripts/check-docs.hell
- uses: actions/checkout@v5
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix build
- run: nix flake check
9 changes: 9 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
pkgs.zlib
];
};
checks = {
run-script-check = pkgs.runCommand "test-hell-script" {
buildInputs = [ app ];
} ''
hell ${./scripts/check.hell} --dir ${./examples} --dir ${./scripts}
touch $out
'';
build = app;
};
packages = {
default = app;
static-arm64 = mkStaticApp pkgsStaticArm64;
Expand Down
10 changes: 0 additions & 10 deletions scripts/check-examples.hell

This file was deleted.

14 changes: 8 additions & 6 deletions scripts/check.hell
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
data Opts = Opts {
dirs :: [Text],
compilerStats :: Bool
}

options =
(\compilerStats -> Main.Opts { compilerStats })
<$> Options.switch (Flag.long "compiler-stats" <> Flag.help "Pass --compiler-stats in?")
(\dirs compilerStats -> Main.Opts { compilerStats, dirs })
<$> Alternative.many (Options.strOption (Option.long "dir" <> Option.help "Directory to check"))
<*> Options.switch (Flag.long "compiler-stats" <> Flag.help "Pass --compiler-stats in?")

main = do
opts <- Options.execParser (Options.info (Main.options <**> Options.helper) Options.fullDesc)
let extra = if Record.get @"compilerStats" opts
then ["--compiler-stats"]
else []
let dirs = Record.get @"dirs" opts
let list = \dir ->
Functor.fmap (List.filter (Text.isSuffixOf ".hell") . List.map (\x -> dir <> x))
Functor.fmap (List.filter (Text.isSuffixOf ".hell") . List.map (\x -> dir <> "/" <> x))
$ Directory.listDirectory dir
examples <- list "examples/"
scripts <- list "scripts/"
Async.pooledForConcurrently (examples <> scripts) \fp -> do
examples <- Functor.fmap List.concat $ Monad.mapM list dirs
Async.pooledForConcurrently examples \fp -> do
Text.putStrLn $ Text.concat ["Checking ", fp]
Process.runProcess_ (Process.proc "hell" (["--check", fp] <> extra))
Text.putStrLn "All OK."
62 changes: 0 additions & 62 deletions scripts/readme.md

This file was deleted.

1 change: 1 addition & 0 deletions src/Hell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,7 @@ polyLits =

-- Alternative operations
"Alternative.optional" (optional) :: forall (f :: Type -> Type) a. (Alternative f) => f a -> f (Maybe a)
"Alternative.many" (many) :: forall (f :: Type -> Type) a. (Alternative f) => f a -> f [a]

-- Monadic operations
"Monad.mapM_" mapM_ :: forall a (m :: Type -> Type). (Monad m) => (a -> m ()) -> [a] -> m ()
Expand Down