|
| 1 | +name: HLint |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + create: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + |
| 14 | + env: |
| 15 | + # Modify this value to "invalidate" the cabal cache. |
| 16 | + CABAL_CACHE_VERSION: "2022-12-30" |
| 17 | + |
| 18 | + HLINT_VERSION: "3.5" |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Install Haskell |
| 22 | + uses: input-output-hk/setup-haskell@v1 |
| 23 | + id: setup-haskell |
| 24 | + with: |
| 25 | + ghc-version: 9.2.4 |
| 26 | + cabal-version: 3.8.1.0 |
| 27 | + |
| 28 | + - name: Cabal update |
| 29 | + run: cabal update |
| 30 | + |
| 31 | + - name: Get hlint |
| 32 | + run: cabal get "hlint-$HLINT_VERSION" |
| 33 | + |
| 34 | + - name: Build dry run for hlint |
| 35 | + run: | |
| 36 | + cd "hlint-$HLINT_VERSION" |
| 37 | + cabal build all --dry-run |
| 38 | +
|
| 39 | + # For users who fork cardano-node and want to define a writable cache, then can set up their own |
| 40 | + # S3 bucket then define in their forked repository settings the following secrets: |
| 41 | + # |
| 42 | + # AWS_ACCESS_KEY_ID |
| 43 | + # AWS_SECRET_ACCESS_KEY |
| 44 | + # BINARY_CACHE_URI |
| 45 | + # BINARY_CACHE_REGION |
| 46 | + - name: Cabal cache over S3 |
| 47 | + uses: action-works/cabal-cache-s3@v1 |
| 48 | + env: |
| 49 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 50 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 51 | + with: |
| 52 | + region: ${{ secrets.BINARY_CACHE_REGION }} |
| 53 | + dist-dir: hlint-${{ env.HLINT_VERSION }}/dist-newstyle |
| 54 | + store-path: ${{ steps.setup-haskell.outputs.cabal-store }} |
| 55 | + threads: 16 |
| 56 | + archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }} |
| 57 | + skip: "${{ secrets.BINARY_CACHE_URI == '' }}" |
| 58 | + |
| 59 | + # It's important to ensure that people who fork this repository can not only successfully build in |
| 60 | + # CI by default, but also have meaning cabal store caching. |
| 61 | + # |
| 62 | + # Because syncing with S3 requires credentials, we cannot rely on S3 for this. For this reason a |
| 63 | + # https fallback is used. The https server mirrors the content of the S3 bucket. The https cabal |
| 64 | + # store archive is read-only for security reasons. |
| 65 | + # |
| 66 | + # Users who fork this repository who want to have a writable cabal store archive are encouraged |
| 67 | + # to set up their own S3 bucket. |
| 68 | + - name: Cabal cache over HTTPS |
| 69 | + uses: action-works/cabal-cache-s3@v1 |
| 70 | + with: |
| 71 | + dist-dir: hlint-${{ env.HLINT_VERSION }}/dist-newstyle |
| 72 | + store-path: ${{ steps.setup-haskell.outputs.cabal-store }} |
| 73 | + threads: 16 |
| 74 | + archive-uri: https://iohk.cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }} |
| 75 | + skip: "${{ secrets.BINARY_CACHE_URI != '' }}" |
| 76 | + enable-save: false |
| 77 | + |
| 78 | + - name: Build hlint |
| 79 | + run: | |
| 80 | + cd "hlint-$HLINT_VERSION" |
| 81 | + cabal build all |
| 82 | +
|
| 83 | + - name: Install hlint |
| 84 | + run: | |
| 85 | + cd "hlint-$HLINT_VERSION" |
| 86 | + cabal install exe:hlint |
| 87 | +
|
| 88 | + - name: Remove hlint build directory |
| 89 | + run: rm -rf "hlint-$HLINT_VERSION" |
| 90 | + |
| 91 | + - name: hlint installation directory |
| 92 | + run: find . -name hlint |
| 93 | + |
| 94 | + - name: Add installation directory to path |
| 95 | + run: echo "PATH=$HOME/.cabal/bin:$PATH" >> $GITHUB_ENV |
| 96 | + |
| 97 | + - uses: actions/checkout@v2 |
| 98 | + |
| 99 | + - name: Run hlint over all Haskell files |
| 100 | + run: | |
| 101 | + hlint . --threads=4 |
0 commit comments