From 532d8c7098327ed6f495a11fca5d4952cf1daca8 Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Sun, 13 Oct 2024 09:22:06 -0400 Subject: [PATCH] Standardize GitHub Actions workflow With most other Dexa projects. --- .github/actions/install-node-pnpm/action.yml | 41 ++++++++++++ .github/workflows/main.yml | 67 +++++++------------- 2 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 .github/actions/install-node-pnpm/action.yml diff --git a/.github/actions/install-node-pnpm/action.yml b/.github/actions/install-node-pnpm/action.yml new file mode 100644 index 0000000..0ac81ae --- /dev/null +++ b/.github/actions/install-node-pnpm/action.yml @@ -0,0 +1,41 @@ +name: 'Install Node and pnpm' +description: 'Install Node and pnpm with caching for fast install' + +inputs: + node-version: + description: 'The version of Node to install' + default: '20' + required: false + +runs: + using: 'composite' + steps: + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Install pnpm + uses: pnpm/action-setup@v4 + id: pnpm-install + with: + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + # Run install with optional filter if present + - name: Install pnpm dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22f7de7..72a1ad1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,51 +1,32 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: - test: - name: Test Node.js ${{ matrix.node-version }} + types: + name: Types runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - node-version: - - 18 - - 20 - - 21 - - 22 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - - name: Install pnpm - uses: pnpm/action-setup@v3 - id: pnpm-install - with: - version: 9.7.0 - 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 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run typecheck - - name: Install dependencies - run: pnpm install --frozen-lockfile + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run lint - - name: Run test - run: pnpm run test + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run format