summaryrefslogtreecommitdiff
path: root/deps/discord-haskell/.github
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2023-11-16 19:06:43 -0500
committerLLLL Colonq <llll@colonq>2023-11-16 19:06:43 -0500
commitdcef0b65069fb38fd0f6c4382353167f603ebff1 (patch)
tree45954ffe308c3dd056e6af4f734e6d2af89e5856 /deps/discord-haskell/.github
Initial commit
Diffstat (limited to 'deps/discord-haskell/.github')
-rw-r--r--deps/discord-haskell/.github/workflows/main.yml91
-rw-r--r--deps/discord-haskell/.github/workflows/parseVersions.hs34
2 files changed, 125 insertions, 0 deletions
diff --git a/deps/discord-haskell/.github/workflows/main.yml b/deps/discord-haskell/.github/workflows/main.yml
new file mode 100644
index 0000000..aec9070
--- /dev/null
+++ b/deps/discord-haskell/.github/workflows/main.yml
@@ -0,0 +1,91 @@
+name: CI
+
+# when the workflow will run
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+
+ # Allows manually starting this workflow from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ # To dynamically create a build matrix, we generate a JSON output from one job
+ # and use fromJson in the next job to construct the matrix.
+ # This dynamic approach means we don't have to update the CI file when we
+ # change supported GHC versions.
+ generate-matrix:
+ name: Generate GHC build matrix
+ runs-on: ubuntu-latest
+ outputs:
+ ghc-matrix: ${{ steps.set-ghc-matrix.outputs.versions }}
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Parse the cabal tested-with stanza
+ id: parse
+ run: |
+ echo "::set-output name=tested-with-versions::$(runghc .github/workflows/parseVersions.hs)"
+
+ - name: Set the GHC matrix for the next job
+ id: set-ghc-matrix
+ # We use single quotes here, since the output from the previous step
+ # will not have escaped double quotes, and it's just easier to use single
+ # quotes on the outside than try to escape the inner double quotes.
+ run: echo '::set-output name=versions::{"ghc-version":${{ steps.parse.outputs.tested-with-versions }}}'
+
+ build:
+ name: Build Check
+ needs: generate-matrix
+ runs-on: ubuntu-latest
+ strategy:
+ # Whether to stop other jobs in the matrix if one fails. This is undesirable
+ # since we want to check e.g. it compiles on 8.10.7 regardless of the status
+ # of 9.X.
+ fail-fast: false
+ # Feed the json from the previous job.
+ matrix: ${{ fromJson(needs.generate-matrix.outputs.ghc-matrix) }}
+ steps:
+ - uses: actions/checkout@v2
+
+ - uses: haskell/actions/setup@v2
+ id: setup-haskell
+ with:
+ # We install a global GHC and use Stack with --system-ghc
+ ghc-version: ${{ matrix.ghc-version }}
+ enable-stack: true
+
+ # First run cabal, since it is generally quicker
+ - name: "Cabal: Update cabal package database, generate build plan"
+ run: |
+ cabal update
+ cabal build --dry-run
+
+ - name: "Cabal: Cache Dependencies"
+ id: cache
+ uses: actions/cache@v2
+ with:
+ # Include the build plan file generated by cabal configure, but allow
+ # restoring without its hash as long as the GHC version is the same.
+ key: cabal-${{ runner.os }}-${{ matrix.ghc-version }}-${{ hashFiles('**/plan.json') }}
+ restore-keys: |
+ cabal-${{ runner.os }}-${{ matrix.ghc-version }}
+ path: |
+ ${{ steps.setup-haskell.outputs.cabal-store }}
+ dist-newstyle
+
+ - name: "Cabal: Build"
+ run: cabal build
+
+ # Now run stack
+ - name: "Stack: Cache ~/.stack"
+ id: cache-stack
+ uses: actions/cache@v2
+ with:
+ path: ~/.stack
+ key: stack-${{ runner.os }}-${{ matrix.ghc-version }}-${{ hashFiles('stack.yaml') }}
+ restore-keys: |
+ stack-${{ runner.os }}-${{ matrix.ghc-version }}
+
+ - name: "Stack: Build"
+ run: stack build --system-ghc
diff --git a/deps/discord-haskell/.github/workflows/parseVersions.hs b/deps/discord-haskell/.github/workflows/parseVersions.hs
new file mode 100644
index 0000000..3302f17
--- /dev/null
+++ b/deps/discord-haskell/.github/workflows/parseVersions.hs
@@ -0,0 +1,34 @@
+-- Small script to use the Cabal library to parse the Tested-With stanza
+-- from discord-haskell.cabal, and output to stdout in a JSON friendly list.
+module Main where
+
+import Prelude hiding (readFile)
+import Data.ByteString (readFile)
+import Data.List (intersperse)
+import Data.Maybe (maybeToList)
+import Distribution.Compiler (CompilerFlavor(GHC))
+import Distribution.PackageDescription.Parsec (parseGenericPackageDescriptionMaybe)
+import Distribution.Pretty (pretty)
+import Distribution.Types.GenericPackageDescription (GenericPackageDescription(packageDescription))
+import Distribution.Types.PackageDescription (PackageDescription(testedWith))
+import Distribution.Types.Version (versionNumbers)
+import Distribution.Types.VersionRange.Internal (VersionRange(ThisVersion))
+import Text.PrettyPrint (render, brackets, comma, doubleQuotes)
+
+main = do
+ bs <- readFile "discord-haskell.cabal"
+ let mbVersions = testedWith . packageDescription <$> parseGenericPackageDescriptionMaybe bs
+ -- e.g. mbVersions = Just [(GHC,ThisVersion (mkVersion [8,10,7])),(GHC,ThisVersion (mkVersion [9,2])),(GHC,ThisVersion (mkVersion [9,4,1]))]
+ let versions = concat $ maybeToList mbVersions
+ -- e.g. versions = [(GHC,ThisVersion (mkVersion [8,10,7])),(GHC,ThisVersion (mkVersion [9,2])),(GHC,ThisVersion (mkVersion [9,4,1]))]
+ let ghcVersions =
+ [ ghcVersion
+ | (flavor, versionRange) <- versions
+ -- Filter only GHC
+ , GHC == flavor
+ -- Filter only to exact matches: "== VERSION"
+ , let (ThisVersion ghcVersion) = versionRange
+ ]
+ -- e.g. ghcVersions = [mkVersion [8,10,7],mkVersion [9,2],mkVersion [9,4,1]]
+ let prettyVersions = brackets $ mconcat $ intersperse comma $ map (doubleQuotes . pretty) ghcVersions
+ putStrLn $ render prettyVersions