From f69fd57407988519038bf85045472e9c885fa3e5 Mon Sep 17 00:00:00 2001 From: alexeyraga Date: Tue, 26 Mar 2019 10:22:17 +1100 Subject: [PATCH] Use Cabal build, add options --- .circleci/config.yml | 193 ++++------------------ .gitignore | 25 +-- .vscode/tasks.json | 148 +++++------------ arbor-monad-metric-datadog.cabal | 20 +-- src/Arbor/Monad/Metric/Datadog/Options.hs | 10 ++ 5 files changed, 91 insertions(+), 305 deletions(-) create mode 100644 src/Arbor/Monad/Metric/Datadog/Options.hs diff --git a/.circleci/config.yml b/.circleci/config.yml index 74d39cf..badaff3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,172 +1,41 @@ +version: 2.1 -cabalbuild: &cabalbuild - working_directory: ~/project +orbs: + haskell: haskell-works/haskell-build@1.6.3 + github: haskell-works/github-release@1.2.1 + hackage: haskell-works/hackage@1.0.0 - steps: - - checkout - - - run: - name: Add GHC tools to PATH - command: | - echo "HOME=$HOME" - echo "BASH_ENV=$BASH_ENV" - echo "PATH=$PATH" - echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV - - - run: - name: Copying scripts - command: | - mkdir -p ~/.local/bin - cp ./scripts/* ~/.local/bin - - - run: - name: GHC version - command: | - echo "$GHC" > ghc.version - date +%Y-%m > month.version - - - run: - name: Find all sub-projects - command: ./scripts/projects-summary > projects.summary - - ##### Building library - - restore_cache: - keys: - - cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--extra - - cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}-- - - cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "month.version"}} - - - run: - name: Building build dependencies - command: | - ./scripts/mk-cabal-project > cabal.project - cabal update - cabal new-build --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j${CABAL_THREADS:-4} all - cabal new-build --enable-tests --enable-benchmarks --project-file="cabal.project" --dep -j${CABAL_THREADS:-4} all - - - save_cache: - key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}-- - paths: [~/.cabal/packages, ~/.cabal/store] - - - run: - name: Building project - command: | - cabal new-build --enable-tests --enable-benchmarks --project-file="cabal.project" -j${CABAL_THREADS:-4} all - - - save_cache: - key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "projects.summary" }}--extra - paths: [~/.cabal/packages, ~/.cabal/store] - - - save_cache: - key: cabal--{{ checksum "ghc.version" }}--{{ .Environment.CACHE_VERSION }}--{{ checksum "month.version"}} - paths: [~/.cabal/packages, ~/.cabal/store] - - - run: - name: Running tests - command: | - if grep '^test-suite' *.cabal > /dev/null; then - cabal new-test --project-file="cabal.project" -j${CABAL_THREADS:-4} all - else - echo Not tests to run - fi - -version: 2.0 -jobs: - ghc-8.4.3: - environment: - - GHC: "ghc8.4.3" - docker: - - image: quay.io/haskell_works/ghc-8.4.3:18.04_2018-09-24 - <<: *cabalbuild - - ghc-8.2.2: - environment: - - GHC: "ghc8.2.2" - docker: - - image: quay.io/haskell_works/ghc-8.2.2:18.04_2018-09-24 - <<: *cabalbuild - - checked-builds: - docker: - - image: quay.io/haskell_works/ghc-8.4.3:18.04_2018-09-24 - - steps: - - checkout - - - run: - name: Add GHC tools to PATH - command: | - echo "HOME=$HOME" - echo "BASH_ENV=$BASH_ENV" - echo "PATH=$PATH" - echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV - - - run: - name: Copying scripts - command: | - mkdir -p ~/.local/bin - cp ./scripts/* ~/.local/bin - - - deploy: - command: | - if [ "$CIRCLE_PROJECT_USERNAME" == "arbor" ]; then - if [[ "$CIRCLE_BRANCH" == master ]]; then - when tag autotag - elif [[ "$CIRCLE_TAG" =~ v.* ]]; then - publish - fi - fi - - release: - docker: - - image: quay.io/haskell_works/ghc-8.4.3:18.04_2018-09-24 - - steps: - - checkout +workflows: + multiple-ghc-build: + jobs: + - haskell/build: + name: GHC 8.2.2 + executor: haskell/ghc-8_2_2 - - run: - name: Add GHC tools to PATH - command: | - echo "HOME=$HOME" - echo "BASH_ENV=$BASH_ENV" - echo "PATH=$PATH" - echo 'export PATH="$PATH:/opt/ghc/bin/"' >> $BASH_ENV + - haskell/build: + name: GHC 8.4.4 + executor: haskell/ghc-8_4_4 - - run: - name: Copying scripts - command: | - mkdir -p ~/.local/bin - cp ./scripts/* ~/.local/bin + - haskell/build: + name: GHC 8.6.3 + executor: haskell/ghc-8_6_3 - - deploy: - command: | - if [ "$CIRCLE_PROJECT_USERNAME" == "arbor" ]; then - if [[ "$CIRCLE_BRANCH" == master ]]; then - when tag autotag - elif [[ "$CIRCLE_TAG" =~ v.* ]]; then - publish - fi - fi - -workflows: - version: 2 - multiple-ghcs: - jobs: - - ghc-8.4.3 - - ghc-8.2.2 - - checked-builds: + - github/release-cabal: + name: GitHub Release + context: haskell-ci requires: - - ghc-8.4.3 - - ghc-8.2.2 + - GHC 8.2.2 + - GHC 8.4.4 + - GHC 8.6.3 + checkout: true filters: branches: only: master - tagged-release: - jobs: - - release: - filters: - branches: - ignore: /.*/ - tags: - only: /^v.*/ + - hackage/upload: + context: haskell-ci + publish: true + requires: + - GitHub Release + username: ${HACKAGE_USER} + password: ${HACKAGE_PASS} diff --git a/.gitignore b/.gitignore index 7c67bce..2116b7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -# Created by http://www.gitignore.io - ### OSX ### .DS_Store *.DS_Store @@ -12,15 +10,15 @@ Icon # Thumbnails ._* -docker/rdkafka/ - # Files that might appear on external disk .Spotlight-V100 .Trashes ### Haskell ### -dist +dist/ +dist-newstyle/ cabal-dev +.ghc.environment* *.o *.hi *.chi @@ -30,6 +28,7 @@ cabal-dev .cabal-sandbox/ cabal.sandbox.config cabal.config +cabal.project.local .stack-work/ *.aux *.ps @@ -61,19 +60,3 @@ tramp # elpa packages /elpa/ TAGS - -## Python -.idea - -/state - -*.ipynb -__pycache* - -# transient librdkafka -.librdkafka - -/dist-newstyle -/.ghc.environment.x86_64-darwin-* -/cabal.project.local - diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 84cb457..cad54e2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,31 +1,18 @@ { "version": "2.0.0", - "type": "shell", - "presentation": { - "reveal": "always", - "panel": "new" - }, - "windows": { - "command": "cmd", "args": ["/c"] - }, - "linux": { - "command": "sh", "args": ["-c"] - }, - "osx": { - "command": "sh", "args": ["-c"] - }, "tasks": [ { - "label": "stack build", - "group": "build", - "command": "/bin/bash", - "args": [ - "-c", - "echo START_BUILD && cd ${workspaceRoot} && ./project.sh build && echo END_BUILD " - ], + "label": "Build", + "type": "shell", + "command": "bash", + "args": ["-lc", "cabal new-build && echo 'Done'"], + "group": { + "kind": "build", + "isDefault": true + }, "problemMatcher": { "owner": "haskell", - "fileLocation": "absolute", + "fileLocation": "relative", "pattern": [ { "regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):.*$", @@ -36,107 +23,46 @@ "message": 1 } ] + }, + "presentation": { + "echo": false, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true } }, { - "label": "stack clean & build", - "command": "/bin/bash", - "args": [ - "-c", - "echo START_CLEAN_AND_BUILD && cd ${workspaceRoot} && ./project.sh clean && ./project.sh build && echo END_CLEAN_AND_BUILD " - ], + "label": "Test", + "type": "shell", + "command": "bash", + "args": ["-lc", "cabal new-test && echo 'Done'"], + "group": { + "kind": "test", + "isDefault": true + }, "problemMatcher": { "owner": "haskell", - "fileLocation": "absolute", + "fileLocation": "relative", "pattern": [ { - "regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):.*$", + "regexp": "^(.+?):(\\d+):(\\d+):.*$", "file": 1, "line": 2, "column": 3, "severity": 4 }, { - "regexp": "\\s*(.*)$", - "message": 1 - } - ] - } - }, - { - "group": "test", - "label": "stack test", - "command": "/bin/bash", - "args": [ - "-c", - "echo START_TEST && cd ${workspaceRoot} && ./project.sh test && echo END_TEST " - ], - "problemMatcher": { - "owner": "haskell", - "fileLocation": [ "relative", "${workspaceRoot}" ], - "pattern": [ - { - "regexp": "^\\s+(.+):(\\d+):.*$", - "file": 1, "line": 2 - }, - { - "regexp": "^.*\\.(.+)\\s*$", - "message": 1 + "regexp": "\\s*(\\d\\)\\s)?(.*)$", + "message": 2 } ] - } - }, - { - "isBackground": true, - "label": "stack watch", - "command": "/bin/bash", - "args": [ - "-c", - "echo START_WATCH && cd ${workspaceRoot} && ./project.sh build --test --no-run-tests --file-watch && echo END_WATCH " - ], - "problemMatcher": { - "owner": "haskell", - "fileLocation": "absolute", - "pattern": [ - { - "regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):.*$", - "file": 1, "line": 2, "column": 3, "severity": 4 - }, - { - "regexp": "\\s*(.*)$", - "message": 1 - } - ], - "background": { - "activeOnStart": true, - "beginsPattern": "^.*\\(local file changes:\\s", - "endsPattern": "(ExitFailure|ExitSuccess)" - } - } - }, - { - "isBackground": true, - "label": "stack watch & test", - "command": "/bin/bash", - "args": [ - "-c", - "echo START_WATCH && cd ${workspaceRoot} && ./project.sh build --test --file-watch && echo END_WATCH " - ], - "problemMatcher": { - "owner": "haskell", - "fileLocation": [ "relative", "${workspaceRoot}" ], - "pattern": [ - { - "regexp": "^\\s+(.+):(\\d+):.*$", - "file": 1, "line": 2 - }, - { - "regexp": "^.*\\.(.+)\\s*$", - "message": 1 - } - ], - "background": { - "activeOnStart": true, - "beginsPattern": "^.*\\(local file changes:.*$", - "endsPattern": "(ExitFailure|ExitSuccess)" - } + }, + "presentation": { + "echo": false, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true } } ] diff --git a/arbor-monad-metric-datadog.cabal b/arbor-monad-metric-datadog.cabal index a75f420..309eb83 100644 --- a/arbor-monad-metric-datadog.cabal +++ b/arbor-monad-metric-datadog.cabal @@ -1,5 +1,6 @@ +cabal-version: 2.2 name: arbor-monad-metric-datadog -version: 1.0.0 +version: 1.1.0 description: Please see the README on Github at synopsis: Metric library backend for datadog. category: Metrics @@ -11,7 +12,6 @@ copyright: Arbor Networks license: MIT license-file: LICENSE build-type: Simple -cabal-version: >= 1.10 extra-source-files: ChangeLog.md README.md @@ -23,26 +23,25 @@ source-repository head library exposed-modules: Arbor.Monad.Metric.Datadog + Arbor.Monad.Metric.Datadog.Options Arbor.Monad.Metric.Datadog.Internal Arbor.Monad.Metric.Datadog.Internal.Show other-modules: - Paths_arbor_monad_metric_datadog - hs-source-dirs: - src + hs-source-dirs: src default-extensions: BangPatterns FlexibleContexts FlexibleInstances GeneralizedNewtypeDeriving MultiParamTypeClasses OverloadedStrings TupleSections ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints build-depends: base >= 4.7 && < 5 - , arbor-datadog >= 0.0.0 && < 0.1 + , arbor-datadog >= 0.1 && < 0.2 , arbor-monad-metric >= 1.1.0 && < 1.3 , bytestring >= 0.10.8 && < 0.11 , containers >= 0.5.10 && < 0.7 , generic-lens >= 1.0.0.2 && < 1.2 , lens >= 4.16 && < 4.18 , mtl >= 2.2.2 && < 2.3 - , network >= 2.6.0 && < 2.9 + , network >= 2.6.0 && < 3 , resourcet >= 1.2.1 && < 1.3 - , stm >= 2.4.0 && < 2.6 + , stm >= 2.5.0 && < 2.6 , text >= 1.2.3 && < 1.3 , transformers >= 0.5.2 && < 0.6 default-language: Haskell2010 @@ -57,7 +56,6 @@ test-suite arbor-monad-metric-datadog-test Arbor.Monad.Metric.Datadog Arbor.Monad.Metric.Datadog.Internal Arbor.Monad.Metric.Datadog.Internal.Show - Paths_arbor_monad_metric_datadog hs-source-dirs: test src @@ -65,7 +63,7 @@ test-suite arbor-monad-metric-datadog-test ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base >= 4.7 && < 5 - , arbor-datadog >= 0.0.0 && < 0.1 + , arbor-datadog >= 0.1 && < 0.2 , arbor-monad-metric , arbor-monad-metric-datadog , bytestring >= 0.10.8 && < 0.11 @@ -79,7 +77,7 @@ test-suite arbor-monad-metric-datadog-test , lens >= 4.17 && < 4.18 , monad-logger , mtl >= 2.2.2 && < 2.3 - , network >= 2.8.0 && < 2.9 + , network >= 2.8.0 && < 3 , resourcet >= 1.2.2 && < 1.3 , stm >= 2.5.0 && < 2.6 , text >= 1.2.3 && < 1.3 diff --git a/src/Arbor/Monad/Metric/Datadog/Options.hs b/src/Arbor/Monad/Metric/Datadog/Options.hs new file mode 100644 index 0000000..24095e7 --- /dev/null +++ b/src/Arbor/Monad/Metric/Datadog/Options.hs @@ -0,0 +1,10 @@ +module Arbor.Monad.Metric.Datadog.Options +( -- * Re-exports + StatsConfig (..) +, StatsTag (..) +, SampleRate(..) +, statsConfigParser +) +where + +import Arbor.Network.StatsD.Options