Skip to content

Commit

Permalink
ci: adds linting and formatting jobs to on pull request workflow (#168)
Browse files Browse the repository at this point in the history
* ci: adds formatting and pr title linting to pull request CI

also removes beachball check and build steps

* chore: removes pretty-quick and husky since their uses is no longer required

* ci: fixes issue where failing the format job didnt result in a job failure

* chore: removes unused codeowners file

* ci: fixes issue where pr title check didnt run if PR was never edited

* ci: run title check on sync as well

* chore: updates lint and format commands to run against tests

* chore: ignore generated code for linting and formatting

* chore: fixes eslint config file to follow v8.x structure

* ci: fixes bug where formatting was not returning the correct error code
  • Loading branch information
ctran88 authored Oct 30, 2024
1 parent b4b15c1 commit 31ee1e7
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 266 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"indent": ["error", 4],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-function-return-type": "error"
}
},
"ignorePatterns": ["src/generated"]
}
1 change: 0 additions & 1 deletion .github/workflows/CODEOWNERS

This file was deleted.

66 changes: 35 additions & 31 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
name: Run Tests on PR
name: Lint, Format, and Test

on:
pull_request:
workflow_dispatch:
workflow_call:
workflow_dispatch:
pull_request:

env:
API_KEY: ${{ secrets.API_KEY }}
APP_ID: ${{ secrets.APP_ID }}
APP_TOKEN: ${{ secrets.APP_TOKEN }}
EXAMPLE_USER_ID: ${{ secrets.EXAMPLE_USER_ID }}
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}
API_KEY: ${{ secrets.API_KEY }}
APP_ID: ${{ secrets.APP_ID }}
APP_TOKEN: ${{ secrets.APP_TOKEN }}
EXAMPLE_USER_ID: ${{ secrets.EXAMPLE_USER_ID }}

jobs:
publish:
name: Run Tests on PR
runs-on: ubuntu-latest

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

- name: Install Dependencies
run: npm i

- name: ESLint Check
run: npm run lint:ci

- name: Beachball Check
run: |
npm run beachball-check
- name: Build
run: npm run set-version && npm run build

- name: Unit Test
run: npm run test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm i
- name: Lint
run: npm run lint:ci
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm i
- name: Format
run: npm run format:ci
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm i
- name: Test
run: npm run test
37 changes: 37 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR Title Check

on:
pull_request:
types:
- opened
- reopened
- synchronize
- edited

jobs:
lint-pr-title:
name: Lint PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Please update the pull request title to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules/
coverage/
.DS_STORE
lib/
generated/
src/generated/
Loading

0 comments on commit 31ee1e7

Please sign in to comment.