ci check lint only on changed files

This commit is contained in:
Anatoly Kussul 2022-04-13 04:42:44 +03:00
parent c7702d8511
commit 4b5d38c940
3 changed files with 74 additions and 3 deletions

71
.github/workflows/ci-pr.yml vendored Normal file

@ -0,0 +1,71 @@
name: CI Pull Request
on:
# Triggers the workflow on pull request events but only for the dev branch, checking only diffs
pull_request:
branches: [dev]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.13.1
uses: actions/setup-node@v2
with:
node-version: 16.13.1
cache: "npm"
- name: Install npm dependencies
run: npm ci
- name: Build the production app
run: npm run build
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 16.13.1
uses: actions/setup-node@v2
with:
node-version: 16.13.1
cache: "npm"
- name: Install npm dependencies
run: npm ci
- name: Run linter
run: npm run lint:report-diff
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 16.13.1
uses: actions/setup-node@v2
with:
node-version: 16.13.1
cache: "npm"
- name: Install npm dependencies
run: npm ci
- name: Run prettier check
run: npm run format:report-diff
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.13.1
uses: actions/setup-node@v2
with:
node-version: 16.13.1
cache: "npm"
- name: Install npm dependencies
run: npm ci
- name: Run tests
run: npm run test

@ -1,11 +1,9 @@
name: CI name: CI
on: on:
# Triggers the workflow on push or pull request events but only for the dev branch # Triggers the workflow on push events but only for the dev branch
push: push:
branches: [dev] branches: [dev]
pull_request:
branches: [dev]
# Allows you to run this workflow manually from the Actions tab # Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:

@ -109,6 +109,7 @@
"doc": "npx api-extractor run && npx api-documenter markdown && rm input/bitburner.api.json && rm -r input", "doc": "npx api-extractor run && npx api-documenter markdown && rm input/bitburner.api.json && rm -r input",
"format": "prettier --write .", "format": "prettier --write .",
"format:report": "prettier -c .", "format:report": "prettier -c .",
"format:report-diff": "if [[ $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | wc -c) -ne 0 ]]; then prettier -c $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs); fi",
"start": "http-server -p 8000", "start": "http-server -p 8000",
"start:dev": "webpack-dev-server --progress --env.devServer --mode development", "start:dev": "webpack-dev-server --progress --env.devServer --mode development",
"start:dev-fast": "webpack-dev-server --progress --env.devServer --mode development --fast true", "start:dev-fast": "webpack-dev-server --progress --env.devServer --mode development --fast true",
@ -117,6 +118,7 @@
"build:dev": "webpack --mode development", "build:dev": "webpack --mode development",
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 .", "lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 .",
"lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 .", "lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 .",
"lint:report-diff": "eslint --max-warnings 0 $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs)",
"preinstall": "node ./tools/engines-check/engines-check.js", "preinstall": "node ./tools/engines-check/engines-check.js",
"postinstall": "cd electron && npm install", "postinstall": "cd electron && npm install",
"test": "jest", "test": "jest",