From 4f9464ff578d5ddae1e04b577a50ed8f23d046b9 Mon Sep 17 00:00:00 2001 From: Danilo Velasquez Date: Mon, 23 Dec 2024 08:48:47 +0100 Subject: [PATCH 1/2] ci: refactored actions to be more reusable --- .github/workflows/pr.yml | 80 ++----------- .github/workflows/publish-demo.yml | 36 +----- .github/workflows/release-canary.yml | 164 -------------------------- .github/workflows/release.yml | 122 +++---------------- .github/workflows/setup.yml | 52 ++++++++ .github/workflows/update-lockfile.yml | 53 ++------- pnpm-lock.yaml | 20 ++-- 7 files changed, 102 insertions(+), 425 deletions(-) delete mode 100644 .github/workflows/release-canary.yml create mode 100644 .github/workflows/setup.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1c0efa19..b6b2be91 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,86 +8,24 @@ on: branches: [main] jobs: - install_dependencies: - name: Install dependencies & lint + setup: + uses: ./.github/workflows/setup.yml + + lint: + name: Lint + needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - - name: Lint run: pnpm lint - run_cypress: + e2e: name: E2E tests + needs: setup runs-on: ubuntu-latest - needs: install_dependencies steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - - name: Build library run: pnpm lerna:build @@ -100,7 +38,5 @@ jobs: wait-on: 'http://127.0.0.1:8080/lighthouse-viewer/' command: pnpm cypress:run env: - # pass the Dashboard record key as an environment variable CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-demo.yml b/.github/workflows/publish-demo.yml index ddc1becc..471ac1e6 100644 --- a/.github/workflows/publish-demo.yml +++ b/.github/workflows/publish-demo.yml @@ -7,45 +7,17 @@ on: - fix/pnpm-github-actions jobs: + setup: + uses: ./.github/workflows/setup.yml + release: name: Update demo pages + needs: setup runs-on: ubuntu-latest env: CI: 'true' steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - name: Build libraries run: pnpm lerna:build diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml deleted file mode 100644 index c8b12727..00000000 --- a/.github/workflows/release-canary.yml +++ /dev/null @@ -1,164 +0,0 @@ -name: Release Canary Version - -on: - push: - branches: - - build/ci - - ci/* - - fix/pnpm-github-actions - -jobs: - install_dependencies: - name: Install dependencies & lint - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Cache node_modules 📦 - uses: actions/cache@v4.1.2 - with: - path: | - ~/.pnpm-store - /home/runner/.cache/Cypress - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 8.7.4 - run_install: | - - recursive: true - args: [--frozen-lockfile] - - - name: Lint - run: pnpm lint - - # run_cypress: - # name: E2E tests - # runs-on: ubuntu-latest - # needs: install_dependencies - - # steps: - # - uses: actions/checkout@v2 - # - name: Cache node_modules 📦 - # uses: actions/cache@v2.1.7 - # with: - # path: | - # ~/.pnpm-store - # /home/runner/.cache/Cypress - # key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - # restore-keys: | - # ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - # ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - # - name: Use Node.js 18.x - # uses: actions/setup-node@v2 - # with: - # node-version: 18.17.1 - - # - uses: pnpm/action-setup@v2.0.1 - # name: Setup PNPM & Install dependencies 👨🏻‍💻 - # with: - # version: 8.7.4 - # run_install: | - # - recursive: true - # args: [--frozen-lockfile] - - # - name: Build library - # run: pnpm lerna:build - - # - name: Cypress run - # uses: cypress-io/github-action@v5 - # with: - # install: false - # record: true - # start: pnpm demo:http-server - # wait-on: 'http://127.0.0.1:8080/lighthouse-viewer/' - # command: pnpm cypress:run - # env: - # # pass the Dashboard record key as an environment variable - # CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - # # pass GitHub token to allow accurately detecting a build vs a re-run build - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - release_canary: - name: Build & Canary Release - runs-on: ubuntu-latest - # needs: run_cypress - needs: install_dependencies - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - CI: 'true' - steps: - - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - - - name: Build library - run: pnpm lerna:build - - - name: Configure CI Git User - run: | - git config --global user.name 'Danilo Velasquez' - git config --global user.email 'danilo.velasquez@gmail.com' - git remote set-url origin https://$GITHUB_TOKEN@github.com/dvelasquez/lighthouse-viewer - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: NPM Auth - run: | - yarn logout - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> .npmrc 2> /dev/null - pnpm whoami - pnpm config set access public - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Version - run: pnpm run lerna:release - - - name: Publish package - run: pnpm run lerna:deploy:ci:canary - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2919203f..b127e741 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,88 +6,24 @@ on: - main jobs: - install_dependencies: - name: Install dependencies & lint - runs-on: ubuntu-latest + setup: + uses: ./.github/workflows/setup.yml + lint: + name: Lint + needs: setup + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - - name: Lint run: pnpm lint - run_cypress: + e2e: name: E2E tests + needs: setup runs-on: ubuntu-latest - needs: install_dependencies - steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - - name: Build library run: pnpm lerna:build @@ -100,49 +36,15 @@ jobs: wait-on: 'http://127.0.0.1:8080/lighthouse-viewer/' command: pnpm cypress:run env: - # pass the Dashboard record key as an environment variable CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} release: name: Build & Release + needs: [e2e] runs-on: ubuntu-latest - needs: run_cypress steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install - run: pnpm install --frozen-lockfile - name: Build library run: pnpm lerna:build @@ -172,3 +74,9 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + update-lockfile: + needs: release + uses: ./.github/workflows/update-lockfile.yml + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 00000000..f5476f69 --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,52 @@ +name: Reusable Setup + +on: + workflow_call: + inputs: + node-version: + required: false + type: string + default: '22.12.0' + pnpm-version: + required: false + type: string + default: '9.15.1' + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - uses: pnpm/action-setup@v4 + name: Setup PNPM + with: + version: ${{ inputs.pnpm-version }} + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Cache node_modules & Turborepo 📦 + uses: actions/cache@v4 + with: + path: | + ${{ steps.pnpm-cache.outputs.STORE_PATH }} + /home/runner/.cache/Cypress + .turbo + **/.turbo + key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} + ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} + + - name: Install Dependencies + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index b512ef21..4a65314e 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -1,49 +1,26 @@ name: Update lockfile on: - push: - branches: - - main - - build/ci + workflow_call: + secrets: + GITHUB_TOKEN: + required: true jobs: + setup: + uses: ./.github/workflows/setup.yml + with: + node-version: '22.12.0' + pnpm-version: '9.15.1' + check_lockfile: name: Check lockfile status + needs: setup runs-on: ubuntu-latest - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} steps: - uses: actions/checkout@v4 - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.12.0 - - - uses: pnpm/action-setup@v4 - name: Setup PNPM & Install dependencies 👨🏻‍💻 - with: - version: 9.15.1 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - name: Install + - name: Install without frozen lockfile run: pnpm install --no-frozen-lockfile - name: Configure CI Git User @@ -55,14 +32,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check for uncommitted changes - id: check-changes - uses: mskri/check-uncommitted-changes-action@v1.0.1 - - name: Update lockfile - if: steps.check-changes.outputs.outcome == failure() run: | if [[ -n "$(git status --porcelain pnpm-lock.yaml)" ]]; then + echo "Lockfile is outdated, updating..." git add pnpm-lock.yaml git commit -m "chore: update lockfile [skip ci]" git push diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6ce5961..3cce3f1f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,7 +90,7 @@ importers: specifier: 5.0.1 version: 5.0.1(@babel/plugin-syntax-flow@7.18.6(@babel/core@7.21.0))(@babel/plugin-transform-react-jsx@7.21.0(@babel/core@7.21.0))(@types/babel__core@7.20.5)(eslint@8.57.1)(react@18.2.0)(type-fest@4.30.2)(typescript@5.7.2)(vue-template-compiler@2.7.16) react2-lighthouse-viewer: - specifier: workspace:0.2.5 + specifier: workspace:0.2.6 version: link:../../packages/react2-lighthouse-viewer web-vitals: specifier: 2.1.4 @@ -136,7 +136,7 @@ importers: specifier: 18.3.1 version: 18.3.1(react@18.3.1) react2-lighthouse-viewer: - specifier: workspace:0.2.5 + specifier: workspace:0.2.6 version: link:../../packages/react2-lighthouse-viewer typescript: specifier: 5.7.2 @@ -164,7 +164,7 @@ importers: specifier: 4.3.4 version: 4.3.4(vite@6.0.5(@types/node@22.10.2)(jiti@1.21.7)(terser@5.37.0)(yaml@2.6.1)) lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../lighthouse-viewer react: specifier: 18.3.1 @@ -182,7 +182,7 @@ importers: specifier: 5.0.4 version: 5.0.4 lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../lighthouse-viewer svelte: specifier: 5.15.0 @@ -200,7 +200,7 @@ importers: specifier: 2.3.3 version: 2.3.3(vite@6.0.5(@types/node@22.10.2)(jiti@1.21.7)(terser@5.37.0)(yaml@2.6.1))(vue@2.7.16) lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../lighthouse-viewer vue: specifier: 2.7.16 @@ -218,7 +218,7 @@ importers: specifier: 0.7.0 version: 0.7.0(typescript@5.7.2)(vue@3.5.13(typescript@5.7.2)) lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../lighthouse-viewer typescript: specifier: 5.7.2 @@ -239,10 +239,10 @@ importers: specifier: 8.0.0 version: 8.0.0 react2-lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../../packages/react2-lighthouse-viewer svelte-lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../../packages/svelte-lighthouse-viewer typescript: specifier: 5.7.2 @@ -251,10 +251,10 @@ importers: specifier: 5.4.11 version: 5.4.11(@types/node@22.10.2)(terser@5.37.0) vue-lighthouse-viewer: - specifier: workspace:^0.2.5 + specifier: workspace:^0.2.6 version: link:../../packages/vue-lighthouse-viewer vue3-lighthouse-viewer: - specifier: workspace:^0.1.5 + specifier: workspace:^0.1.7 version: link:../../packages/vue3-lighthouse-viewer packages: From da2d1fa86a76507deae875e216d56e302f2629e2 Mon Sep 17 00:00:00 2001 From: Danilo Velasquez Date: Mon, 23 Dec 2024 09:06:08 +0100 Subject: [PATCH 2/2] refactor: changed workflow to composite action --- .github/actions/setup/action.yml | 47 ++++++++++++++++++++++++ .github/workflows/pr.yml | 20 ++++++----- .github/workflows/publish-demo.yml | 11 +++--- .github/workflows/release.yml | 24 +++++++++---- .github/workflows/setup.yml | 52 --------------------------- .github/workflows/update-lockfile.yml | 7 ---- 6 files changed, 82 insertions(+), 79 deletions(-) create mode 100644 .github/actions/setup/action.yml delete mode 100644 .github/workflows/setup.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..16f2b078 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,47 @@ +name: Reusable Setup +description: "Setup the environment for the project" +inputs: + node-version: + required: false + default: '22.12.0' + description: "The version of Node.js to use" + pnpm-version: + required: false + default: '9.15.1' + description: "The version of PNPM to use" +runs: + using: composite + steps: + - name: Use Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - uses: pnpm/action-setup@v4 + name: Setup PNPM + with: + version: ${{ inputs.pnpm-version }} + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Cache node_modules & Turborepo 📦 + uses: actions/cache@v4 + with: + path: | + ${{ steps.pnpm-cache.outputs.STORE_PATH }} + /home/runner/.cache/Cypress + .turbo + key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} + ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} + ${{ runner.os }}-node- + + - name: Install Dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b6b2be91..c8a60cb4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,27 +8,31 @@ on: branches: [main] jobs: - setup: - uses: ./.github/workflows/setup.yml - - lint: - name: Lint - needs: setup + lint_build: + name: Lint & Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Lint run: pnpm lint e2e: name: E2E tests - needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Build library run: pnpm lerna:build - - name: Cypress run uses: cypress-io/github-action@v5 with: diff --git a/.github/workflows/publish-demo.yml b/.github/workflows/publish-demo.yml index 471ac1e6..8bfda066 100644 --- a/.github/workflows/publish-demo.yml +++ b/.github/workflows/publish-demo.yml @@ -7,23 +7,24 @@ on: - fix/pnpm-github-actions jobs: - setup: - uses: ./.github/workflows/setup.yml - release: name: Update demo pages - needs: setup runs-on: ubuntu-latest env: CI: 'true' steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Build libraries run: pnpm lerna:build - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.6.9 + uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages # The branch the action should deploy to. folder: web/lighthouse-viewer/dist/lighthouse-viewer # The folder the action should deploy. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b127e741..8c83fd7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,24 +6,29 @@ on: - main jobs: - setup: - uses: ./.github/workflows/setup.yml - - lint: - name: Lint - needs: setup + lint_build: + name: Lint & Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Lint run: pnpm lint e2e: name: E2E tests - needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Build library run: pnpm lerna:build @@ -45,6 +50,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 22.12.0 + pnpm-version: 9.15.1 - name: Build library run: pnpm lerna:build diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml deleted file mode 100644 index f5476f69..00000000 --- a/.github/workflows/setup.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Reusable Setup - -on: - workflow_call: - inputs: - node-version: - required: false - type: string - default: '22.12.0' - pnpm-version: - required: false - type: string - default: '9.15.1' - -jobs: - setup: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js ${{ inputs.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - - uses: pnpm/action-setup@v4 - name: Setup PNPM - with: - version: ${{ inputs.pnpm-version }} - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Cache node_modules & Turborepo 📦 - uses: actions/cache@v4 - with: - path: | - ${{ steps.pnpm-cache.outputs.STORE_PATH }} - /home/runner/.cache/Cypress - .turbo - **/.turbo - key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/package.json') }} - ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} - - - name: Install Dependencies - run: pnpm install --frozen-lockfile diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index 4a65314e..1c0c4201 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -7,15 +7,8 @@ on: required: true jobs: - setup: - uses: ./.github/workflows/setup.yml - with: - node-version: '22.12.0' - pnpm-version: '9.15.1' - check_lockfile: name: Check lockfile status - needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4