diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 000000000..e9a2c3b24 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c714b6b14..5f75d20d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,9 @@ name: CI 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: branches: [dev] - pull_request: - branches: [dev] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/package.json b/package.json index a11d09d81..c34263691 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "doc": "npx api-extractor run && npx api-documenter markdown && rm input/bitburner.api.json && rm -r input", "format": "prettier --write .", "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:dev": "webpack-dev-server --progress --env.devServer --mode development", "start:dev-fast": "webpack-dev-server --progress --env.devServer --mode development --fast true", @@ -117,6 +118,7 @@ "build:dev": "webpack --mode development", "lint": "eslint --fix --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", "postinstall": "cd electron && npm install", "test": "jest",