Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: refactored actions to be more reusable #1602

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading