Skip to content

Commit 211e90f

Browse files
committed
First commit
0 parents  commit 211e90f

22 files changed

+1213
-0
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*.hs]
6+
indent_style = space
7+
indent_size = 2
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
charset = utf-8
11+
end_of_line = lf
12+
13+
[LICENSE]
14+
insert_final_newline = false
15+
16+
[Makefile]
17+
indent_style = tab

.github/ISSUE_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* Display version:
2+
* GHC version:
3+
* Cabal version:
4+
5+
Describe what you were trying to get done.
6+
Tell us what happened, what went wrong, and what you expected to happen.
7+

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
# Trigger the workflow on push or pull request, but only for the main branch
4+
on:
5+
pull_request:
6+
push:
7+
branches: ["main"]
8+
9+
jobs:
10+
cabal:
11+
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest]
16+
cabal: ["3.4.0.0"]
17+
ghc: ["8.8.4", "8.10.4", "9.0.1"]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main'
22+
23+
- name: Prepare environment
24+
run: .github/workflows/setup_ci_env.sh
25+
26+
- name: Configure environment
27+
run: |
28+
git config --global http.sslVerify false
29+
echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH"
30+
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
31+
echo "NIX_SSL_CERT_FILE=$cert_file" >> "$GITHUB_ENV"
32+
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
33+
env
34+
35+
- name: Configure Darwin Nixpkgs
36+
if: matrix.os == 'macos-latest'
37+
run: |
38+
echo 'NIX_PATH="nixpkgs=channel:nixpkgs-21.05-darwin"' >> "$GITHUB_ENV"
39+
40+
- name: Configure Linux Nixpkgs
41+
if: matrix.os == 'ubuntu-latest'
42+
run: |
43+
echo 'NIX_PATH="nixpkgs=channel:nixos-21.05"' >> "$GITHUB_ENV"
44+
45+
- name: Set GHC version for Nix
46+
run: |
47+
if [[ ${{matrix.ghc}} == '8.8.4' ]]
48+
then echo "GHC='884'" >> "$GITHUB_ENV"
49+
elif [[ ${{matrix.ghc}} == '8.10.4' ]]
50+
then echo "GHC='8104'" >> "$GITHUB_ENV"
51+
elif [[ ${{matrix.ghc}} == '9.0.1' ]]
52+
then echo "GHC='901'" >> "$GITHUB_ENV"
53+
fi
54+
55+
- name: Install Nix
56+
run: ./.github/workflows/install-nix.sh
57+
58+
- name: Configure
59+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal update && cabal configure --enable-tests --disable-benchmarks --test-show-details=direct --disable-optimization --with-compiler="ghc-${{ matrix.ghc }}"' .github/workflows/shell.nix
60+
61+
- name: Freeze
62+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal freeze' .github/workflows/shell.nix
63+
64+
- uses: actions/cache@v2
65+
name: Cache ~/.cabal/store
66+
with:
67+
path: ~/.cabal/store
68+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}-
69+
70+
- name: Installing dependencies
71+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make deps' .github/workflows/shell.nix
72+
73+
- name: Running hlint
74+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/hlint-runner.sh' .github/workflows/shell.nix
75+
76+
- name: Running stylish-haskell
77+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/stylish-haskell-runner.sh' .github/workflows/shell.nix
78+
79+
- name: Build
80+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make build' .github/workflows/shell.nix
81+
82+
- name: Test
83+
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'cabal test all' .github/workflows/shell.nix

.github/workflows/cpus.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# Originally from:
3+
# https://github.com/blankpage/e5UNIXBuilder/blob/master/build-akili.sh
4+
5+
if [[ "$OSTYPE" =~ "linux-gnu" ]]
6+
then CPUS=$(nproc)
7+
elif [[ "$OSTYPE" =~ "darwin" ]]
8+
then CPUS=2
9+
else CPUS=$(sysctl -n hw.ncpu)
10+
fi
11+
12+
export CPUS

.github/workflows/deploy-docs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: deploy-docs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build:
9+
name: Deploy docs
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout main
13+
uses: actions/checkout@v2
14+
15+
- name: Deploy docs
16+
uses: mhausenblas/mkdocs-deploy-gh-pages@master
17+
# Or use mhausenblas/mkdocs-deploy-gh-pages@nomaterial to build without the mkdocs-material theme
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
CONFIG_FILE: docs/mkdocs.yml
21+
EXTRA_PACKAGES: build-base

.github/workflows/hlint-runner.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
source .github/workflows/cpus.sh
6+
7+
git add .
8+
9+
find src test -name "*.hs" | parallel -j "$CPUS" -- hlint --refactor-options="-i" --refactor {}
10+
11+
git status
12+
13+
set +e
14+
15+
git diff --exit-code
16+
diff_code=$?
17+
18+
if [ $diff_code -ne 0 ]
19+
then
20+
echo "Test Hlint failed"
21+
exit 1
22+
fi

.github/workflows/install-nix.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if type -p nix &>/dev/null ; then
5+
echo "Aborting: Nix is already installed at $(type -p nix)"
6+
exit
7+
fi
8+
9+
# Configure Nix
10+
add_config() {
11+
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null
12+
}
13+
# Set jobs to number of cores
14+
add_config "max-jobs = auto"
15+
# Allow binary caches for user
16+
add_config "trusted-users = root $USER"
17+
18+
# Nix installer flags
19+
installer_options=(
20+
--daemon
21+
--daemon-user-count 4
22+
--no-channel-add
23+
--darwin-use-unencrypted-nix-store-volume
24+
--nix-extra-conf-file /tmp/nix.conf
25+
)
26+
27+
echo "installer options: ${installer_options[@]}"
28+
# On self-hosted runners we don't need to install more than once
29+
if [[ ! -d /nix/store ]]
30+
then
31+
sh <(curl --retry 5 --retry-connrefused -L "https://nixos.org/nix/install") "${installer_options[@]}"
32+
fi
33+
34+
if [[ $OSTYPE =~ darwin ]]; then
35+
# Disable spotlight indexing of /nix to speed up performance
36+
sudo mdutil -i off /nix
37+
38+
# macOS needs certificates hints
39+
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
40+
export NIX_SSL_CERT_FILE=$cert_file
41+
sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file"
42+
fi
43+
44+
# Set paths
45+
46+
# if [[ $INPUT_NIX_PATH != "" ]]; then
47+
# echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
48+
# fi

.github/workflows/setup_ci_env.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
CI_OS=$(uname -s)
6+
7+
install_deps_linux() {
8+
echo "Setting up the environment for linux"
9+
sudo apt-get update
10+
}
11+
12+
install_deps_darwin() {
13+
echo "Setting up the environment for macOS"
14+
brew update
15+
}
16+
17+
case $CI_OS in
18+
Linux) install_deps_linux;;
19+
Darwin) install_deps_darwin;;
20+
esac
21+

.github/workflows/shell.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{ ghcVersion }:
2+
let pkgs = import <nixpkgs> {};
3+
in with pkgs;
4+
mkShell {
5+
buildInputs = [
6+
# Haskell Deps
7+
haskell.compiler."ghc${ghcVersion}"
8+
cabal-install
9+
hlint
10+
haskellPackages.apply-refact
11+
stylish-haskell
12+
13+
# DB Deps
14+
postgresql_13
15+
gmp
16+
zlib
17+
glibcLocales
18+
19+
# Extra
20+
parallel
21+
git
22+
# mkdocs
23+
gnumake
24+
];
25+
shellHook = ''
26+
export LOCALE_ARCHIVE="/nix/store/m53mq2077pfxhqf37gdbj7fkkdc1c8hc-glibc-locales-2.27/lib/locale/locale-archive"
27+
export LC_ALL=C.UTF-8
28+
'';
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
git add .
6+
7+
stylish-haskell -c .stylish-haskell.yaml -r src test app -i
8+
9+
git status
10+
11+
set +e
12+
git diff --exit-code
13+
diff_code=$?
14+
15+
if [ $diff_code -ne 0 ]
16+
then
17+
echo "Test formatting failed"
18+
exit 1
19+
fi

0 commit comments

Comments
 (0)