Created
November 17, 2022 04:42
-
-
Save productdevbook/299a7e71766ac6091496370601a73501 to your computer and use it in GitHub Desktop.
pnpm with cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
install: | |
name: Install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2.2.4 | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache pnpm | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm-store | |
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }} | |
restore-keys: pnpm- | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
id: cache-node-modules | |
with: | |
path: | | |
node_modules | |
docs/node_modules | |
examples/**/node_modules | |
packages/**/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Install Dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: pnpm i | |
- name: Link Dependencies | |
if: steps.cache-node-modules.outputs.cache-hit == 'true' | |
run: pnpm dev | |
lint: | |
name: Lint | |
needs: install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2.2.4 | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
docs/node_modules | |
examples/**/node_modules | |
packages/**/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Lint code | |
run: pnpm lint | |
- name: Check types | |
run: pnpm typecheck | |
build: | |
name: Build | |
needs: lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2.2.4 | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
docs/node_modules | |
examples/**/node_modules | |
packages/**/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Build | |
run: pnpm build | |
test: | |
name: Test | |
needs: lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# TODO: Switch back to Node 16 once Vitest is patched | |
# https://github.com/vitest-dev/vitest/issues/1191 | |
node-version: [18] | |
pnpm-version: [7] | |
react-version: [17, 18] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2.2.4 | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
docs/node_modules | |
examples/**/node_modules | |
packages/**/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Install rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
profile: minimal | |
override: true | |
- name: Install Anvil | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
# TODO: Cache Anvil RPC calls between runs to speed up tests | |
- name: Launch Anvil | |
run: anvil --fork-url $ANVIL_FORK_URL --fork-block-number $ANVIL_BLOCK_NUMBER & | |
env: | |
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }} | |
ANVIL_BLOCK_NUMBER: 15578840 | |
- name: Test React 18 | |
if: matrix.react-version == 18 | |
run: pnpm test:coverage | |
env: | |
REACT_VERSION: ${{ matrix.react-version }} | |
- name: Test types | |
if: matrix.react-version == 18 | |
run: pnpm test:typecheck | |
env: | |
REACT_VERSION: ${{ matrix.react-version }} | |
- name: Test React 17 | |
if: matrix.react-version == 17 | |
run: | | |
cd packages/react | |
pnpm add -D react@17.0.2 react-dom@17.0.2 | |
cd ../.. | |
pnpm test:run react | |
env: | |
REACT_VERSION: ${{ matrix.react-version }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment