Skip to content

Commit

Permalink
ci: refactored actions to be more reusable (#1602)
Browse files Browse the repository at this point in the history
* ci: refactored actions to be more reusable

* refactor: changed workflow to composite action
  • Loading branch information
dvelasquez authored Dec 23, 2024
1 parent 07ebfeb commit 1830dbd
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 415 deletions.
47 changes: 47 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -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
78 changes: 9 additions & 69 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,31 @@ on:
branches: [main]

jobs:
install_dependencies:
name: Install dependencies & lint
lint_build:
name: Lint & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
- name: Setup
uses: ./.github/actions/setup
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

pnpm-version: 9.15.1
- name: Lint
run: pnpm lint

run_cypress:
e2e:
name: E2E tests
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
- name: Setup
uses: ./.github/actions/setup
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

pnpm-version: 9.15.1
- name: Build library
run: pnpm lerna:build

- name: Cypress run
uses: cypress-io/github-action@v5
with:
Expand All @@ -100,7 +42,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 }}
35 changes: 4 additions & 31 deletions .github/workflows/publish-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,17 @@ jobs:
CI: 'true'
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
- name: Setup
uses: ./.github/actions/setup
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
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.
164 changes: 0 additions & 164 deletions .github/workflows/release-canary.yml

This file was deleted.

Loading

0 comments on commit 1830dbd

Please sign in to comment.