Skip to content

Commit

Permalink
ci: init automated checks (#16)
Browse files Browse the repository at this point in the history
Resolves #14

Adding automated checks:

For the pull requests:
- Title check: checks that the title it formatted according to the [conventional commits specs](https://www.conventionalcommits.org/en/v1.0.0/). If we would like to ensure that all commit messages are formatted as such, we could configure the repository so that only squash and merge is allowed. In that way, the title from the PR will become the commit message.

For the source code:
- Code formatting: note that this job will be failing in this PR. This is ok, since I'll address this in a separate PR.
- Type checking
- Linter
- Tests
- Build. Not very useful on its own, but the idea is that the output will be tested in another step (#18). This will require a separate PR, which is why tha

@sep2 Once this PR has been merged, I'd like to request a branch protection rule for main that requires both of these checks to pass.



## How to test

Create a new branch based on this one. Make changes, open a stacked PR, and observe the result from the automated checks:

Check that all jobs always run, even if the previous jobs failed. For example, if the code formatter fails, we still want to see if the linter fails.
  • Loading branch information
johannes-lindgren authored Jan 23, 2025
1 parent 8ef2b9a commit f732bc9
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
pull-requests: read

# https://github.com/amannn/action-semantic-pull-request
jobs:
title-check:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Code Integration Checks'
on: ['push']
jobs:
integration-checks:
runs-on: ubuntu-latest
name: Code Integration Checks
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install
run: yarn install --immutable
- name: Check Code Formatting
if: always()
run: yarn check:formatting
- name: Check Types
if: always()
run: yarn check:types
- name: Lint
if: always()
run: yarn lint
- name: Test
if: always()
run: yarn test
- name: Build
if: always()
run: yarn build
# TODO test build output: https://github.com/sep2/immer-yjs/issues/18
# - name: Test Build Output
# if: always()
# run: yarn workspace test-app test
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.pnp.cjs
.pnp.loader.mjs
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"publish": "yarn workspace immer-yjs npm publish",
"release": "yarn workspace immer-yjs release",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --fix packages",
"format": "prettier . --write"
"format": "prettier . --write",
"check:formatting": "prettier . --check",
"check:types": "yarn workspace immer-yjs check:types"
},
"devDependencies": {
"@types/node": "^17.0.21",
Expand Down
3 changes: 2 additions & 1 deletion packages/immer-yjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"build": "tsc && vite build",
"test": "NODE_NO_WARNINGS=1 vitest",
"coverage": "vitest run --coverage",
"release": "standard-version"
"release": "standard-version",
"check:types": "tsc --noEmit"
},
"peerDependencies": {
"immer": "^9.0.12",
Expand Down

0 comments on commit f732bc9

Please sign in to comment.