diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 3a41c01dca2..eb2c6103f53 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,15 +1,33 @@ name: Setup node and pnpm -description: Configure the Node.js and pnpm versions +description: | + Configures Node, pnpm, cache, performs pnpm install inputs: node-version: - description: 'The Node.js version to use' + description: Node.js version required: true - default: 22.6.2 + default: 22.6.0 pnpm-version: - description: 'The pnpm version to use' + description: Pnpm version required: true default: 9.7.1 + pnpm-run-install: + description: Whether to run pnpm install + required: false + default: true + pnpm-restore-cache: + description: Whether to restore cache + required: false + default: true + pnpm-install-cache-key: + description: The cache key for the pnpm install cache + default: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + +outputs: + pnpm-store-path: + description: The resolved pnpm store path + pnpm-install-cache-key: + description: The cache key used for pnpm install cache runs: using: composite @@ -30,19 +48,29 @@ runs: version: ${{ inputs.pnpm-version }} run_install: false - - name: Get pnpm store directory + - name: Get pnpm store path shell: bash run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + STORE_PATH=$(pnpm store path --silent) + echo "STORE_PATH=$STORE_PATH" >> $GITHUB_ENV + echo "Pnpm store path resolved to: $STORE_PATH" - - name: Setup pnpm cache + - name: Restore pnpm install cache + if: ${{ inputs.pnpm-restore-cache == 'true' }} uses: actions/cache@v4 with: path: ${{ env.STORE_PATH }} - key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + key: ${{ inputs.pnpm-install-cache-key }} restore-keys: | + pnpm-store-${{ inputs.pnpm-version }}- pnpm-store- - pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - shell: bash + - name: Run pnpm install + if: ${{ inputs.pnpm-run-install == 'true' }} + shell: bash run: pnpm install + + # Set the cache key output + - run: | + echo "pnpm-install-cache-key=${{ inputs.pnpm-install-cache-key }}" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03564ec6f95..b2ffdd908f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,8 +36,6 @@ jobs: run: sudo ethtool -K eth0 tx off rx off - uses: actions/checkout@v4 - with: - fetch-depth: 25 - uses: dorny/paths-filter@v3 id: filter with: @@ -69,40 +67,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - timeout-minutes: 720 - with: - path: ${{ env.STORE_PATH }} - key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - pnpm-store- - pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - - run: pnpm install - name: Lint staged run: | git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF}...${GITHUB_SHA} @@ -115,47 +87,20 @@ jobs: steps: - uses: actions/checkout@v4 - with: - fetch-depth: 25 - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off - - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - timeout-minutes: 720 - with: - path: ${{ env.STORE_PATH }} - key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - pnpm-store- - pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - - run: pnpm install - run: pnpm run build:all env: DO_NOT_TRACK: 1 # Disable Turbopack telemetry - name: Cache build uses: actions/cache@v4 - timeout-minutes: 10 with: path: ./* key: ${{ github.sha }}-${{ github.run_number }} @@ -165,24 +110,19 @@ jobs: needs: [changes, build] if: ${{ needs.changes.outputs.needs_tests == 'true' }} steps: - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off + - uses: actions/checkout@v4 - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-run-install: false + pnpm-restore-cache: false # Full build is restored below + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Restore build uses: actions/cache@v4 - timeout-minutes: 10 with: path: ./* key: ${{ github.sha }}-${{ github.run_number }} @@ -231,24 +171,21 @@ jobs: steps: - uses: actions/checkout@v4 - with: - fetch-depth: 25 - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-run-install: false + pnpm-restore-cache: false # Full build is restored below + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Restore build + uses: actions/cache@v4 with: - version: ${{ env.PNPM_VERSION }} - run_install: false - - - run: pnpm install + path: ./* + key: ${{ github.sha }}-${{ github.run_number }} - name: Start LocalStack run: pnpm docker:start @@ -341,24 +278,19 @@ jobs: env: SUITE_NAME: ${{ matrix.suite }} steps: - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off + - uses: actions/checkout@v4 - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-run-install: false + pnpm-restore-cache: false # Full build is restored below + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Restore build uses: actions/cache@v4 - timeout-minutes: 10 with: path: ./* key: ${{ github.sha }}-${{ github.run_number }} @@ -449,24 +381,19 @@ jobs: POSTGRES_DB: payloadtests steps: - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off + - uses: actions/checkout@v4 - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-run-install: false + pnpm-restore-cache: false # Full build is restored below + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Restore build uses: actions/cache@v4 - timeout-minutes: 10 with: path: ./* key: ${{ github.sha }}-${{ github.run_number }} @@ -506,24 +433,19 @@ jobs: needs: [changes, build] if: ${{ needs.changes.outputs.needs_tests == 'true' }} steps: - # https://github.com/actions/virtual-environments/issues/1187 - - name: tune linux network - run: sudo ethtool -K eth0 tx off rx off + - uses: actions/checkout@v4 - - name: Setup Node@${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 + - name: Node setup + uses: ./.github/actions/setup with: node-version: ${{ env.NODE_VERSION }} - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: ${{ env.PNPM_VERSION }} - run_install: false + pnpm-version: ${{ env.PNPM_VERSION }} + pnpm-run-install: false + pnpm-restore-cache: false # Full build is restored below + pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Restore build uses: actions/cache@v4 - timeout-minutes: 10 with: path: ./* key: ${{ github.sha }}-${{ github.run_number }}