fjcaetano / mint-action

Github Action to install Swift packages using Mint
3 stars 0 forks source link

Cache mint binary #1

Open potmo opened 1 year ago

potmo commented 1 year ago

It takes an awful long time to build mint everytime. maybe it would be possible to cache the mint binary (and the installed packages) with actions/checkout@v2 ot something? Or am I supposed to do that as a consumer of the package?

fjcaetano commented 1 year ago

What does "an awful long time" means, exactly?

This action builds mint from source every time. It might be possible to cache the binary, but the cache would have to be invalidated when the OS image where the action is running changes.

My suggestion would be to give it a go at caching it yourself. If it works and you want to open a PR to add that to this action, it will be more than welcome.

potmo commented 1 year ago

I gave it a go with caching mint manually and maybe its better to do it outside this action. For later reference for anyone coming here looking for a solution (its just using vanilla actions):

jobs:
  do_stuff_with_cached_mint:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout Mint
        uses: actions/checkout@v3
        with:
          repository: yonaskolb/Mint
          path: ./Mint
          ref: 0.17.4

      - name: Cache Mint
        id: cache-mint
        uses: actions/cache@v3
        with:
          path: |
                ./mint-cache
                ~/.mint
                ~/.mint/bin
          key: ${{ runner.os }}-mint-cache-0001-${{ hashFiles('**/Mintfile') }}

      - name: Build Mint
        if: steps.cache-mint.outputs.cache-hit != 'true'
        run: |
             cd ./Mint
             swift build --disable-sandbox -c release
             cd ..
             cp -f -r ./Mint/.build/release/ ./mint-cache

      - name: Remove checkedout Mint
        run: |
            rm -rf ./Mint

      - name: Install mint packages
        run: ./mint-cache/mint bootstrap --verbose

      - name: Run swift Lint for example
        run: ./mint-cache/mint run swiftlint lint ${{ github.workspace }} --config ${{ github.workspace }}/.swiftlint.yml