From 9bb33e723a4585ec7a77cd26ef4b5672473d7ee2 Mon Sep 17 00:00:00 2001 From: Alexander Roidl <34438048+alexanderroidl@users.noreply.github.com> Date: Wed, 23 Jul 2025 08:58:43 +0200 Subject: [PATCH] Workflow to check sourcecode's linting and formatting (#146) * ci: workflow to check sourcecode * fix: make workflow to check source fail for incorrect linting/formatting * ci: change step name for workflow to check sourcecode --- .github/workflows/check_source.yml | 26 ++++++++++++++++++++++++++ .github/workflows/stales.yml | 2 +- .github/workflows/test.yml | 3 +-- package.json | 4 +++- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check_source.yml diff --git a/.github/workflows/check_source.yml b/.github/workflows/check_source.yml new file mode 100644 index 0000000..a3d1b92 --- /dev/null +++ b/.github/workflows/check_source.yml @@ -0,0 +1,26 @@ +name: Check the source code +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + check_source_code: + name: Check the source code + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Check formatting + run: yarn format:check + + - name: Lint + run: yarn lint diff --git a/.github/workflows/stales.yml b/.github/workflows/stales.yml index 0c6a597..bb48b54 100644 --- a/.github/workflows/stales.yml +++ b/.github/workflows/stales.yml @@ -1,4 +1,4 @@ -name: "Close stale issues and PRs" +name: Close stale issues and PRs on: schedule: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8cc9cf4..d5ce6ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: node-version: 20 cache: 'yarn' diff --git a/package.json b/package.json index c8f2b89..4496755 100755 --- a/package.json +++ b/package.json @@ -9,8 +9,10 @@ "ui": "rm -rf ./ui/public/* && vite", "prod": "yarn && vite build --emptyOutDir", "format": "prettier --write lib/**/*.js ui/src/**/*.jsx test/**/*.js *.js", + "format:check": "prettier --check lib/**/*.js ui/src/**/*.jsx test/**/*.js *.js", "test": "mocha --loader=esmock --timeout 3000000 test/**/*.test.js", - "lint": "eslint index.js lib/**/*.js test/**/*.js ui/src/**/*.jsx --fix" + "lint": "eslint index.js lib/**/*.js test/**/*.js ui/src/**/*.jsx", + "lint:fix": "yarn lint --fix" }, "type": "module", "lint-staged": {