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

CI & other tools #1

Merged
merged 9 commits into from
Mar 19, 2024
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
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
labels:
- dependabot
- actions
schedule:
interval: "weekly"
77 changes: 77 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
on:
workflow_call:

jobs:
pedantic-build:
name: Pedantic build
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Setup Haskell with Stack
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-version: "latest"

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.stack
key: pedantic-${{ hashFiles('stack.yaml') }}
restore-keys: |
pedantic-

- name: Install dependencies
run: |
stack update
stack build --only-dependencies

- name: Pedantic build
run: |
stack build --pedantic

build-and-test:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- name: Clone project
uses: actions/checkout@v4

- name: Setup Haskell with Stack
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-version: "latest"

- name: Cache dependencies on Unix-like OS
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
uses: actions/cache@v4
with:
path: ~/.stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}

- name: Cache dependencies on Windows
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v4
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}

- name: Install dependencies
run: |
stack update
stack build --only-dependencies --test --bench --no-run-tests --no-run-benchmarks

- name: Build
run: stack build --test --bench --no-run-tests --no-run-benchmarks

- name: Run tests
run: stack test
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches:
# PRs can only use caches from their target branch. We therefore need to
# make sure we run on 'master' too.
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yaml

fourmolu:
needs: pre-commit
uses: ./.github/workflows/fourmolu.yaml

hlint:
needs: fourmolu
uses: ./.github/workflows/hlint.yaml

build-and-test:
needs: hlint
uses: ./.github/workflows/build-and-test.yaml
15 changes: 15 additions & 0 deletions .github/workflows/fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
workflow_call:

jobs:
hlint:
name: Fourmolu
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Run fourmolu
uses: haskell-actions/run-fourmolu@v9
with:
version: "latest"
19 changes: 19 additions & 0 deletions .github/workflows/hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_call:

jobs:
hlint:
name: Hlint
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Set up HLint
uses: haskell-actions/hlint-setup@v2

- name: Run HLint
uses: haskell-actions/hlint-run@v2
with:
path: .
KubEF marked this conversation as resolved.
Show resolved Hide resolved
fail-on: warning
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
workflow_call:

jobs:
pre-commit:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Install pre-commit
run: |
pip install pre-commit

- name: Run pre-commit
run: |
pre-commit run --all-files
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ cabal.project.local~

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

# Because of prettier in pre-commit
node_modules/
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: fix-byte-order-marker
- id: mixed-line-ending
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Lamagraph IL

## Required tools

### Pre-commit

We use [pre-commit](https://pre-commit.com/) for general tidy up of files.
To install pre-commit run:

```shell
pip install pre-commit # or install using your distro package manager
pre-commit install
```

To run pre-commit on all files run

```shell
pre-commit run --all-files
```

### Fourmolu

We use [Fourmolu](https://fourmolu.github.io/) as a formatter for Haskell source files with our custom config.
**Fourmolu must be explicitly enabled in VS Code!**

## Editor

Our editor of choice is [VS Code](https://code.visualstudio.com/) with following extensions:

- [Haskell](https://marketplace.visualstudio.com/items?itemName=haskell.haskell)
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for YAML formatting
2 changes: 1 addition & 1 deletion distiller/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.stack-work/
*~
*~
1 change: 1 addition & 0 deletions distiller/Setup.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import Distribution.Simple

main = defaultMain
50 changes: 50 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Number of spaces per indentation step
indentation: 4

# Max line length for automatic line breaking
column-limit: 120

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: trailing

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: diff-friendly

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: false

# Whether to leave a space before an opening record brace
record-brace-space: false

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: multi-line

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: auto

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: right-align

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []
1 change: 1 addition & 0 deletions lang/Setup.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import Distribution.Simple

main = defaultMain
7 changes: 5 additions & 2 deletions lang/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ bodyOfAppend =
Case
(Variable "xs")
[ (Pat "Nil" [], Variable "ys")
, (Pat "Cons" ["x'", "xs'"], Constructor "Cons" [Variable "x'", Application (Application (Function "append") (Variable "xs'")) (Variable "ys")])
,
( Pat "Cons" ["x'", "xs'"]
, Constructor "Cons" [Variable "x'", Application (Application (Function "append") (Variable "xs'")) (Variable "ys")]
)
]

appendInExp :: FunctionHeader
Expand All @@ -24,4 +27,4 @@ appendInExp =
(Lambda "xs" (Lambda "ys" bodyOfAppend))

main :: IO ()
main = print appendInExp
main = print appendInExp
14 changes: 12 additions & 2 deletions lang/src/Syntax.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{-# LANGUAGE InstanceSigs #-}

module Syntax (Expression (Variable, Constructor, Lambda, Application, Case, Let, Function), Fun, Pattern (Pat), FunctionHeader (Header)) where
module Syntax (
Expression (Variable, Constructor, Lambda, Application, Case, Let, Function),
Fun,
Pattern (Pat),
FunctionHeader (Header),
) where

type Fun = String

Expand All @@ -27,7 +32,12 @@ instance Show Expression where
Lambda v exp' -> "(λ" ++ show v ++ "." ++ show exp' ++ ")"
Constructor name exps -> "(" ++ name ++ foldr (\x acc -> "(" ++ show x ++ ")" ++ acc) "" exps ++ ")"
Application exp1 exp2 -> "(" ++ show exp1 ++ ")(" ++ show exp2 ++ ")"
Case exp' ls -> "(case " ++ show exp' ++ "of\n" ++ foldr (\(pat, exp'') acc -> "\t" ++ show pat ++ " => " ++ show exp'' ++ "\n" ++ acc) "" ls ++ ")"
Case exp' ls ->
"(case "
++ show exp'
++ "of\n"
++ foldr (\(pat, exp'') acc -> "\t" ++ show pat ++ " => " ++ show exp'' ++ "\n" ++ acc) "" ls
++ ")"
Let var exp1 exp2 -> "let " ++ show var ++ " = " ++ show exp1 ++ " in " ++ show exp2
Function f -> show f

Expand Down
2 changes: 1 addition & 1 deletion lang/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resolver:
# - auto-update
# - wai
packages:
- .
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
Expand Down
6 changes: 3 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2023-01-01.yaml
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/11.yaml
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/13.yaml

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand All @@ -30,8 +30,8 @@ resolver:
# - auto-update
# - wai
packages:
- distiller
- lang
- distiller
- lang
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
packages: []
snapshots:
- completed:
sha256: 2fdd7d3e54540062ef75ca0a73ca3a804c527dbf8a4cadafabf340e66ac4af40
size: 712469
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/11.yaml
sha256: 6f0bea3ba5b07360f25bc886e8cff8d847767557a492a6f7f6dcb06e3cc79ee9
size: 712905
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/13.yaml
original:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/11.yaml
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/13.yaml
Loading