|
1 | | -name: Publish API docs |
| 1 | +name: Test and Publish API docs |
2 | 2 |
|
3 | 3 | on: [push, pull_request, workflow_dispatch] |
4 | 4 |
|
5 | 5 | env: |
6 | 6 | HADDOCK_DIR: haddock-html |
| 7 | + HADDOCK_BUILD_DIR: haddock_build |
7 | 8 | PAGES_DIR: gh-pages |
8 | 9 |
|
9 | 10 | jobs: |
10 | 11 |
|
11 | | - haddock: |
| 12 | + build_test_doc: |
| 13 | + name: Build, Test, API docs |
12 | 14 | runs-on: ubuntu-latest |
13 | 15 | steps: |
14 | 16 |
|
15 | | - - name: Set up haskell |
| 17 | + - name: Checkout repository content |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Haskell |
16 | 21 | uses: haskell-actions/setup@v2 |
| 22 | + id: setup |
17 | 23 | with: |
18 | 24 | ghc-version: '9.2.7' |
19 | 25 | cabal-version: '3.6.2.0' |
20 | 26 |
|
21 | | - - name: Checkout repository content |
22 | | - uses: actions/checkout@v4 |
| 27 | + - name: Configure the build |
| 28 | + # generates dist-newstyle/cache/plan.json |
| 29 | + run: | |
| 30 | + cabal configure --enable-tests --enable-benchmarks |
| 31 | + cabal build all --dry-run |
23 | 32 |
|
24 | 33 | - name: Configure cache |
25 | 34 | uses: actions/cache@v4 |
26 | 35 | with: |
27 | | - path: | |
28 | | - ~/.cabal/packages |
29 | | - ~/.cabal/store |
30 | | - dist-newstyle |
31 | | - key: cabal-${{ hashFiles('**/*.cabal', '**/*.cabal.project', '**/*.cabal.project.freeze') }} |
| 36 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 37 | + key: cabal-${{ hashFiles('**/plan.json') }} |
32 | 38 | restore-keys: cabal- |
33 | 39 |
|
34 | | - - name: Prepare cabal |
35 | | - run: cabal update |
| 40 | + - name: Install dependencies |
| 41 | + run: cabal build --only-dependencies all |
| 42 | + |
| 43 | + - name: Build project |
| 44 | + run: cabal build all |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + run: cabal test --test-show-details=streaming all |
36 | 48 |
|
37 | 49 | - name: Generate haddock API docs |
38 | | - run: cabal haddock --builddir=haddock_build --haddock-hyperlinked-source --haddock-html-location='https://hackage.haskell.org/package/$pkg-$version/docs' |
| 50 | + run: cabal haddock --builddir=$HADDOCK_BUILD_DIR --haddock-hyperlinked-source --haddock-html-location='https://hackage.haskell.org/package/$pkg-$version/docs' |
39 | 51 |
|
40 | 52 | - name: Find generated HTML |
41 | | - run: mv $(find haddock_build -wholename '*doc/html/circular-enum' | head -n 1) $HADDOCK_DIR |
| 53 | + run: mv $(find $HADDOCK_BUILD_DIR -wholename '*doc/html/circular-enum' | head -n 1) $HADDOCK_DIR |
42 | 54 |
|
43 | 55 | - name: Store generated API docs |
44 | 56 | uses: actions/upload-artifact@v4 |
|
52 | 64 | path: ${{ env.HADDOCK_DIR }} |
53 | 65 |
|
54 | 66 | deploy: |
55 | | - needs: haddock |
| 67 | + name: Deploy API docs |
| 68 | + needs: build_test_doc |
56 | 69 | if: github.ref == 'refs/heads/main' |
57 | 70 | runs-on: ubuntu-latest |
58 | 71 | permissions: |
|
0 commit comments