diff --git a/.cirrus.yml b/.cirrus.yml index b07545ae67..00fa78eca5 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -17,10 +17,20 @@ build_task: '**.hs' ) - stack_cache: + stack_deps_cache: folders: /.stack - fingerprint_script: cat postgrest.cabal stack.yaml.lock - reupload_on_changes: false + fingerprint_script: + - echo $CIRRUS_OS + - stack --version + - cat stack.yaml.lock + + stack_work_cache: + folders: .stack-work + fingerprint_script: + - echo $CIRRUS_OS + - stack --version + - cat stack.yaml.lock + - find main src -type f -iname '*.hs' -exec md5sum "{}" + build_script: | stack build -j 1 --local-bin-path . --copy-bins diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index af10bc667d..d4d802a1d3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -91,14 +91,12 @@ jobs: runs-on: ubuntu-22.04 cache: | ~/.stack - .stack-work # no artifact for Linux, because we use the static build - name: MacOS runs-on: macos-12 cache: | ~/.stack - .stack-work artifact: postgrest-macos-x64 - name: Windows @@ -106,7 +104,6 @@ jobs: cache: | ~\AppData\Roaming\stack ~\AppData\Local\Programs\stack - .stack-work deps: Add-Content $env:GITHUB_PATH $env:PGBIN artifact: postgrest-windows-x64 @@ -114,17 +111,28 @@ jobs: runs-on: ${{ matrix.runs-on }} steps: - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 - - name: Restore stack working files cache + - name: Install dependencies + if: matrix.deps + run: ${{ matrix.deps }} + - name: Restore ~/.stack cache uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - id: restore-cache + id: restore-stack with: path: ${{ matrix.cache }} - key: stack-${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }} + key: stack-${{ runner.os }}-deps-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal') }} restore-keys: | - stack-${{ runner.os }}- - - name: Install dependencies - if: matrix.deps - run: ${{ matrix.deps }} + stack-${{ runner.os }}-deps-${{ hashFiles('stack.yaml.lock') }}- + stack-${{ runner.os }}-deps- + - name: Restore .stack-work cache + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + id: restore-stack-work + with: + path: .stack-work + key: stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal') }}-${{ hashFiles('main/*.hs', 'src/**/*.hs') }} + restore-keys: | + stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal') }}- + stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}- + stack-${{ runner.os }}-work- - name: Build with Stack run: stack build --lock-file error-on-write --local-bin-path result --copy-bins - name: Strip Executable @@ -138,12 +146,18 @@ jobs: result/postgrest result/postgrest.exe if-no-files-found: error - - name: Save stack working files cache + - name: Save .stack-work cache + if: startsWith(github.ref, 'refs/heads/') + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: .stack-work + key: ${{ steps.restore-stack-work.outputs.cache-primary-key }} + - name: Save ~/.stack cache if: startsWith(github.ref, 'refs/heads/') uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ${{ matrix.cache }} - key: ${{ steps.restore-cache.outputs.cache-primary-key }} + key: ${{ steps.restore-stack.outputs.cache-primary-key }} freebsd: @@ -177,29 +191,44 @@ jobs: - name: Fix caching run: | mkdir ~/.cabal - - name: Restore cache + - name: Restore .cabal cache uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - id: restore-cache + id: restore-cabal with: path: | ~/.cabal/packages ~/.cabal/store - dist-newstyle - key: cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('postgrest.cabal', 'cabal.project', 'cabal.project.freeze') }} + key: cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }} restore-keys: | - cabal-${{ runner.os }}-${{ matrix.ghc }}- + cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}- + cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal- + - name: Restore dist-newstyle cache + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + id: restore-dist-newstyle + with: + path: dist-newstyle + key: cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }}-${{ hashFiles('**/*.hs') }} + restore-keys: | + cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }}- + cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}- + cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle- - name: Install dependencies run: | cabal update cabal build --only-dependencies --enable-tests --enable-benchmarks - name: Build run: cabal build --enable-tests --enable-benchmarks all - - name: Save cache + - name: Save dist-newstyle cache + if: startsWith(github.ref, 'refs/heads/') + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: dist-newstyle + key: ${{ steps.restore-dist-newstyle.outputs.cache-primary-key }} + - name: Save .cabal cache if: startsWith(github.ref, 'refs/heads/') uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: | ~/.cabal/packages ~/.cabal/store - dist-newstyle - key: ${{ steps.restore-cache.outputs.cache-primary-key }} + key: ${{ steps.restore-cabal.outputs.cache-primary-key }}