From d04cc0b59c49511b3ebae20b0b2ce98d61f04c64 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 28 Oct 2021 16:38:22 +0100 Subject: Initial commit --- .github/workflows/CI.yaml | 90 ++++++++++++++ .gitignore | 27 ++++ CHANGELOG.md | 7 ++ LICENSE | 29 +++++ README.md | 5 + app/Main.hs | 4 + bench/Main.hs | 4 + cabal.project | 5 + flake.lock | 310 ++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 48 +++++++ gsa-parser.cabal | 68 ++++++++++ hie.yaml | 16 +++ src/Lib.hs | 7 ++ test/Spec.hs | 8 ++ 14 files changed, 628 insertions(+) create mode 100644 .github/workflows/CI.yaml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 app/Main.hs create mode 100644 bench/Main.hs create mode 100644 cabal.project create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 gsa-parser.cabal create mode 100644 hie.yaml create mode 100644 src/Lib.hs create mode 100644 test/Spec.hs diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 0000000..84295c7 --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,90 @@ +name: CI + +on: push + +jobs: + + nix-build: + name: Nix build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - uses: cachix/install-nix-action@v13 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' + extra_nix_config: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v8 + with: + name: jmc + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build gsa-parser + run: nix build -L + # TODO `nix flake check` is currently system-dependent but should be used here + - name: Build gsa-parser checks + run: nix build -L '.#checks.x86_64-linux."gsa-parser:test:gsa-parser-test"' + - name: Build gsa-parser shell + run: nix build -L '.#devShell.x86_64-linux' + + stack-build: + name: Stack ${{ matrix.resolver }} on ${{ matrix.os }} (${{ matrix.required }}) + strategy: + fail-fast: false + matrix: + resolver: [ nightly, lts-18, lts-17, lts-16, lts-15, lts-14 ] + os: [ macos-latest, ubuntu-latest ] + required: [ required ] + # include: + # - resolver: nightly + # os: ubuntu-latest + # required: optional + continue-on-error: ${{ matrix.required == 'optional' }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: haskell/actions/setup@v1 + with: + enable-stack: true + ## For some reason, stack caching seems to be very brittle, and cause a lot of build failures. + ## I haven't investigated very thoroughly what to best do about this, but for now, I'm just not caching stack builds. + # - uses: actions/cache@v2 + # with: + # path: | + # ~/.stack + # .stack-work + # key: stack-cache-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('**/*.cabal') }} + - run: stack init --resolver ${{ matrix.resolver }} + - run: stack build --resolver ${{ matrix.resolver }} --only-dependencies + - run: stack build --resolver ${{ matrix.resolver }} + - run: stack build --resolver ${{ matrix.resolver }} --haddock --test --bench --no-run-benchmarks + + cabal-build: + name: Cabal GHC ${{ matrix.ghc }} on ${{ matrix.os }} (${{ matrix.required }}) + strategy: + fail-fast: false + matrix: + ghc: [ '8.6.5', '8.8.3', '8.10.5', '9.0.1' ] + os: [ ubuntu-latest, macos-latest ] + required: [ required ] + include: + - ghc: latest + os: ubuntu-latest + required: optional + continue-on-error: ${{ matrix.required == 'optional' }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: haskell/actions/setup@v1 + with: + ghc-version: ${{ matrix.ghc }} + - uses: actions/cache@v2 + with: + path: | + ~/.cabal + dist-newstyle + key: cabal-cache-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }} + - run: cabal new-build --only-dependencies + - run: cabal new-build + - run: cabal new-test --test-show-details=direct diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edb8907 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +### Nix ### +result + +### Haskell ### +dist +dist-* +cabal-dev +*.o +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5fccd0a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 0 + +### [Added] +### [Removed] +### [Changed] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d296d3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2021, Yann Herklotz +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5bf9e8 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# gsa-parser +[![gsa-parser on hackage](https://img.shields.io/hackage/v/gsa-parser)](http://hackage.haskell.org/package/gsa-parser) +[![gsa-parser on Stackage Nightly](https://stackage.org/package/gsa-parser/badge/nightly)](https://stackage.org/nightly/package/gsa-parser) + +Generated with [template-haskell](https://github.com/jonascarpay/template-haskell) diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..2ca1f1d --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "heyyyyyy" diff --git a/bench/Main.hs b/bench/Main.hs new file mode 100644 index 0000000..04c2719 --- /dev/null +++ b/bench/Main.hs @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "heyyyyyyyyyyyyyyyyyyyy" diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..4964617 --- /dev/null +++ b/cabal.project @@ -0,0 +1,5 @@ +packages: + ./ + +package gsa-parser + tests: True diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7ba97d3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,310 @@ +{ + "nodes": { + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-sDbrmur9Zfp4mPKohCD8IDZfXJ0Tjxpmr2R+kg5PpSY=", + "owner": "haskell", + "repo": "cabal", + "rev": "94aaa8e4720081f9c75497e2735b90f6a819b08e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1622475795, + "narHash": "sha256-chwTL304Cav+7p38d9mcb+egABWmxo2Aq+xgVBgEb/U=", + "owner": "haskell", + "repo": "cabal", + "rev": "b086c1995cdd616fc8d91f46a21e905cc50a1049", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ghc-8.6.5-iohk": { + "flake": false, + "locked": { + "lastModified": 1600920045, + "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "owner": "input-output-hk", + "repo": "ghc", + "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "release/8.6.5-iohk", + "repo": "ghc", + "type": "github" + } + }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1632964339, + "narHash": "sha256-GjL/b4D6m+XOWJ2kqghdGrkDY4I/wLrzMlFpTiMLb/4=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "2051e81503e4b10f82f877ef06abc5c6f89576f7", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskellNix": { + "inputs": { + "HTTP": "HTTP", + "cabal-32": "cabal-32", + "cabal-34": "cabal-34", + "cardano-shell": "cardano-shell", + "flake-utils": "flake-utils_2", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hpc-coveralls": "hpc-coveralls", + "nix-tools": "nix-tools", + "nixpkgs": [ + "haskellNix", + "nixpkgs-2105" + ], + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2009": "nixpkgs-2009", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1632964520, + "narHash": "sha256-DEc5rXBnkllRFvWOQRYF0yFdG0rCRZMH2SXG1tjt6SA=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "7421a25fb842e188eff6612f31a766e479f973a5", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "nix-tools": { + "flake": false, + "locked": { + "lastModified": 1627889534, + "narHash": "sha256-9eEbK2nrRp6rYGQoBv6LO9IA/ANZpofwAkxMuGBD45Y=", + "owner": "input-output-hk", + "repo": "nix-tools", + "rev": "15d2e4b61cb63ff351f3c490c12c4d89eafd31a1", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "nix-tools", + "type": "github" + } + }, + "nixpkgs-2003": { + "locked": { + "lastModified": 1620055814, + "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.03-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2009": { + "locked": { + "lastModified": 1624271064, + "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.09-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1630481079, + "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1628785280, + "narHash": "sha256-2B5eMrEr6O8ff2aQNeVxTB+9WrGE80OB4+oM6T7fOcc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6525bbc06a39f26750ad8ee0d40000ddfdc24acb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1631092763, + "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master", + "repo": "old-ghc-nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "haskellNix": "haskellNix", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ] + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1632964463, + "narHash": "sha256-MzScOnxjJJXT86UTEWkNI1pjqAHKqg7w0YZp/OdaZVU=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "daa4f106dee8e558d5ca94899ee8bf1477eb22c7", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..21038e8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "gsa-parser"; + + inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; + inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils, haskellNix }: + flake-utils.lib.eachDefaultSystem (system: + let + overlay = self: _: { + hsPkgs = + self.haskell-nix.project' rec { + src = ./.; + compiler-nix-name = "ghc8107"; + shell = { + tools = { + cabal = { }; + ghcid = { }; + haskell-language-server = { }; + hlint = { }; + ormolu = { }; + }; + ## ormolu that uses ImportQualifiedPost. + ## To use, remove ormolu from the shell.tools section above, and uncomment the following lines. + # buildInputs = + # let + # ormolu = pkgs.haskell-nix.tool compiler-nix-name "ormolu" "latest"; + # ormolu-wrapped = pkgs.writeShellScriptBin "ormolu" '' + # ${ormolu}/bin/ormolu --ghc-opt=-XImportQualifiedPost $@ + # ''; + # in + # [ ormolu-wrapped ]; + }; + }; + }; + pkgs = import nixpkgs { + inherit system; + overlays = [ + haskellNix.overlay + overlay + ]; + }; + flake = pkgs.hsPkgs.flake { }; + in + flake // { defaultPackage = flake.packages."gsa-parser:exe:gsa-parser-exe"; } + ); +} diff --git a/gsa-parser.cabal b/gsa-parser.cabal new file mode 100644 index 0000000..b360072 --- /dev/null +++ b/gsa-parser.cabal @@ -0,0 +1,68 @@ +cabal-version: 2.4 +name: gsa-parser +version: 0 +license: BSD-3-Clause +build-type: Simple +license-file: LICENSE +author: Yann Herklotz +maintainer: Yann Herklotz +copyright: 2021 Yann Herklotz +tested-with: GHC ==8.6.3 || ==8.8.3 || ==8.10.5 +extra-doc-files: + CHANGELOG.md + README.md + +-- category: +-- description: description +-- synopsis: one-line synopsis +-- homepage: https://github.com/FIXME/gsa-parser#readme +-- source-repository head +-- type: git +-- location: git://github.com/FIXME/gsa-parser.git + +common common-options + build-depends: base >=4.9 && <5 + default-language: Haskell2010 + ghc-options: + -Wall -Wcompat -Widentities -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wredundant-constraints + -fhide-source-paths -Wpartial-fields + +library + import: common-options + hs-source-dirs: src + exposed-modules: Lib + build-depends: + , containers + , mtl + +executable gsa-parser-exe + import: common-options + hs-source-dirs: app + main-is: Main.hs + build-depends: gsa-parser + ghc-options: -threaded -rtsopts -with-rtsopts=-N + +test-suite gsa-parser-test + import: common-options + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Spec.hs + build-depends: + , hspec + , HUnit + , gsa-parser + , QuickCheck + + ghc-options: -threaded -rtsopts -with-rtsopts=-N + +benchmark gsa-parser-bench + import: common-options + type: exitcode-stdio-1.0 + hs-source-dirs: bench + main-is: Main.hs + build-depends: + , criterion + , gsa-parser + + ghc-options: -threaded -rtsopts -with-rtsopts=-N diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 0000000..b6663a1 --- /dev/null +++ b/hie.yaml @@ -0,0 +1,16 @@ +cradle: + multi: + # - path: "ignore/" + # config: {cradle: {none: }} + + - path: "src" + config: {cradle: {cabal: {component: "lib:gsa-parser"}}} + + - path: "app" + config: {cradle: {cabal: {component: "gsa-parser:gsa-parser-exe"}}} + + - path: "test" + config: {cradle: {cabal: {component: "gsa-parser:gsa-parser-test"}}} + + - path: "bench" + config: {cradle: {cabal: {component: "gsa-parser:gsa-parser-bench"}}} diff --git a/src/Lib.hs b/src/Lib.hs new file mode 100644 index 0000000..1055c22 --- /dev/null +++ b/src/Lib.hs @@ -0,0 +1,7 @@ +module Lib + ( someFunc, + ) +where + +someFunc :: IO () +someFunc = putStrLn "hey" diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..74cfd56 --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,8 @@ +import Test.Hspec + +main :: IO () +main = + hspec $ + describe "gsa-parser-test" $ + it "works" $ + 2 + 2 `shouldBe` (4 :: Int) -- cgit