Skip to content

Commit

Permalink
Add CI and template project for compiler
Browse files Browse the repository at this point in the history
Mostly based on Lamagraph/intermediate-lang-distiller
  • Loading branch information
WoWaster committed Sep 9, 2024
1 parent ce92794 commit 93ed169
Show file tree
Hide file tree
Showing 22 changed files with 552 additions and 2 deletions.
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@v10
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: .
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
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,haskell
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,haskell

### Haskell ###
dist
dist-*
cabal-dev
Expand All @@ -21,3 +26,44 @@ cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,haskell

# 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
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"redhat.vscode-yaml",
"haskell.haskell",
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"editor.formatOnSave": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"editor.renderWhitespace": "all",
"[haskell]": {
"editor.tabSize": 4
},
"haskell.manageHLS": "GHCup",
"haskell.formattingProvider": "fourmolu",
"yaml.format.enable": true,
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
}
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
# interaction-nets-in-fpga
Interaction nets based processor in Clash
# Interaction nets based processor in Clash

## 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)
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: []
11 changes: 11 additions & 0 deletions lamagraph-compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog for `lamagraph-compiler`

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).

## Unreleased

## 0.1.0.0 - YYYY-MM-DD
Empty file added lamagraph-compiler/README.md
Empty file.
2 changes: 2 additions & 0 deletions lamagraph-compiler/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
6 changes: 6 additions & 0 deletions lamagraph-compiler/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main (main) where

import Lib

main :: IO ()
main = someFunc
Loading

0 comments on commit 93ed169

Please sign in to comment.