Skip to content

Commit

Permalink
ci: reusable setup + read node version from nvmrc
Browse files Browse the repository at this point in the history
Closes #145

Addresses the following discussions:
 - #148 (comment)
 - #148 (comment)

Signed-off-by: Lukas Mertens <[email protected]>

commit-id:9b48f5ae
  • Loading branch information
lukas-mertens committed Apr 23, 2024
1 parent f05e98d commit a596803
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 76 deletions.
39 changes: 39 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest

name: Setup Node and pnpm
description: "Setups node + pnpm"

inputs:
pnpm-version:
description: "pnpm version to install"
default: "8"

outputs:
pnpm-version:
description: "The pnpm version that was installed"
value: ${{ inputs.pnpm-version }}

runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v2
with:
version: ${{ inputs.pnpm-version }}

- name: Read .nvmrc
id: nvmrc
shell: bash
run: echo version=$(cat .nvmrc) >> "$GITHUB_OUTPUT"

- name: Setup Node.js ${{ steps.nvmrc.outputs.version }}
uses: actions/setup-node@v4
with:
node-version: ${{ steps.nvmrc.outputs.version }}
cache: 'pnpm'
cache-dependency-path: |
pnpm-lock.yaml
- name: install dependencies
shell: bash
run: pnpm install
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
check_license_headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check License Header
uses: apache/skywalking-eyes/header@main

26 changes: 4 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,11 @@ jobs:
env:
SUBDIR: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'main' }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup node + pnpm install
uses: ./.github/actions/setup-node
with:
node-version: '18.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
pnpm-version: 9
- name: Build
run: pnpm build:pages
- uses: ahmadnassri/action-workflow-queue@v1 # we have to ensure that no other deployment is running
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ jobs:
browser: ['electron', 'firefox']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
name: Install pnpm
- name: Setup node + pnpm install
uses: ./.github/actions/setup-node
with:
version: 8
run_install: false
pnpm-version: 9
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
with:
Expand Down
26 changes: 4 additions & 22 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,11 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup node + pnpm install
uses: ./.github/actions/setup-node
with:
node-version: '18.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
pnpm-version: 9
- name: Build
run: pnpm build
- name: Tar
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/shrinkwrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ jobs:
create-shrinkwrap:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Read .nvmrc
id: nvmrc
shell: bash
run: echo version=$(cat .nvmrc) >> "$GITHUB_OUTPUT"

- name: Setup Node.js ${{ steps.nvmrc.outputs.version }}
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: ${{ steps.nvmrc.outputs.version }}

- name: Generate npm-shrinkwrap.json
run: |
Expand Down
26 changes: 4 additions & 22 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,11 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup node + pnpm install
uses: ./.github/actions/setup-node
with:
node-version: '18.x'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
pnpm-version: 9
- name: Run Vitest
run: pnpm test:coverage
- name: 'Report Coverage'
Expand Down

0 comments on commit a596803

Please sign in to comment.