|
| 1 | +name: Caching of dependencies |
| 2 | + |
| 3 | +# 2021-11-30: NOTE: This workflow currently a trimmed copy of a main `test.yml` workflow. Workflows need further deduplication: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#overview |
| 4 | + |
| 5 | +defaults: |
| 6 | + run: |
| 7 | + shell: bash |
| 8 | + |
| 9 | +# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency. |
| 10 | +concurrency: |
| 11 | + group: ${{ github.head_ref }}-${{ github.workflow }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - master |
| 18 | + schedule: |
| 19 | + # Try to save snapshot every day at 03:45 UTC (~21:45 in California) |
| 20 | + - cron: "45 3 * * *" |
| 21 | + pull_request: |
| 22 | + branches: |
| 23 | + - '**' |
| 24 | + |
| 25 | +jobs: |
| 26 | + pre_job: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 30 | + should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }} |
| 31 | + steps: |
| 32 | + - id: skip_check |
| 33 | + |
| 34 | + with: |
| 35 | + cancel_others: false |
| 36 | + paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", "install/**", "**.nix", "flake.lock", "**/README.md", "FUNDING.yml", ".circleci/**"]' |
| 37 | + # If we only change ghcide downstream packages we have not test ghcide itself |
| 38 | + - id: skip_ghcide_check |
| 39 | + |
| 40 | + with: |
| 41 | + cancel_others: false |
| 42 | + paths_ignore: '["hls-test-utils/**", "plugins/**", "src/**", "exe/**", "test/**", "shake-bench/**"]' |
| 43 | + |
| 44 | + deps: |
| 45 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 46 | + needs: pre_job |
| 47 | + runs-on: ${{ matrix.os }} |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + ghc: ["9.0.1", '8.10.7', '8.10.6', "8.10.5", "8.8.4", "8.8.3", "8.6.5"] |
| 51 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 52 | + exclude: |
| 53 | + - os: windows-latest |
| 54 | + ghc: '8.8.3' |
| 55 | + |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v2 |
| 58 | + with: |
| 59 | + submodules: true |
| 60 | + - uses: haskell/actions/setup@v1 |
| 61 | + with: |
| 62 | + ghc-version: ${{ matrix.ghc }} |
| 63 | + cabal-version: "3.4" |
| 64 | + |
| 65 | + - if: matrix.os == 'windows-latest' |
| 66 | + name: Set some window specific things |
| 67 | + run: | |
| 68 | + echo "CABAL_STORE_DIR=$SYSTEMDRIVE\\SR" >> $GITHUB_ENV |
| 69 | + echo "CABAL_PKGS_DIR=~\\AppData\\cabal\\packages" >> $GITHUB_ENV |
| 70 | +
|
| 71 | + - if: matrix.os != 'windows-latest' |
| 72 | + name: Set some linux/macOS specific things |
| 73 | + run: | |
| 74 | + echo "CABAL_STORE_DIR=~/.cabal/store" >> $GITHUB_ENV |
| 75 | + echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV |
| 76 | +
|
| 77 | + - if: matrix.os == 'macOS-latest' && matrix.ghc == '8.10.5' |
| 78 | + name: Workaround for GHC 8.10.5 on macOS |
| 79 | + run: | |
| 80 | + echo "# uninstalling CommandLineTools (see https://github.com/haskell/haskell-language-server/issues/1913#issuecomment-861667786)" |
| 81 | + sudo rm -rf /Library/Developer/CommandLineTools |
| 82 | +
|
| 83 | + # Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file |
| 84 | + - if: matrix.ghc == '9.0.1' |
| 85 | + name: Use modified cabal.project for ghc9 |
| 86 | + run: cp cabal-ghc901.project cabal.project |
| 87 | + |
| 88 | + - if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest' |
| 89 | + name: Modify cabal.project to workaround segfaults for ghc-8.8.4 and windows |
| 90 | + run: | |
| 91 | + echo "package floskell" >> cabal.project |
| 92 | + echo " ghc-options: -O0" >> cabal.project |
| 93 | +
|
| 94 | + - name: Cache Cabal |
| 95 | + uses: actions/cache@v2 |
| 96 | + env: |
| 97 | + cache-name: cache-cabal |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ${{ env.CABAL_PKGS_DIR }} |
| 101 | + ${{ env.CABAL_STORE_DIR }} |
| 102 | + key: v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }} |
| 103 | + restore-keys: | |
| 104 | + v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }} |
| 105 | + v2-${{ runner.os }}-${{ matrix.ghc }}-build- |
| 106 | + v2-${{ runner.os }}-${{ matrix.ghc }} |
| 107 | +
|
| 108 | + - run: cabal update |
| 109 | + |
| 110 | + # Need this to work around filepath length limits in Windows |
| 111 | + - name: Shorten binary names |
| 112 | + run: | |
| 113 | + sed -i.bak -e 's/haskell-language-server/hls/g' \ |
| 114 | + -e 's/haskell_language_server/hls/g' \ |
| 115 | + haskell-language-server.cabal cabal.project |
| 116 | + sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ |
| 117 | + src/**/*.hs exe/*.hs |
| 118 | +
|
| 119 | + # repeating builds to workaround segfaults in windows and ghc-8.8.4 |
| 120 | + - name: Build |
| 121 | + run: cabal build --only-dependencies || cabal build --only-dependencies || cabal build --only-dependencies |
0 commit comments