From 2e7e08055ee511072f4e53b25645e3c7105de71a Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sun, 20 Nov 2022 14:09:56 -0800 Subject: [PATCH] Cabal file and GitHub Action (#48) * upgrade Stack resolver to fix build and test * GitHub Action for Stack https://github.com/freckle/stack-action * Cabal file and GitHub Action --- .github/workflows/haskell-ci.yml | 183 +++++++++++++++++++++++++++++++ .github/workflows/stack.yml | 15 +++ .gitignore | 2 +- README.md | 3 + package.yaml | 8 +- stack.yaml | 2 +- stack.yaml.lock | 12 ++ steeloverseer.cabal | 159 +++++++++++++++++++++++++++ 8 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/haskell-ci.yml create mode 100644 .github/workflows/stack.yml create mode 100644 stack.yaml.lock create mode 100644 steeloverseer.cabal diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml new file mode 100644 index 0000000..eac62d4 --- /dev/null +++ b/.github/workflows/haskell-ci.yml @@ -0,0 +1,183 @@ +# This GitHub workflow config has been generated by a script via +# +# haskell-ci 'github' 'steeloverseer.cabal' +# +# To regenerate the script (for example after adjusting tested-with) run +# +# haskell-ci regenerate +# +# For more information, see https://github.com/haskell-CI/haskell-ci +# +# version: 0.14.3 +# +# REGENDATA ("0.14.3",["github","steeloverseer.cabal"]) +# +name: Haskell-CI +on: + - push + - pull_request +jobs: + linux: + name: Haskell-CI - Linux - ${{ matrix.compiler }} + runs-on: ubuntu-18.04 + timeout-minutes: + 60 + container: + image: buildpack-deps:bionic + continue-on-error: ${{ matrix.allow-failure }} + strategy: + matrix: + include: + - compiler: ghc-9.2.2 + compilerKind: ghc + compilerVersion: 9.2.2 + setup-method: ghcup + allow-failure: false + fail-fast: false + steps: + - name: apt + run: | + apt-get update + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.17.5/x86_64-linux-ghcup-0.1.17.5 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" + "$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: Set PATH and environment variables + run: | + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + echo "LANG=C.UTF-8" >> "$GITHUB_ENV" + echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" + echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" + HCDIR=/opt/$HCKIND/$HCVER + HC=$HOME/.ghcup/bin/$HCKIND-$HCVER + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" + echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" + HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') + echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" + echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" + echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" + echo "HEADHACKAGE=false" >> "$GITHUB_ENV" + echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" + echo "GHCJSARITH=0" >> "$GITHUB_ENV" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: env + run: | + env + - name: write cabal config + run: | + mkdir -p $CABAL_DIR + cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz + echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c - + xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan + rm -f cabal-plan.xz + chmod a+x $HOME/.cabal/bin/cabal-plan + cabal-plan --version + - name: checkout + uses: actions/checkout@v2 + with: + path: source + - name: initial cabal.project for sdist + run: | + touch cabal.project + echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project + cat cabal.project + - name: sdist + run: | + mkdir -p sdist + $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist + - name: unpack + run: | + mkdir -p unpacked + find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; + - name: generate cabal.project + run: | + PKGDIR_steeloverseer="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/steeloverseer-[0-9.]*')" + echo "PKGDIR_steeloverseer=${PKGDIR_steeloverseer}" >> "$GITHUB_ENV" + rm -f cabal.project cabal.project.local + touch cabal.project + touch cabal.project.local + echo "packages: ${PKGDIR_steeloverseer}" >> cabal.project + echo "package steeloverseer" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + cat >> cabal.project <> cabal.project.local + cat cabal.project + cat cabal.project.local + - name: dump install plan + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all + cabal-plan + - name: cache + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store + restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- + - name: install dependencies + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all + - name: build w/o tests + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: build + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always + - name: tests + run: | + $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct + - name: cabal check + run: | + cd ${PKGDIR_steeloverseer} || false + ${CABAL} -vnormal check + - name: haddock + run: | + $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all + - name: unconstrained build + run: | + rm -f cabal.project.local + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml new file mode 100644 index 0000000..c8a569a --- /dev/null +++ b/.github/workflows/stack.yml @@ -0,0 +1,15 @@ +# https://github.com/freckle/stack-action +name: Stack + +on: + push: + branches: + - '**' + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: freckle/stack-action@v3 diff --git a/.gitignore b/.gitignore index baa03d6..5692334 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ cabal.sandbox.config .stack-work/ .sosrc* codex.tags -steeloverseer.cabal +dist-newstyle diff --git a/README.md b/README.md index 0f1cd6a..3ae04ed 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ commands in response. The first command to fail short circuits the series. The w be selected using regular expressions and the commands may include capture groups. [![Build Status](https://travis-ci.org/steeloverseer/steeloverseer.png?branch=master)](https://travis-ci.org/steeloverseer/steeloverseer) +[![Build status](https://github.com/schell/steeloverseer/actions/workflows/stack.yml/badge.svg)](https://github.com/schell/steeloverseer/actions/workflows/stack.yml) +[![Build status](https://github.com/schell/steeloverseer/actions/workflows/haskell-ci.yml/badge.svg)](https://github.com/schell/steeloverseer/actions/workflows/haskell-ci.yml) + Installation ============ diff --git a/package.yaml b/package.yaml index 284def3..1f6b326 100644 --- a/package.yaml +++ b/package.yaml @@ -20,6 +20,12 @@ extra-source-files: ghc-options: -Wall +build-tool-depends: + hspec-discover + +tested-with: + - GHC==9.2.2 + default-extensions: - BangPatterns - DeriveDataTypeable @@ -38,7 +44,7 @@ dependencies: - base >= 4.0 && < 5.0 - bytestring >= 0.10 - exceptions - - fsnotify >= 0.3 + - fsnotify >= 0.3 && < 0.4 - managed >= 1.0.1 - mtl >= 2.2 - regex-tdfa >= 1.2 diff --git a/stack.yaml b/stack.yaml index 5d283e7..2751e8d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1 +1 @@ -resolver: lts-12.13 +resolver: lts-20.0 diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..c454645 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: a2cbcd2f37010a64c4ef74c21fd7e55982a07b49840d2bed306f9bac9981a9c3 + size: 648420 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/0.yaml + original: lts-20.0 diff --git a/steeloverseer.cabal b/steeloverseer.cabal new file mode 100644 index 0000000..d9b58b9 --- /dev/null +++ b/steeloverseer.cabal @@ -0,0 +1,159 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.35.0. +-- +-- see: https://github.com/sol/hpack + +name: steeloverseer +version: 2.1.0.0 +synopsis: A file watcher and development tool. +description: A command line tool that responds to filesystem events. Allows the user to automatically execute commands after files are added or updated. Watches files using regular expressions. +category: Development +stability: stable +homepage: https://github.com/schell/steeloverseer#readme +bug-reports: https://github.com/schell/steeloverseer/issues +author: Schell Scivally, + Mitchell Rosen +maintainer: schell@takt.com +license: BSD3 +license-file: LICENSE +build-type: Simple +tested-with: + GHC==9.2.2 +extra-source-files: + README.md + +source-repository head + type: git + location: https://github.com/schell/steeloverseer + +library + exposed-modules: + Control.Concurrent.STM.TQueue.Extra + Sos.Exception + Sos.FileEvent + Sos.Job + Sos.Rule + Sos.Template + Sos.Utils + System.FSNotify.Streaming + hs-source-dirs: + src + default-extensions: + BangPatterns + DeriveDataTypeable + DeriveFunctor + FlexibleContexts + InstanceSigs + LambdaCase + OverloadedStrings + RecordWildCards + ScopedTypeVariables + ViewPatterns + ghc-options: -Wall + build-tool-depends: + hspec-discover:hspec-discover + build-depends: + aeson >=0.8 + , aeson-compat >=0.3.10 + , ansi-terminal >=0.6.2 + , async >=2.0 + , base >=4.0 && <5.0 + , bytestring >=0.10 + , containers >=0.5 + , exceptions + , fsnotify ==0.3.* + , managed >=1.0.1 + , mtl >=2.2 + , process ==1.6.* + , regex-tdfa >=1.2 + , semigroups >=0.16 + , stm >=2.4 + , streaming >=0.1.0 && <0.3 + , text >=1.2 + , unix + , yaml >=0.8 + default-language: Haskell2010 + +executable sos + main-is: Main.hs + hs-source-dirs: + app + default-extensions: + BangPatterns + DeriveDataTypeable + DeriveFunctor + FlexibleContexts + InstanceSigs + LambdaCase + OverloadedStrings + RecordWildCards + ScopedTypeVariables + ViewPatterns + ghc-options: -Wall -threaded + build-tool-depends: + hspec-discover:hspec-discover + build-depends: + aeson-compat >=0.3.10 + , async >=2.0 + , base >=4.0 && <5.0 + , bytestring >=0.10 + , directory >=1.2 + , exceptions + , filepath >=1.3 + , fsnotify ==0.3.* + , managed >=1.0.1 + , mtl >=2.2 + , optparse-applicative >=0.11 + , regex-tdfa >=1.2 + , semigroups >=0.16 + , steeloverseer + , stm >=2.4 + , streaming >=0.1.0 && <0.3 + , text >=1.2 + , yaml >=0.8 + default-language: Haskell2010 + if os(darwin) + build-depends: + hfsevents >=0.1.3 + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Sos.TemplateSpec + Paths_steeloverseer + hs-source-dirs: + test + default-extensions: + BangPatterns + DeriveDataTypeable + DeriveFunctor + FlexibleContexts + InstanceSigs + LambdaCase + OverloadedStrings + RecordWildCards + ScopedTypeVariables + ViewPatterns + ghc-options: -Wall + build-tool-depends: + hspec-discover:hspec-discover + build-depends: + aeson-compat >=0.3.10 + , async >=2.0 + , base >=4.0 && <5.0 + , bytestring >=0.10 + , exceptions + , fsnotify ==0.3.* + , hspec + , managed >=1.0.1 + , mtl >=2.2 + , regex-tdfa >=1.2 + , semigroups >=0.16 + , steeloverseer + , stm >=2.4 + , streaming >=0.1.0 && <0.3 + , text >=1.2 + , yaml >=0.8 + default-language: Haskell2010