diff --git a/.github/actions/pnpm-install/action.yml b/.github/actions/pnpm-install/action.yml new file mode 100644 index 00000000..82f7d0af --- /dev/null +++ b/.github/actions/pnpm-install/action.yml @@ -0,0 +1,60 @@ +######################################################################################## +# "pnpm install" composite action # +#--------------------------------------------------------------------------------------# +# Cache: # +# - Downloaded zip archive (multi-arch, preserved across pnpm.lock changes) # +# - Yarn install state (discarded in pnpm.lock changes) # +# References: # +# - bench: https://gist.github.com/belgattitude/0ecd26155b47e7be1be6163ecfbb0f0b # +# - vs @setup/node: https://github.com/actions/setup-node/issues/325 # +######################################################################################## + +name: 'PNPM install' +description: 'Run pnpm install with cache enabled' + +runs: + using: 'composite' + + steps: + - uses: pnpm/action-setup@v2 + + # If you're not setting the packageManager field in package.json, add the version here + with: + version: 7.16.1 + + - name: Expose pnpm config(s) through "$GITHUB_OUTPUT" + if: ${{ !env.ACT }} + id: pnpm-config + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Cache rotation keys + id: cache-rotation + if: ${{ !env.ACT }} + shell: bash + run: | + echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + if: ${{ !env.ACT }} + with: + path: ${{ steps.pnpm-config.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}- + + # Prevent store to grow over time (not needed with yarn) + # Note: not perfect as it prune too much in monorepos so the idea + # is to use cache-rotation as above. In the future this might work better. + #- name: Prune pnpm store + # shell: bash + # run: pnpm prune store + + - name: Install dependencies + shell: bash + run: pnpm install --frozen-lockfile --strict-peer-dependencies --prefer-offline + env: + # Other environment variables + HUSKY: '0' # By default do not run HUSKY install \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 2dca9f70..dc0be3b3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -109,6 +109,9 @@ jobs: - name: Grant execute permission to gradlew run: chmod +x gradlew + - name: 📥 Monorepo install all deps & pnpm + uses: ./.github/actions/pnpm-install + - name: Test working-directory: e2e run: pnpm e2e