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] Add auto lint and format checking #6

Merged
merged 2 commits into from
Oct 10, 2023
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
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
Loading