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

Revisit Dependencies, Nix Setup #18

Merged
merged 3 commits into from
Oct 2, 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
2 changes: 1 addition & 1 deletion .chglog/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ options:
- Subject
notes:
keywords:
- BREAKING CHANGE
- BREAKING CHANGE
23 changes: 23 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Check, Test and Build Codebase"

on:
pull_request:
workflow_dispatch:

jobs:
check:
runs-on: "ubuntu-latest"

steps:
- name: "Checkout main"
uses: "actions/checkout@v4"

- name: "Install Nix"
uses: "DeterminateSystems/nix-installer-action@v14"

- name: "Use Nix Cache"
uses: "DeterminateSystems/magic-nix-cache-action@v8"

- name: "Check, Test and Build"
run: |
nix-shell --pure --run "dev-test-build"
31 changes: 6 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
.cabal-sandbox/
.ghc.environment.*
.hpc
.hsenv
.HTF/
.stack-work/
*.aux
*.chi
*.chs.h
*.dyn_hi
*.dyn_o
*.eventlog
*.hi
*.hie
*.hp
*.o
*.prof
cabal-dev
cabal.project.local
cabal.project.local~
cabal.sandbox.config
dist
dist-*

## Nix stuff:
*~
/.direnv
/.envrc
/dist
/dist-newstyle
/result
/tmp
56 changes: 28 additions & 28 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,45 @@
#######################

- modules:
- {name: Control.Monad.Error, within: []}
- {name: [Data.Aeson], as: Aeson}
- {name: Data.ByteString, as: B }
- {name: Data.ByteString.Char8, as: BC }
- {name: Data.ByteString.Lazy, as: BL }
- {name: Data.ByteString.Lazy.Char8, as: BLC }
- {name: Data.Text, as: T }
- {name: Data.Text.Lazy, as: TL }
- {name: Data.Text.Encoding, as: TE }
- { name: Control.Monad.Error, within: [] }
- { name: [Data.Aeson], as: Aeson }
- { name: Data.ByteString, as: B }
- { name: Data.ByteString.Char8, as: BC }
- { name: Data.ByteString.Lazy, as: BL }
- { name: Data.ByteString.Lazy.Char8, as: BLC }
- { name: Data.Text, as: T }
- { name: Data.Text.Lazy, as: TL }
- { name: Data.Text.Encoding, as: TE }

##########################
# EXTENSION RESTRICTIONS #
##########################

- extensions:
- default: false # All extension are banned by default
- name:
- DataKinds
- DeriveGeneric
- DeriveLift
- FlexibleContexts
- FlexibleInstances
- GADTs
- GeneralizedNewtypeDeriving
- KindSignatures
- OverloadedStrings
- RankNTypes
- RecordWildCards
- ScopedTypeVariables
- StandaloneDeriving
- TypeApplications
- TypeOperators
- default: false # All extension are banned by default
- name:
- DataKinds
- DeriveGeneric
- DeriveLift
- FlexibleContexts
- FlexibleInstances
- GADTs
- GeneralizedNewtypeDeriving
- KindSignatures
- OverloadedStrings
- RankNTypes
- RecordWildCards
- ScopedTypeVariables
- StandaloneDeriving
- TypeApplications
- TypeOperators

################
# CUSTOM RULES #
################

# Replace a $ b $ c with a . b $ c
- group: {name: dollar, enabled: true}
- group: { name: dollar, enabled: true }

# Generalise map to fmap, ++ to <>
- group: {name: generalise, enabled: true}
- group: { name: generalise, enabled: true }
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist-newstyle/
dist/
nix/
*.md
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 2,
"singleQuote": false,
"trailingComma": "es5",
"printWidth": 120
}
8 changes: 8 additions & 0 deletions .stan.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Big tuples
# Using tuples of big size (>= 4) can decrease code readability
# In serveral places Stack uses 4-tuples and in one place Stack uses a
# 5-tuple.
[[check]]
id = "STAN-0302"
scope = "all"
type = "Exclude"
22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-2024 Telostat Pte Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
120 changes: 14 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,123 +13,31 @@
*haspara* is a Haskell library that provides monetary definitions and a
rudimentary (and experimental) accounting functionality.

## Supported GHC Versions

1. `ghc90`
1. `ghc92`

At the moment, there is no particular reason for not supporting
`ghc94` except that required settings are not done yet in Nix support
files, in particular for Cabal dependency.

## Testing Against GHC Versions

You can use Nix support to test against different GHC versions:

```sh
nix-build --arg compiler "\"ghc92\""
nix-build --arg compiler "\"ghc90\""
```

`nix-build` command will default to `ghc90`. Check `./default.nix`
file for the default `ghc` version in case that this documentation is
out of date.

## Development

Before committing code to repository, reformat the code:
Big, long build command for the impatient:

```sh
fourmolu -i src/ test/
```

Compile the codebase, check warnings and errors:

```sh
cabal build -O0
cabal test -O0
cabal haddock -O0
```

Run [hlint](https://github.com/ndmitchell/hlint):

```sh
hlint src/
hpack &&
direnv reload &&
fourmolu -i src/ test/ &&
prettier --write . &&
find . -iname "*.nix" -not -path "*/nix/sources.nix" -print0 | xargs --null nixpkgs-fmt &&
hlint src/ test/ &&
cabal build -O0 &&
cabal run -O0 haspara -- --version &&
cabal v1-test &&
cabal haddock -O0
```

Run [weeder](https://hackage.haskell.org/package/weeder):
To test and build codebase in development environment, run:

```sh
weeder --require-hs-files
dev-test-build
```

## Making Releases

1. Checkout `main` branch:

```sh
git checkout main
```

2. Ensure that your branch is up to date:

```sh
git pull
```

3. Update the `version` information in [package.yaml](./package.yaml) if
required, run `hpack` to reflect the change on the `.cabal` file, and
recompile the project, run tests and generate Haddock documentation:

```sh
hpack
cabal clean
cabal build -O0
cabal test -O0
cabal haddock -O0
nix-build --arg compiler "\"ghc92\""
nix-build --arg compiler "\"ghc90\""
```

4. Update [CHANGELOG.md](./CHANGELOG.md) file:

```sh
git-chglog --next-tag <NEW-VERSION> -o CHANGELOG.md
```

5. Commit, tag and push:

```sh
git commit -am "chore(release): <NEW-VERSION>"
git tag -a -m "Release <NEW-VERSION>" <NEW-VERSION>
git push --follow-tags origin main
```

6. Publish GitHub release:

```sh
gh release create "<NEW-VERSION>" --title "v<NEW-VERSION>" --generate-notes
```

7. Create the package, upload to Hackage as a candidate first and check the result:

```sh
cabal clean
cabal build -O0
cabal test -O0
cabal haddock -O0
cabal sdist
cabal upload <path to .tar.gz archive>
```

8. If the candidate package release works fine, release to Hackage:

```sh
cabal upload --publish <path to .tar.gz archive>
```

## License

Copyright Telostat Pte Ltd (c) 2021-2022.
Copyright Telostat Pte Ltd (c) 2021-2024.

This work is licensed under MIT license. See [LICENSE](./LICENSE).
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
*.cabal

package *
ghc-options: -fwrite-ide-info
Loading