Skip to content

Commit

Permalink
Add github actions to build and run tests on pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuripetusko committed Jan 17, 2024
1 parent 1acdb51 commit fe26544
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build and test
on:
workflow_call:
workflow_dispatch:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true

- name: Lint code
run: pnpm format && bun lint:fix

- uses: stefanzweifel/git-auto-commit-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: 'chore: format'
commit_user_name: 'github-actions[bot]'
commit_user_email: 'github-actions[bot]@users.noreply.github.com'

build:
name: Build
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true

- name: Build
run: pnpm run build

test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: true

- name: Build
run: pnpm run build

- name: Run tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: pnpm run test:ci
16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pull request
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches:
- '!rc'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
verify:
name: Build and test
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint": "biome check .",
"lint:fix": "pnpm lint --apply",
"test": "vitest",
"test:ci": "CI=true vitest --coverage --retry=3 --bail=1 --pool=forks",
"test:watch": "pnpm run test --watch",
"test:build": "pnpm run --r --parallel test:build",
"test:cov": "vitest run --coverage",
Expand Down

0 comments on commit fe26544

Please sign in to comment.