diff --git a/.github/workflows/quality-checks.yml b/.github/workflows/quality-checks.yml new file mode 100644 index 0000000000..fb8e582cfa --- /dev/null +++ b/.github/workflows/quality-checks.yml @@ -0,0 +1,86 @@ +name: Quality checks + +on: + pull_request: + push: + +jobs: + format: + name: Format check + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Setup node + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version-file: '.node-version' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Check formatting + run: npm run fmt:check + + lint: + name: Lint + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Setup node + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version-file: '.node-version' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run ESLint + run: npm run lint + + typecheck: + name: Typecheck + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Setup node + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version-file: '.node-version' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run TypeScript typecheck + run: npm run typecheck -- --pretty false + + knip: + name: Knip + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Setup node + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + node-version-file: '.node-version' + cache: 'npm' + - name: Install dependencies + run: npm ci --ignore-scripts + - name: Run Knip + run: npm run knip diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b981272263..62a4932539 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,6 +37,13 @@ It is not always possible to phrase every change in such a manner, but it is des Also, we use [ESLint](https://eslint.org/) for clean and stylistically consistent code syntax, so make sure your pull request follow it. +**Pull requests are not merged unless all quality checks are passing.** At minimum, `format`, `lint`, `typecheck`, and `knip` must all be green before a pull request can be merged. Run these locally before opening or updating a pull request: + +- `npm run fmt:check` +- `npm run lint` +- `npm run typecheck` +- `npm run knip` + **For any query or design discussion, join our [Matrix room](https://matrix.to/#/#sable:sable.moe).** ## Helpful links