This commit is contained in:
Sergey Gulin 2023-08-10 16:34:46 +03:00
parent 9a83c892f4
commit ac386bb577
No known key found for this signature in database
GPG Key ID: 4974F364CB8EDF61
32 changed files with 892 additions and 196 deletions

View File

@ -13,10 +13,10 @@ jobs:
- name: xrefcheck
run: nix run github:serokell/xrefcheck
- name: reuse
run: nix build -L .#checks.x86_64-linux.reuse-lint
# Run step even if the previous one has failed
if: success() || failure()
# - name: reuse
# run: nix build -L .#checks.x86_64-linux.reuse-lint
# # Run step even if the previous one has failed
# if: success() || failure()
- name: hlint
run: nix build -L .#checks.x86_64-linux.hlint
@ -26,9 +26,9 @@ jobs:
run: nix build -L .#checks.x86_64-linux.stylish-haskell
if: success() || failure()
- name: check-trailing-whitespace
run: nix build -L .#checks.x86_64-linux.trailing-whitespace
if: success() || failure()
# - name: check-trailing-whitespace
# run: nix build -L .#checks.x86_64-linux.trailing-whitespace
# if: success() || failure()
- name: check-hpack
run: nix build -L .#checks.x86_64-linux.hpack
@ -43,11 +43,11 @@ jobs:
- uses: actions/checkout@v3
- id: set-matrix
run: echo "matrix=$(nix eval --json .#ghc-matrix.x86_64-linux)" >> $GITHUB_OUTPUT
run: echo "matrix=$(nix eval --json .#build-matrix.x86_64-linux)" >> $GITHUB_OUTPUT
build-and-test:
needs: ghc-versions
name: ghc${{ matrix.ghc }}
name: ${{ matrix.prefix }}
runs-on: [self-hosted, nix]
strategy:
fail-fast: false
@ -57,8 +57,8 @@ jobs:
- uses: actions/checkout@v3
- name: build
run: nix build -L .#checks.x86_64-linux.ghc${{ matrix.ghc }}:build-all --keep-going
run: nix build -L .#checks.x86_64-linux.${{ matrix.prefix }}:build-all --keep-going
- name: test
run: nix build -L .#checks.x86_64-linux.ghc${{ matrix.ghc }}:test-all --keep-going
run: nix build -L .#checks.x86_64-linux.${{ matrix.prefix }}:test-all --keep-going
if: success() || failure()

3
cabal.project Normal file
View File

@ -0,0 +1,3 @@
packages:
./with-utf8/
./test-package/

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,7 @@
inputs.hackage.follows = "hackage";
inputs.stackage.follows = "stackage";
};
serokell-nix.url = "github:serokell/serokell.nix/sereja/OPS-1458-ci-wrapper";
hackage = {
flake = false;
};
@ -36,76 +37,28 @@
lib = pkgs.lib;
hs-package-name = "with-utf8";
ci = serokell-nix.lib.haskell.makeCI haskellPkgs {
src = ./.;
stackFiles = ["stack-lts-20-7.yaml"];
resolvers = ["lts-19.13"];
};
ghc-versions = [ "884" "8107" "902" "926" "944" ];
# invoke haskell.nix for each ghc version listed in ghc-versions
pkgs-per-ghc = lib.genAttrs (map (v: "ghc${v}") ghc-versions)
(ghc: haskellPkgs.haskell-nix.cabalProject {
src = haskellPkgs.haskell-nix.haskellLib.cleanGit {
name = hs-package-name;
src = ./.;
};
compiler-nix-name = ghc;
# haskell.nix configuration
modules = [{
packages.${hs-package-name} = {
ghcOptions = [
# fail on warnings
"-Werror"
# disable optimisations, we don't need them if we don't package or deploy the executable
"-O0"
];
};
}];
});
# returns the list of all components for a package
get-package-components = pkg:
# library
lib.optional (pkg ? library) pkg.library
# haddock
++ lib.optional (pkg ? library) pkg.library.haddock
# exes, tests and benchmarks
++ lib.attrValues pkg.exes
++ lib.attrValues pkg.tests
++ lib.attrValues pkg.benchmarks;
# all components for each specified ghc version
build-all = lib.mapAttrs'
(ghc: pkg:
let components = get-package-components pkg.${hs-package-name}.components;
in lib.nameValuePair "${ghc}:build-all"
(pkgs.linkFarmFromDrvs "build-all" components)) pkgs-per-ghc;
# all tests for each specified ghc version
test-all = lib.mapAttrs'
(ghc: pkg:
let tests = lib.filter lib.isDerivation
(lib.attrValues pkg.${hs-package-name}.checks);
in lib.nameValuePair "${ghc}:test-all"
(pkgs.linkFarmFromDrvs "test-all" tests)) pkgs-per-ghc;
in {
# nixpkgs revision pinned by this flake
legacyPackages = pkgs;
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.hpack ];
};
# used to dynamically build a matrix in the GitHub pipeline
ghc-matrix = {
include = map (ver: { ghc = ver; }) ghc-versions;
buildInputs = [ pkgs.hpack ];
};
# derivations that we can run from CI
checks = build-all // test-all // {
# used to dynamically build a matrix in the GitHub pipeline
inherit (ci) build-matrix ;
trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.;
reuse-lint = pkgs.build.reuseLint ./.;
# derivations that we can run from CI
checks = ci.build-all // ci.test-all // {
# trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.;
# reuse-lint = pkgs.build.reuseLint ./.;
hlint = pkgs.build.haskell.hlint ./.;
stylish-haskell = pkgs.build.haskell.stylish-haskell ./.;

23
stack-lts-20-7.yaml Normal file
View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: MPL-2.0
resolver: lts-20.7
packages:
- with-utf8
- test-package
extra-deps:
# Required for GHC >= 9
- th-env-0.1.0.3
# Required for GHC >= 9.2
- constraints-0.13.1
- hashable-1.3.5.0
- random-1.2.1
# text-2.0
#- hashable-1.4.0.1
#- text-2.0
#allow-newer: true # text-2.0: some of our deps (incorrectly) say they dont like it

View File

@ -3,7 +3,9 @@
# SPDX-License-Identifier: MPL-2.0
resolver: lts-18.14
packages: [.]
packages:
- with-utf8
- test-package
extra-deps:
# Required for GHC >= 9

2
test-package/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.stack-work/
*~

11
test-package/CHANGELOG.md Normal file
View File

@ -0,0 +1,11 @@
# Changelog for `test-package`
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

30
test-package/LICENSE Normal file
View File

@ -0,0 +1,30 @@
Copyright Author name here (c) 2023
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of Author name here nor the names of other
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
OWNER 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.

1
test-package/README.md Normal file
View File

@ -0,0 +1 @@
# test-package

2
test-package/Setup.hs Normal file
View File

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

6
test-package/app/Main.hs Normal file
View File

@ -0,0 +1,6 @@
module Main (main) where
import Lib
main :: IO ()
main = someFunc

60
test-package/package.yaml Normal file
View File

@ -0,0 +1,60 @@
name: test-package
version: 0.1.0.0
github: "githubuser/test-package"
license: BSD3
author: "Author name here"
maintainer: "example@example.com"
copyright: "2023 Author name here"
extra-source-files:
- README.md
- CHANGELOG.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on GitHub at <https://github.com/githubuser/test-package#readme>
tested-with: GHC == 9.2.6, GHC == 9.4.4
dependencies:
- base >= 4.7 && < 5
ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
library:
source-dirs: src
executables:
test-package-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- test-package
tests:
test-package-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- test-package

6
test-package/src/Lib.hs Normal file
View File

@ -0,0 +1,6 @@
module Lib
( someFunc
) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"

View File

@ -0,0 +1,63 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack
name: test-package
version: 0.1.0.0
description: Please see the README on GitHub at <https://github.com/githubuser/test-package#readme>
homepage: https://github.com/githubuser/test-package#readme
bug-reports: https://github.com/githubuser/test-package/issues
author: Author name here
maintainer: example@example.com
copyright: 2023 Author name here
license: BSD3
license-file: LICENSE
build-type: Simple
tested-with:
GHC == 9.2.6, GHC == 9.4.4
extra-source-files:
README.md
CHANGELOG.md
source-repository head
type: git
location: https://github.com/githubuser/test-package
library
exposed-modules:
Lib
other-modules:
Paths_test_package
hs-source-dirs:
src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
default-language: Haskell2010
executable test-package-exe
main-is: Main.hs
other-modules:
Paths_test_package
hs-source-dirs:
app
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, test-package
default-language: Haskell2010
test-suite test-package-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_test_package
hs-source-dirs:
test
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, test-package
default-language: Haskell2010

View File

@ -0,0 +1,2 @@
main :: IO ()
main = putStrLn "Test suite not yet implemented"

View File

@ -21,13 +21,11 @@ category: IO
author: Kirill Elagin <kirelagin@serokell.io>
copyright: 2020 Serokell
license-file: LICENSES/MPL-2.0.txt
# license-file: ../LICENSES/MPL-2.0.txt
github: serokell/haskell-with-utf8
tested-with: GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2
extra-doc-files:
- CHANGELOG.md
- README.md
ghc-options:
- -Wall

View File

@ -1,4 +1,4 @@
cabal-version: 1.18
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
@ -24,12 +24,9 @@ bug-reports: https://github.com/serokell/haskell-with-utf8/issues
author: Kirill Elagin <kirelagin@serokell.io>
maintainer: Kirill Elagin <kirelagin@serokell.io>
copyright: 2020 Serokell
license: MPL-2.0
license-file: LICENSES/MPL-2.0.txt
build-type: Simple
extra-doc-files:
CHANGELOG.md
README.md
tested-with:
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2
source-repository head
type: git