Skip to content
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
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ jobs:

- uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c
name: Install pnpm
with:
cache: true

- name: 📦 Install dependencies
run: pnpm install
# pnpm cache skipped deliberately as the project is not actually installed here

- name: 🔠 Lint project
run: pnpm lint
run: node scripts/lint.ts

test:
runs-on: ubuntu-latest
Expand Down
33 changes: 33 additions & 0 deletions scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This script runs oxlint and oxfmt in a CI environment, without the need to install the entire
* project. It reads the required version from pnpm-lock.yaml and executes the linters accordingly.
* It's "stupid by design" so it could work in minimal Node.js environments.
*/

import { spawnSync } from 'node:child_process'

function getDependencyVersion(dependencyName: string): string {
const result = spawnSync('npm', ['pkg', 'get', `devDependencies.${dependencyName}`], {
encoding: 'utf8',
})

if (result.status) {
throw new Error(`Command failed: pnpm info ${dependencyName} version`)
}

return JSON.parse(result.stdout)
}

function runCommand(command: string, args: string[]) {
const result = spawnSync(command, args, { stdio: 'inherit' })

if (result.status) {
throw new Error(`Command failed: ${command} ${args.join(' ')}`)
}
}

const oxlintVersion = getDependencyVersion('oxlint')
const oxfmtVersion = getDependencyVersion('oxfmt')

runCommand('pnpx', [`oxlint@${oxlintVersion}`])
runCommand('pnpx', [`oxfmt@${oxfmtVersion}`, '--check'])
Loading