From 7e445ea474d42ce0fa45cb504f1e2cdd6ce122b3 Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:03:41 +0200 Subject: [PATCH 1/6] No need for Ci on PRs as it is triggered by all pushes --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 821d586..f2593c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ name: Build and test -on: [push, pull_request, workflow_dispatch] +on: [push, workflow_dispatch] jobs: test: From 6dbdac0dfdf7b48b5674b03886ac5a097a47a0cd Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:08:50 +0200 Subject: [PATCH 2/6] Use matrix in CI --- .github/workflows/test.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2593c6..07f5bcf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,14 +4,21 @@ on: [push, workflow_dispatch] jobs: test: - runs-on: ubuntu-20.04 + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + ghc-version: ['9.4', '9.6'] steps: - - name: Set up haskell + - name: Set up GHC ${{ matrix.ghc-version }} uses: haskell/actions/setup@v1 with: - ghc-version: '9.0.1' - cabal-version: '3.4' + ghc-version: ${{ matrix.ghc-version }} + cabal-version: 'latest' + cabal-update: true - name: Checkout repository content uses: actions/checkout@v2 From a9779da6bbcffa7b38b9db559773b687cb4a2a7e Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:10:05 +0200 Subject: [PATCH 3/6] Update GH action versions --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07f5bcf..f7b6219 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,14 +14,14 @@ jobs: steps: - name: Set up GHC ${{ matrix.ghc-version }} - uses: haskell/actions/setup@v1 + uses: haskell-actions/setup@v2 with: ghc-version: ${{ matrix.ghc-version }} cabal-version: 'latest' cabal-update: true - name: Checkout repository content - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Prepare cabal cache uses: actions/cache@v2 From ba0af6c945c4be82d5dfc01913dc7ec5c1a59c18 Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:21:29 +0200 Subject: [PATCH 4/6] Improve CI caching --- .github/workflows/test.yml | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7b6219..dcce0b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ jobs: - name: Set up GHC ${{ matrix.ghc-version }} uses: haskell-actions/setup@v2 + id: setup with: ghc-version: ${{ matrix.ghc-version }} cabal-version: 'latest' @@ -23,23 +24,34 @@ jobs: - name: Checkout repository content uses: actions/checkout@v3 - - name: Prepare cabal cache - uses: actions/cache@v2 + - name: Configure the build + run: | + cabal configure --enable-tests + cabal build --dry-run + # The last step generates dist-newstyle/cache/plan.json for the cache key + + - name: Restore cached dependencies + uses: actions/cache/restore@v3 + id: cache env: - cache-name: cache-cabal + key: ${{ runner.os }}-ghc-${{ steps.setup-outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: - path: ~/.cabal - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} + restore-keys: ${{ env.key }} + - name: Install dependencies - run: | - cabal update - cabal build --only-dependencies --enable-tests --enable-benchmarks + run: cabal build all --only-dependencies --enable-tests + - name: Build project - run: cabal build --enable-tests --enable-benchmarks all + run: cabal build --enable-tests all - name: Run tests run: cabal test --test-show-details=streaming + + - name: Save cached dependencies + uses: actions/cache/save@v3 + if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }} + with: + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ steps.cache.outputs.cache-primary-key }} From 68c9c63d02477ba8dad1d8b1179abd26982b3bb5 Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:35:32 +0200 Subject: [PATCH 5/6] Add more GHC versions to check --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dcce0b7..76de060 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ghc-version: ['9.4', '9.6'] + ghc-version: ['8.10', '9.2', '9.4', '9.6', '9.8'] steps: - name: Set up GHC ${{ matrix.ghc-version }} From 7b9ee755feb350214d8cdc2ff1d502ad05aef56c Mon Sep 17 00:00:00 2001 From: Mirko Westermeier Date: Mon, 29 Apr 2024 12:49:55 +0200 Subject: [PATCH 6/6] Unify workflows --- .github/workflows/haddock-pages.yml | 71 ------------------- .../workflows/{test.yml => test-apidocs.yml} | 30 +++++++- README.md | 3 +- 3 files changed, 29 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/haddock-pages.yml rename .github/workflows/{test.yml => test-apidocs.yml} (66%) diff --git a/.github/workflows/haddock-pages.yml b/.github/workflows/haddock-pages.yml deleted file mode 100644 index 9b434e5..0000000 --- a/.github/workflows/haddock-pages.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Publish API docs - -on: [push, pull_request, workflow_dispatch] - -env: - HADDOCK_DIR: haddock-html - PAGES_DIR: gh-pages - -jobs: - - haddock: - runs-on: ubuntu-20.04 - steps: - - - name: Set up haskell - uses: haskell/actions/setup@v1 - with: - ghc-version: '9.0.1' - cabal-version: '3.4' - - - name: Checkout repository content - uses: actions/checkout@v2 - - - name: Prepare cabal cache - uses: actions/cache@v2 - env: - cache-name: cache-cabal - with: - path: ~/.cabal - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Prepare cabal - run: cabal update - - - name: Generate haddock API docs - run: cabal haddock --builddir=haddock_build - - - name: Find generated HTML - run: mv $(find haddock_build -wholename '*doc/html/trivialini' | head -n 1) $HADDOCK_DIR - - - name: Store generated API docs - uses: actions/upload-artifact@v2 - with: - path: ${{ env.HADDOCK_DIR }} - name: haddock-html - - deploy-pages: - needs: haddock - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-20.04 - steps: - - - name: Load API docs - uses: actions/download-artifact@v2 - with: - name: haddock-html - path: ${{ env.PAGES_DIR }} - - - name: Disable GitHub Pages' Jekyll - run: touch $PAGES_DIR/.nojekyll - - - name: Deploy to GitHub Pages - uses: crazy-max/ghaction-github-pages@v2 - with: - target_branch: gh-pages - build_dir: ${{ env.PAGES_DIR }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test-apidocs.yml similarity index 66% rename from .github/workflows/test.yml rename to .github/workflows/test-apidocs.yml index 76de060..0a6226b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-apidocs.yml @@ -1,9 +1,9 @@ -name: Build and test +name: Build, Test, API Docs on: [push, workflow_dispatch] jobs: - test: + build_test_docs: name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -49,9 +49,35 @@ jobs: - name: Run tests run: cabal test --test-show-details=streaming + - name: Build API docs + run: cabal haddock --builddir=haddock_build --haddock-hyperlinked-source --haddock-html-location='https://hackage.haskell.org/package/$pkg-$version/docs' + - name: Save cached dependencies uses: actions/cache/save@v3 if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }} with: path: ${{ steps.setup.outputs.cabal-store }} key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Collect generated API docs + run: mv $(find haddock_build -wholename '*doc/html/trivialini' | head -n 1) haddock_html + + - name: Store generated API docs as artifact + uses: actions/upload-artifact@v2 + with: + path: haddock_html + + deploy_docs: + needs: build_test_docs + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deploy + uses: actions/deploy-pages@v2 diff --git a/README.md b/README.md index c9432c6..bcda3a3 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ **Ultra light weight ini file parser, written in Haskell** -[![Build and test](https://github.com/memowe/trivialini/actions/workflows/test.yml/badge.svg)](https://github.com/memowe/trivialini/actions/workflows/test.yml) -[![Publish API docs](https://github.com/memowe/trivialini/actions/workflows/haddock-pages.yml/badge.svg)](https://github.com/memowe/trivialini/actions/workflows/haddock-pages.yml) +[![Test & API Docs pipeline](https://github.com/memowe/trivialini/actions/workflows/test-apidocs.yml/badge.svg)](https://github.com/memowe/trivialini/actions/workflows/test-apidocs.yml) [![API docs](https://img.shields.io/badge/Haddock-Documentation-8a80a8?style=flat&logo=haskell&logoColor=lightgray)](https://mirko.westermeier.de/trivialini/Trivialini.html) ## Overview