Skip to content

Commit 0e36b74

Browse files
committed
Sets up flipstone-esque local development and CI
This does not include a `stack-base.yaml`. Instead `stack.yaml` is provided for backwards compatibility with mainline `stack` because this package has been released. Once `!include` is available in a released version of `stack`, we can change this to use the `stack-base.yaml` pattern.
1 parent 341fdde commit 0e36b74

34 files changed

+357
-90
lines changed

.cirrus.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref_name }}
8+
cancel-in-progress: ${{ github.ref_name != 'main' }}
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
find-stack-yamls:
16+
name: Find stack.yamls for GHC Matrix
17+
runs-on: ubuntu-22.04
18+
outputs:
19+
stack-yamls: ${{ steps.set-output.outputs.stack-yamls }}
20+
steps:
21+
- name: Find Stack Yamls
22+
id: set-output
23+
uses: flipstone/github-actions/find-stack-ghc-yamls@bef3396e6c3777767d1d4837203cfdb2635b4933
24+
25+
build:
26+
name: Build and Test
27+
needs: find-stack-yamls
28+
runs-on: ubuntu-22.04
29+
strategy:
30+
max-parallel: 5
31+
matrix:
32+
stack-yaml: ${{ fromJson(needs.find-stack-yamls.outputs.stack-yamls) }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Cache
39+
uses: actions/cache@v4
40+
env:
41+
cache-version: v3
42+
with:
43+
key: ${{ env.cache-version }}-${{ matrix.stack-yaml }}-${{ hashFiles(matrix.stack-yaml, 'stack-base.yaml', 'package.yaml') }}
44+
restore-keys: |
45+
${{ env.cache-version }}-${{ matrix.stack-yaml }}-
46+
path: |
47+
./stack-root
48+
49+
- name: Setup Stack
50+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
51+
with:
52+
stack-root: ./stack-root
53+
54+
- name: Build and test
55+
run: ./scripts/test --stack-yaml ${{ matrix.stack-yaml }}
56+
57+
cabal-check:
58+
name: Cabal Check
59+
runs-on: ubuntu-22.04
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Stack (for docker env)
65+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
66+
with:
67+
stack-root: ./stack-root
68+
69+
- name: Check for Hackage releasable issues
70+
run: docker compose run --rm dev cabal check
71+
72+
shellcheck:
73+
name: shellcheck
74+
runs-on: ubuntu-22.04
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Stack (for docker env)
80+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
81+
with:
82+
stack-root: ./stack-root
83+
84+
- name: Format and Check for Diff
85+
run: scripts/shellcheck
86+
87+
cabal-latest-build:
88+
name: Cabal Build
89+
runs-on: ubuntu-22.04
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
94+
- name: Setup Stack (for docker env)
95+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
96+
with:
97+
stack-root: ./stack-root
98+
99+
- name: Build with cabal and latest ghc+deps
100+
# When a new ghc version is released, we might not be able to build all the dependencies for
101+
# a little while. So we need to allow failure here. It is a very unfortunate situation that
102+
# github does not give us a better UX for this as the closest thing to a required check is
103+
# not configured here, but seemingly only through the api/webui for "branch protection"
104+
continue-on-error: true
105+
run: scripts/cabal-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.stack-work
22
dist-newstyle
3+
test-all-logs
4+
.env

Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
dev:
3+
image: ghcr.io/flipstone/haskell-tools:debian-ghc-9.6.6-54c3115
4+
volumes:
5+
- .:${PROJECT_DIR}
6+
- flipstone_stack_root:/stack-root
7+
environment:
8+
STACK_ROOT: /stack-root
9+
IN_DEV_CONTAINER: 'true'
10+
# Pass through the CI variable from GitHub (or set it to `true` locally
11+
# for debugging CI builds)
12+
CI:
13+
working_dir: ${PROJECT_DIR}
14+
tty: true
15+
16+
volumes:
17+
flipstone_stack_root:
18+
external: true

non-empty-text.cabal

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.35.2.
3+
-- This file has been generated from package.yaml by hpack version 0.38.1.
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: 31f29e2afdc641f83475d8957a7eb8b14f1cb8c80780a100049e72a7ccc91684
7+
-- hash: fec44e5211fe675e5a37ea4993b6ebb7e78ba649413df46f2c5d1a40bbef1073
88

99
name: non-empty-text
1010
version: 0.2.1
@@ -20,7 +20,7 @@ license: MIT
2020
license-file: LICENSE
2121
build-type: Simple
2222
tested-with:
23-
GHC == 8.8.4, GHC == 8.10.7
23+
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.4.7, GHC == 9.6.7, GHC == 9.8.4, GHC == 9.10.2
2424
extra-source-files:
2525
CHANGELOG.md
2626

@@ -47,6 +47,8 @@ library
4747
default-language: Haskell2010
4848
if flag(ci)
4949
ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-patterns -Wincomplete-record-updates -Wmissing-local-signatures -Wmissing-export-lists -Wmissing-import-lists -Wnoncanonical-monad-instances -Wredundant-constraints -Wpartial-fields -Wmissed-specialisations -Wno-implicit-prelude -Wno-safe -Wno-unsafe
50+
if impl (ghc >= 9.8)
51+
ghc-options: -Wterm-variable-capture -Wextended-warnings
5052
else
5153
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates
5254

package.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ author: Antoine Catton, Trevis Elser
99
maintainer: Trevis Elser <[email protected]>
1010
github: flipstone/haskell-non-empty-text
1111
license: MIT
12-
tested-with: GHC == 8.8.4, GHC == 8.10.7
12+
tested-with:
13+
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.4.7, GHC == 9.6.7, GHC == 9.8.4, GHC == 9.10.2
1314

1415
flags:
1516
ci:
@@ -51,6 +52,11 @@ library:
5152
- -Wno-implicit-prelude
5253
- -Wno-safe
5354
- -Wno-unsafe
55+
when:
56+
- condition: impl (ghc >= 9.8)
57+
ghc-options:
58+
- -Wterm-variable-capture
59+
- -Wextended-warnings
5460
else:
5561
ghc-options:
5662
- -Wall

scripts/bootstrap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
if docker volume inspect flipstone_stack_root >/dev/null 2>/dev/null; then
6+
echo "Skipping creation of flipstone_stack_root docker volume. It already exists"
7+
else
8+
echo "Creating flipstone_stack_root docker network"
9+
docker volume create flipstone_stack_root
10+
fi
11+
12+
if [ -f .env ]; then
13+
echo "Skipping creation of .env because it already exists. Remove it if you want to this script to recreate it"
14+
else
15+
echo "PROJECT_DIR=$PWD" >> .env
16+
fi
17+
18+
if [ "$EXIT_FAILURE" != "" ]; then
19+
exit 1
20+
fi

scripts/build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
./scripts/test-all

scripts/cabal-latest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
. scripts/lib/run-in-container.sh
6+
7+
ghcup install ghc latest --set
8+
9+
cabal update
10+
cabal test --flag ci

0 commit comments

Comments
 (0)