Skip to content

Commit

Permalink
[ci] Update github actions for formatting and unit tests
Browse files Browse the repository at this point in the history
Splits Unit tests from E2E tests, formatting, linting, and build
to ensure consistency across pull requests.
  • Loading branch information
gregnazario committed Oct 10, 2023
1 parent 0f401fd commit 1a86540
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/actions/run-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Run optimized SDK build"
description: |
Run build for Browser, Node, and Types
runs:
using: composite
steps:
# Install node and pnpm.
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8.9.0

# Run package install and build
- run: pnpm install --frozen-lockfile && pnpm build
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/run-fmt/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Verify SDK formatting"
description: |
Run prettier on the codebase to ensure consistency
runs:
using: composite
steps:
# Install node and pnpm.
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8.9.0

# Verify that the format is correct
- run: pnpm install --frozen-lockfile && pnpm _fmt --check
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/run-lint/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Lint SDK Code"
description: |
Run eslint on the codebase to ensure consistency
runs:
using: composite
steps:
# Install node and pnpm.
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8.9.0

# Run eslint
- run: pnpm install --frozen-lockfile && pnpm lint
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/run-unit-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "SDK Unit Tests"
description: |
Run the SDK unit tests locally
runs:
using: composite
steps:
# Install node and pnpm.
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8.9.0

# Run unit tests
- run: pnpm install --frozen-lockfile && pnpm unit-test
shell: bash
19 changes: 19 additions & 0 deletions .github/workflows/run-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
env:
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

name: "Run SDK optimized build"
on:
pull_request:
types: [labeled, opened, synchronize, reopened, auto_merge_enabled]
push:
branches:
- main

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GIT_SHA }}
- uses: ./.github/actions/run-build
19 changes: 19 additions & 0 deletions .github/workflows/run-fmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
env:
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

name: "Run SDK code format check"
on:
pull_request:
types: [labeled, opened, synchronize, reopened, auto_merge_enabled]
push:
branches:
- main

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GIT_SHA }}
- uses: ./.github/actions/run-fmt
19 changes: 19 additions & 0 deletions .github/workflows/run-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
env:
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

name: "Run SDK code linting"
on:
pull_request:
types: [labeled, opened, synchronize, reopened, auto_merge_enabled]
push:
branches:
- main

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GIT_SHA }}
- uses: ./.github/actions/run-lint
19 changes: 19 additions & 0 deletions .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
env:
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

name: "Run SDK unit tests"
on:
pull_request:
types: [labeled, opened, synchronize, reopened, auto_merge_enabled]
push:
branches:
- main

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GIT_SHA }}
- uses: ./.github/actions/run-unit-tests
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"fmt": "pnpm _fmt --write",
"lint": "eslint \"**/*.ts\"",
"test": "pnpm jest",
"unit-test": "pnpm jest tests/unit",
"e2e-test": "pnpm jest tests/e2e",
"indexer-codegen": "graphql-codegen --config ./src/types/codegen.yaml"
},
"dependencies": {
Expand Down

0 comments on commit 1a86540

Please sign in to comment.