diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 914fff4..9e275f2 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -1,119 +1,197 @@ -name: Color-CI +name: CI on: push: - branches: [ '*' ] + branches: [ "master", "release/**" ] pull_request: - branches: [ master ] + branches: [ "**" ] + schedule: + - cron: "0 5 * * 5" defaults: { run: { shell: bash } } +# Cancel running workflows when a new workflow on the same PR or branch is started, +# but put scheduled workflows into their own group +concurrency: + group: ${{ + format('{0}-{1}{2}', + github.workflow, + github.event.pull_request.number || github.ref, + github.event_name == 'schedule' && '-scheduled' || '')}} + cancel-in-progress: true + jobs: - build: - name: CI + test-with-stack: + name: Stack runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest] - # resolver: [nightly -- disabled for now, some issue with installing ghc - resolver: [lts-20, lts-19, lts-18, lts-16, lts-14, lts-12] + os: [ubuntu-latest, macOS-latest, windows-latest] + resolver: [lts-12, lts-14, lts-16, lts-18, lts-19, lts-20, lts-21, lts-22, nightly] include: - - resolver: lts-12 + - resolver: lts-14 ghc: 8.4.4 - stack-yaml: stack-extra-deps.yaml - resolver: lts-14 - stack-yaml: stack-coveralls.yaml + ghc: 8.6.5 - resolver: lts-16 ghc: 8.8.4 - resolver: lts-18 - - # Latest stable for MacOS: ghc-8.8.4 - - resolver: lts-16 - os: macos-latest + ghc: 8.10.7 - resolver: lts-19 - os: macos-latest + ghc: 9.0.2 - resolver: lts-20 - os: macos-latest - # Latest stable for Windows: ghc-8.6.4 + ghc: 9.2.8 + - resolver: lts-21 + ghc: 9.4.8 + stack-yaml: stack-coveralls.yaml + - resolver: lts-22 + ghc: 9.6.6 + - resolver: nightly + ghc: 9.8.2 + stack-yaml: stack.yaml + exclude: + # Newer MacOS does not support older GHC: - resolver: lts-14 - os: windows-latest + os: macOS-latest + - resolver: lts-16 + os: macOS-latest + - resolver: lts-18 + os: macOS-latest - resolver: lts-19 - os: windows-latest - - resolver: lts-20 - os: windows-latest + os: macOS-latest env: - STACK_YAML: stack.yaml - STACK_ARGS: '--resolver ${{ matrix.resolver }}' - cache-version: v5 # bump up this version to invalidate currently stored cache + STACK_YAML: ${{ matrix.stack-yaml || matrix.ghc != '' && format('stack.ghc-{0}.yaml', matrix.ghc) || 'stack.yaml' }} + STACK_ARGS: '--resolver ${{ matrix.resolver }} --system-ghc' + cache-version: v0 # bump up this version to invalidate currently stored cache steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: haskell-actions/setup@v2 + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + enable-stack: true + stack-version: 'latest' + cabal-version: 'latest' - name: Cache id: cache - uses: actions/cache@v2 - if: matrix.os != 'macos-latest' + uses: actions/cache@v4 with: path: | - ~/.stack + ${{ steps.setup-haskell-cabal.outputs.stack-root }} .stack-work - Color/.stack-work key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} restore-keys: | ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} - - name: Cache - id: cache-macos - uses: actions/cache@v2 - if: matrix.os == 'macos-latest' - with: - path: | - ~/.stack - key: ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} - restore-keys: | - ${{ runner.os }}-${{ matrix.resolver }}-${{ env.cache-version }} - - name: Workaround setup-exe-cache failure on macos - if: steps.cache-macos.outputs.cache-hit == 'true' && matrix.os == 'macos-latest' - run: | - rm -r ~/.stack/setup-exe-cache - name: Windows Cache id: cache-windows - uses: actions/cache@v2 + uses: actions/cache@v4 if: matrix.os == 'windows-latest' with: path: | - C:\\Users\\RUNNER~1\\AppData\\Roaming\\stack C:\\Users\\RUNNER~1\\AppData\\Local\\Programs\\stack key: ${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }} restore-keys: | ${{ runner.os }}-${{ matrix.resolver }}-programs-${{ env.cache-version }} - - - name: Ubuntu install GHC - if: matrix.ghc != '' && matrix.os == 'ubuntu-latest' + - name: Reset modtime run: | - sudo add-apt-repository ppa:hvr/ghc -y - sudo apt-get update - sudo apt-get install ghc-${{ matrix.ghc }} - - name: Install Stack and local GHC + set -ex + curl -sSL https://raw.githubusercontent.com/lehins/utils/master/haskell/git-modtime/git-modtime.hs -o git-modtime.hs + runhaskell -- git-modtime.hs -f .stack-work-root/tree-contents.txt + - name: Build run: | set -ex - curl -sSL https://get.haskellstack.org/ | sh -s - -f - curl -sSL https://raw.githubusercontent.com/lehins/utils/786c3fe7e9e1345d7b403019f52e344627224edf/haskell/git-modtime/git-modtime.hs -o git-modtime.hs - [ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc" - [ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }} - stack $STACK_ARGS runghc git-modtime.hs - - name: Tests + stack $STACK_ARGS test --no-run-tests --haddock --no-haddock-deps + - name: Test env: - COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | set -ex - [ -n "${{ matrix.ghc }}" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ] && STACK_ARGS="$STACK_ARGS --system-ghc" - [ -n "${{ matrix.stack-yaml }}" ] && STACK_YAML=${{ matrix.stack-yaml }} - if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-14" ] && [ -n "${COVERALLS_TOKEN}" ]; then - stack $STACK_ARGS test Color:tests --coverage --haddock --no-haddock-deps + if [ "${{ matrix.os }}.${{ matrix.resolver }}" == "ubuntu-latest.lts-21" ] && [ -n "${COVERALLS_REPO_TOKEN}" ]; then + stack $STACK_ARGS test --coverage stack $STACK_ARGS hpc report --all - curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.6.1/shc-linux-x64-8.8.4.tar.bz2 | tar xj shc - ./shc --repo-token="$COVERALLS_TOKEN" --partial-coverage --fetch-coverage combined custom + curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.7.0/shc-Linux-X64.tar.bz2 | tar xj shc + ./shc --repo-token="$COVERALLS_REPO_TOKEN" --partial-coverage --fetch-coverage combined custom else - stack $STACK_ARGS test Color:tests Color:doctests --bench --no-run-benchmarks --haddock --no-haddock-deps + stack $STACK_ARGS test fi + + test-with-cabal: + name: Cabal + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.0.2" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.2.2" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.4.4" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.6.5" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.8.4" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "8.10.7" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.0.2" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.2.8" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.4.8" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.6.6" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.8.2" } + - { cabal: "3.12", os: ubuntu-latest, ghc: "9.10.1" } + - { cabal: "3.12", os: windows-latest, ghc: "9.0.2" } + - { cabal: "3.12", os: windows-latest, ghc: "9.2.8" } + - { cabal: "3.12", os: windows-latest, ghc: "9.4.8" } + - { cabal: "3.12", os: windows-latest, ghc: "9.6.6" } + - { cabal: "3.12", os: windows-latest, ghc: "9.8.2" } + - { cabal: "3.12", os: windows-latest, ghc: "9.10.1" } + - { cabal: "3.12", os: macOS-13, ghc: "9.0.2" } + - { cabal: "3.12", os: macOS-latest, ghc: "9.2.8" } + - { cabal: "3.12", os: macOS-latest, ghc: "9.4.8" } + - { cabal: "3.12", os: macOS-latest, ghc: "9.6.6" } + - { cabal: "3.12", os: macOS-latest, ghc: "9.8.2" } + - { cabal: "3.12", os: macOS-latest, ghc: "9.10.1" } + + env: + cache-version: v0 # bump up this version to invalidate currently stored cache + steps: + - uses: actions/checkout@v4 + - uses: haskell-actions/setup@v2 + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Cache Cabal Store + id: cache + uses: actions/cache@v4 + with: + path: | + ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + dist-newstyle + key: cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-version }} + restore-keys: | + cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-version }} + - name: Build + run: | + set -ex + cabal configure --haddock-all --enable-tests --enable-benchmarks + cabal build all --write-ghc-environment-files=always + - name: Test + run: | + set -ex + cabal test all + - name: Doctest + # older ghc versions do not like some haddock examples + # linker on MacOS-13 complains too + # windows as always results in non-deterministic nonsense, so it will likely get disabled soon too. + # if: contains(fromJSON('["8.6.5", "8.8.4", "8.10.7", "9.0.2"]'), matrix.ghc) != true && matrix.os != 'macOS-13' + run: | + set -ex + cabal install doctest --ignore-project --overwrite-policy=always + cabal repl --build-depends=QuickCheck --with-compiler=doctest --repl-options='-w -Wdefault' + - name: Check Cabal Files + run: | + set -ex + cabal -vnormal check diff --git a/stack-extra-deps.yaml b/stack.ghc-8.4.4.yaml similarity index 98% rename from stack-extra-deps.yaml rename to stack.ghc-8.4.4.yaml index d68fce7..5f1cb8d 100644 --- a/stack-extra-deps.yaml +++ b/stack.ghc-8.4.4.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.30 +resolver: lts-12.26 packages: - Color extra-deps: diff --git a/stack.ghc-8.6.5.yaml b/stack.ghc-8.6.5.yaml new file mode 100644 index 0000000..5f1cb8d --- /dev/null +++ b/stack.ghc-8.6.5.yaml @@ -0,0 +1,15 @@ +resolver: lts-12.26 +packages: +- Color +extra-deps: +- JuicyPixels-3.3.5@sha256:5c67dc066d67f5045221a8202f701f4c77eab8220f44414c00fadcdc3e4f872b,3911 +- QuickCheck-2.13.2@sha256:ad4e5adbd1c9dc0221a44307b992cb040c515f31095182e47aa7e974bc461df1,6952 +- splitmix-0.0.3@sha256:455de9326ae5bbe5492cbb140fefb04cf988501e25b204dabaf755ab67400d9d,4835 +- cabal-doctest-1.0.8@sha256:34dff6369d417df2699af4e15f06bc181d495eca9c51efde173deae2053c197c,1491 +- doctest-0.16.2@sha256:2f96e9bbe9aee11b47453c82c24b3dc76cdbb8a2a7c984dfd60b4906d08adf68,6942 +- hspec-core-2.7.1@sha256:2696420050bafb1b690366b2c0ca8595a27c4597811df036f0c35cf19f46862b,4583 +- hspec-2.7.1@sha256:0aa48928ce80a34f8ff8c5ef114bb6807edfb8d884bcd7211eceed710e7fb7a8,1769 +- hspec-discover-2.7.1@sha256:e8ce36741c06b41de58069814a7d3b7314bdeaab35ae573e3c924739011e0c29,2243 +- massiv-test-0.1.2@sha256:93df921acadb56f81b35d3117e020e485b3b26c28a99e2053544878c92de2fcb,3859 +- massiv-0.4.5.0@sha256:a0e16ef4503c642cff1bbf686f1c89e87ac3bb6755f4d975ff8b5b8fc27b61db,4611 +- scheduler-1.4.2.1@sha256:26fb16ccf5f41ee9144f8c77a5228163968543ae5cc8242c761e69ff8f579e07,2863 diff --git a/stack.ghc-8.8.4.yaml b/stack.ghc-8.8.4.yaml new file mode 100644 index 0000000..5f1cb8d --- /dev/null +++ b/stack.ghc-8.8.4.yaml @@ -0,0 +1,15 @@ +resolver: lts-12.26 +packages: +- Color +extra-deps: +- JuicyPixels-3.3.5@sha256:5c67dc066d67f5045221a8202f701f4c77eab8220f44414c00fadcdc3e4f872b,3911 +- QuickCheck-2.13.2@sha256:ad4e5adbd1c9dc0221a44307b992cb040c515f31095182e47aa7e974bc461df1,6952 +- splitmix-0.0.3@sha256:455de9326ae5bbe5492cbb140fefb04cf988501e25b204dabaf755ab67400d9d,4835 +- cabal-doctest-1.0.8@sha256:34dff6369d417df2699af4e15f06bc181d495eca9c51efde173deae2053c197c,1491 +- doctest-0.16.2@sha256:2f96e9bbe9aee11b47453c82c24b3dc76cdbb8a2a7c984dfd60b4906d08adf68,6942 +- hspec-core-2.7.1@sha256:2696420050bafb1b690366b2c0ca8595a27c4597811df036f0c35cf19f46862b,4583 +- hspec-2.7.1@sha256:0aa48928ce80a34f8ff8c5ef114bb6807edfb8d884bcd7211eceed710e7fb7a8,1769 +- hspec-discover-2.7.1@sha256:e8ce36741c06b41de58069814a7d3b7314bdeaab35ae573e3c924739011e0c29,2243 +- massiv-test-0.1.2@sha256:93df921acadb56f81b35d3117e020e485b3b26c28a99e2053544878c92de2fcb,3859 +- massiv-0.4.5.0@sha256:a0e16ef4503c642cff1bbf686f1c89e87ac3bb6755f4d975ff8b5b8fc27b61db,4611 +- scheduler-1.4.2.1@sha256:26fb16ccf5f41ee9144f8c77a5228163968543ae5cc8242c761e69ff8f579e07,2863