-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
862 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
name: Binaries | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ghc: ["9.6.5", "9.8.2"] | ||
os: | ||
- ubuntu-latest | ||
# - windows-latest | ||
# include: | ||
# - ghc: "9.8.2" | ||
# os: macOS-latest | ||
|
||
env: | ||
# Modify this value to "invalidate" the cabal cache. | ||
CABAL_CACHE_VERSION: "hw-prelude/2024-10-21" | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: haskell-actions/setup@v2 | ||
id: setup-haskell | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: '3.10.3.0' | ||
|
||
- name: Set some window specific things | ||
if: matrix.os == 'windows-latest' | ||
run: echo 'EXE_EXT=.exe' >> $GITHUB_ENV | ||
|
||
- name: Configure project | ||
run: | | ||
cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ | ||
cabal build all --enable-tests --enable-benchmarks --dry-run | ||
- name: Cabal cache over S3 | ||
uses: action-works/cabal-cache-s3@v1 | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
with: | ||
region: us-west-2 | ||
dist-dir: dist-newstyle | ||
store-path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
threads: 16 | ||
archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} | ||
skip: "${{ secrets.BINARY_CACHE_URI == '' }}" | ||
|
||
- name: Cabal cache over HTTPS | ||
uses: action-works/cabal-cache-s3@v1 | ||
with: | ||
dist-dir: dist-newstyle | ||
store-path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
threads: 16 | ||
archive-uri: https://cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} | ||
skip: "${{ secrets.BINARY_CACHE_URI != '' }}" | ||
|
||
- name: Build | ||
run: cabal build all --enable-tests --enable-benchmarks | ||
|
||
- name: Test | ||
env: | ||
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | ||
run: cabal test all --enable-tests --enable-benchmarks | ||
|
||
check: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag: ${{ steps.tag.outputs.tag }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Check if cabal project is sane | ||
run: | | ||
PROJECT_DIR=$PWD | ||
mkdir -p $PROJECT_DIR/build/sdist | ||
for i in $(git ls-files | grep '\.cabal'); do | ||
cd $PROJECT_DIR && cd `dirname $i` | ||
cabal check | ||
done | ||
- name: Tag new version | ||
id: tag | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
env: | ||
server: http://hackage.haskell.org | ||
username: ${{ secrets.HACKAGE_USER }} | ||
password: ${{ secrets.HACKAGE_PASS }} | ||
run: | | ||
package_version="$(cat *.cabal | grep '^version:' | cut -d : -f 2 | xargs)" | ||
echo "Package version is v$package_version" | ||
git fetch --unshallow origin | ||
if git tag "v$package_version"; then | ||
echo "Tagging with new version "v$package_version"" | ||
if git push origin "v$package_version"; then | ||
echo "Tagged with new version "v$package_version"" | ||
echo "::set-output name=tag::v$package_version" | ||
fi | ||
fi | ||
release: | ||
needs: [build, check] | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.check.outputs.tag != '' }} | ||
outputs: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Create source distribution | ||
run: | | ||
PROJECT_DIR=$PWD | ||
mkdir -p $PROJECT_DIR/build/sdist | ||
for i in $(git ls-files | grep '\.cabal'); do | ||
cd $PROJECT_DIR && cd `dirname $i` | ||
cabal v2-sdist -o $PROJECT_DIR/build/sdist | ||
done; | ||
- name: Publish to hackage | ||
env: | ||
server: http://hackage.haskell.org | ||
username: ${{ secrets.HACKAGE_USER }} | ||
password: ${{ secrets.HACKAGE_PASS }} | ||
candidate: false | ||
run: | | ||
package_version="$(cat *.cabal | grep '^version:' | cut -d : -f 2 | xargs)" | ||
for PACKAGE_TARBALL in $(find ./build/sdist/ -name "*.tar.gz"); do | ||
PACKAGE_NAME=$(basename ${PACKAGE_TARBALL%.*.*}) | ||
if ${{ env.candidate }}; then | ||
TARGET_URL="${{ env.server }}/packages/candidates"; | ||
DOCS_URL="${{ env.server }}/package/$PACKAGE_NAME/candidate/docs" | ||
else | ||
TARGET_URL="${{ env.server }}/packages/upload"; | ||
DOCS_URL="${{ env.server }}/package/$PACKAGE_NAME/docs" | ||
fi | ||
HACKAGE_STATUS=$(curl --silent --head -w %{http_code} -XGET --anyauth --user "${{ env.username }}:${{ env.password }}" ${{ env.server }}/package/$PACKAGE_NAME -o /dev/null) | ||
if [ "$HACKAGE_STATUS" = "404" ]; then | ||
echo "Uploading $PACKAGE_NAME to $TARGET_URL" | ||
curl -X POST -f --user "${{ env.username }}:${{ env.password }}" $TARGET_URL -F "package=@$PACKAGE_TARBALL" | ||
echo "Uploaded $PACKAGE_NAME" | ||
else | ||
echo "Package $PACKAGE_NAME" already exists on Hackage. | ||
fi | ||
done | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: Undocumented | ||
draft: true | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Revision history for hw-polysemy | ||
# Revision history for hw-prelude | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Opinionated prelude library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
packages: . | ||
|
||
allow-newer: | ||
base, | ||
bytestring, | ||
|
||
package testcontainers | ||
ghc-options: -XDuplicateRecordFields | ||
|
||
package amazonka | ||
ghc-options: -XDuplicateRecordFields | ||
|
||
package amazonka-s3 | ||
ghc-options: -XDuplicateRecordFields | ||
|
||
package amazonka-sso | ||
ghc-options: -XDuplicateRecordFields | ||
|
||
package amazonka-sts | ||
ghc-options: -XDuplicateRecordFields |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
cabal-version: 3.4 | ||
name: hw-prelude | ||
version: 0.0.0.1 | ||
synopsis: Opinionated prelude library | ||
description: Opinionated prelude library. | ||
license: Apache-2.0 | ||
license-file: LICENSE | ||
author: John Ky | ||
maintainer: [email protected] | ||
copyright: 2024 John Ky | ||
category: Development | ||
build-type: Simple | ||
extra-doc-files: CHANGELOG.md | ||
extra-source-files: README.md | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/haskell-works/hw-prelude | ||
|
||
common base { build-depends: base >= 4.13 && < 5 } | ||
|
||
common async { build-depends: async < 2.3 } | ||
common bytestring { build-depends: bytestring < 0.13 } | ||
common contravariant { build-depends: contravariant < 1.6 } | ||
common directory { build-depends: directory < 1.4 } | ||
common filepath { build-depends: filepath < 1.6 } | ||
common network { build-depends: network < 3.3 } | ||
common process { build-depends: process < 1.7 } | ||
common resourcet { build-depends: resourcet < 1.4 } | ||
common text { build-depends: text < 3 } | ||
common unliftio { build-depends: unliftio < 0.3 } | ||
|
||
common hw-prelude { build-depends: hw-prelude } | ||
|
||
common Win32 | ||
if os(windows) | ||
build-depends: Win32 >= 2.5.4.1 | ||
|
||
flag werror | ||
description: Enable -Werror | ||
manual: True | ||
default: False | ||
|
||
common project-config | ||
default-language: Haskell2010 | ||
default-extensions: BlockArguments | ||
DataKinds | ||
DeriveGeneric | ||
DuplicateRecordFields | ||
FlexibleContexts | ||
FlexibleInstances | ||
LambdaCase | ||
NoImplicitPrelude | ||
OverloadedStrings | ||
RankNTypes | ||
ScopedTypeVariables | ||
TypeApplications | ||
TypeOperators | ||
ghc-options: -Wall | ||
|
||
if flag(werror) | ||
ghc-options: -Werror | ||
|
||
library | ||
import: base, project-config, | ||
async, | ||
bytestring, | ||
contravariant, | ||
directory, | ||
filepath, | ||
network, | ||
process, | ||
resourcet, | ||
text, | ||
unliftio, | ||
Win32, | ||
visibility: public | ||
|
||
if os(windows) | ||
exposed-modules: HaskellWorks.IO.Win32.NamedPipe | ||
|
||
exposed-modules: HaskellWorks.Control.Monad | ||
HaskellWorks.Data.String | ||
HaskellWorks.Error | ||
HaskellWorks.Error.Types | ||
HaskellWorks.IO.Network.NamedPipe | ||
HaskellWorks.IO.Network.Port | ||
HaskellWorks.IO.Network.Socket | ||
HaskellWorks.IO.Process | ||
HaskellWorks.Prelude | ||
HaskellWorks.Unsafe | ||
hs-source-dirs: src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module HaskellWorks.Control.Monad | ||
( repeatNUntilM_, | ||
repeatNWhileM_, | ||
) where | ||
|
||
import HaskellWorks.Prelude | ||
|
||
-- | Repeat an action n times until the action returns True. | ||
repeatNUntilM_ :: () | ||
=> Monad m | ||
=> Int | ||
-> (Int -> m Bool) | ||
-> m () | ||
repeatNUntilM_ n action = go 0 | ||
where | ||
go i = | ||
when (i < n) $ do | ||
shouldTerminate <- action i | ||
unless shouldTerminate $ go (i + 1) | ||
|
||
-- | Repeat an action n times while the action returns True. | ||
repeatNWhileM_ :: () | ||
=> Monad m | ||
=> Int | ||
-> (Int -> m Bool) | ||
-> m () | ||
repeatNWhileM_ n action = go 0 | ||
where | ||
go i = | ||
when (i < n) $ do | ||
shouldContinue <- action i | ||
when shouldContinue $ go (i + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module HaskellWorks.Data.String | ||
( unlines | ||
, unwords | ||
, words | ||
, lines | ||
) where | ||
|
||
import Data.String |
Oops, something went wrong.