Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed May 12, 2024
1 parent dffba77 commit ad5f931
Show file tree
Hide file tree
Showing 11 changed files with 1,460 additions and 1 deletion.
179 changes: 179 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
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, macOS-latest]
exclude:
- os: windows-latest
ghc: "9.8.2"

env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2024-05-10"

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
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
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dist
dist-*
cabal-dev
*.o
*.hi
*.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.*

.vscode/ipch
/hie.yaml
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Revision history for polysemy-blockfrost

## 0.1.0.0 -- YYYY-mm-dd

* First version. Released on an unsuspecting world.
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) 2024, John Ky

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 John Ky 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 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# polysemy-blockfrost
# polysemy-blockfrost
76 changes: 76 additions & 0 deletions polysemy-blockfrost.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cabal-version: 3.4


name: polysymey-blockfrost
version: 0.1.0.0
synopsis: Polysemy wrapper around the Blockfrost client
description: Polysemy wrapper around the Blockfrost client.
license: Apache-2.0
license-file: LICENSE
author: John Ky
maintainer: newhoggy@gmail.com
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/polysymey-blockfrost

common base { build-depends: base >= 4.18.2.1 && < 5 }

common blockfrost-api { build-depends: blockfrost-api < 0.11 }
common blockfrost-client { build-depends: blockfrost-client < 0.9 }
common bytestring { build-depends: bytestring < 0.13 }
common contravariant { build-depends: contravariant < 1.6 }
common filepath { build-depends: filepath < 1.6 }
common ghc-prim { build-depends: ghc-prim < 0.12 }
common hedgehog { build-depends: hedgehog < 1.5 }
common polysemy { build-depends: polysemy < 2 }
common polysemy-log { build-depends: polysemy-log < 0.11 }
common polysemy-plugin { build-depends: polysemy-plugin < 0.5 }
common polysemy-time { build-depends: polysemy-time < 0.7 }
common tasty { build-depends: tasty < 1.6 }
common tasty-hedgehog { build-depends: tasty-hedgehog < 1.5 }
common text { build-depends: text < 3 }

common polysymey-blockfrost { build-depends: polysymey-blockfrost }

common project-config
import: polysemy,
polysemy-plugin,
default-extensions: BlockArguments
DataKinds
FlexibleContexts
FlexibleInstances
LambdaCase
NoImplicitPrelude
OverloadedStrings
TypeApplications
ghc-options: -Wall
-fplugin=Polysemy.Plugin

library
import: base, project-config,
blockfrost-api,
blockfrost-client,
polysemy,
text,
exposed-modules: Polysemy.Blockfrost
Polysemy.Blockfrost.Api
Polysemy.Blockfrost.Client
Polysemy.Blockfrost.Effect.Blockfrost
hs-source-dirs: src
default-language: GHC2021

test-suite polysymey-blockfrost-test
import: base, project-config,
tasty,
default-language: GHC2021
type: exitcode-stdio-1.0
build-tool-depends: tasty-discover:tasty-discover
hs-source-dirs: test
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T
Loading

0 comments on commit ad5f931

Please sign in to comment.