Add Monkey CI (#3799)

* Split PR checks

* Split Jobs

* Test

* Fix path check

* Use checkout

* Undo

* oh boy

* .

* .

* .

* .

* test

* .

* .

* .

* .

* .

* .

* .

* yay

* Remove jsonschema from global dep

* monkey ci

* .

* oops

* test

* .

* .

* .

* .

* .

* .

* .

* ayy

* add permissions
This commit is contained in:
Bruce Berrios 2022-12-05 12:52:15 -05:00 committed by GitHub
parent abe61873a4
commit 46d7a78ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 172 additions and 143 deletions

147
.github/workflows/monkey-ci.yml vendored Normal file
View file

@ -0,0 +1,147 @@
name: Monkey CI
env:
NODE_VERSION: "16.13.2"
on:
pull_request:
branches: [master]
push:
branches: [master]
concurrency:
group: group-${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
pre-ci:
name: pre-ci
runs-on: ubuntu-latest
outputs:
should-build-be: ${{ steps.export-changes.outputs.should-build-be }}
should-build-fe: ${{ steps.export-changes.outputs.should-build-fe }}
assets-json: ${{ steps.export-changes.outputs.assets-json }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
json:
- 'frontend/**/*.json'
be-src:
- 'backend/**/*.{ts,js,json,lua,css,html}'
fe-src:
- 'frontend/**/*.{ts,scss}'
anti-cheat:
- 'backend/**/anticheat/**'
- name: Check Anti-cheat
if: steps.filter.outputs.anti-cheat == 'true'
run: exit 1
- name: Export changes
id: export-changes
run: |
echo "should-build-be=${{ steps.filter.outputs.be-src }}" >> $GITHUB_OUTPUT
echo "should-build-fe=${{ steps.filter.outputs.fe-src }}" >> $GITHUB_OUTPUT
echo "assets-json=${{ steps.filter.outputs.json }}" >> $GITHUB_OUTPUT
ci-be:
name: ci-be
needs: [pre-ci]
runs-on: ubuntu-latest
if: needs.pre-ci.outputs.should-build-be == 'true'
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci & cd backend && npm ci
- name: Check pretty
run: npm run pretty-code-be
- name: Check lint
run: npm run lint-be
- name: Build
run: npm run pr-check-build-be
- name: Test
run: npm run test-be
ci-fe:
name: ci-fe
needs: [pre-ci]
runs-on: ubuntu-latest
if: needs.pre-ci.outputs.should-build-fe == 'true'
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Create stub firebase config
working-directory: ./frontend/src/ts/constants
run: mv ./firebase-config-example.ts ./firebase-config-live.ts
- name: Install dependencies
run: npm ci & cd frontend && npm ci
- name: Check pretty
run: npm run pretty-code-fe
- name: Check lint
run: npm run lint-fe
- name: Build
run: npm run pr-check-ts
ci-assets:
name: ci-assets
needs: [pre-ci]
runs-on: ubuntu-latest
if: needs.pre-ci.outputs.assets-json == 'true'
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
language-json:
- 'frontend/static/languages/*.json'
quotes-json:
- 'frontend/static/quotes/*.json'
other-json:
- 'frontend/static/funbox/*.json'
- 'frontend/static/fonts/*.json'
- 'frontend/static/themes/*.json'
- 'frontend/static/challenges/*.json'
- 'frontend/static/layouts/*.json'
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci & cd frontend && npm ci
- name: Lint JSON
run: npm run pr-check-lint-json
- name: Validate languages JSON
if: steps.filter.outputs.language-json == 'true'
run: npm run pr-check-language-json
- name: Validate quotes JSON
if: steps.filter.outputs.quotes-json == 'true'
run: npm run pr-check-quote-json
- name: Validate other JSON
if: steps.filter.outputs.other-json == 'true'
run: npm run pr-check-other-json

View file

@ -1,124 +0,0 @@
name: PR Check
on:
pull_request:
branches: [master, dev]
jobs:
build:
permissions:
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
any-json:
- 'frontend/**/*.json'
language-json:
- 'frontend/static/languages/*.json'
quotes-json:
- 'frontend/static/quotes/*.json'
other-json:
- 'frontend/static/funbox/*.json'
- 'frontend/static/fonts/*.json'
- 'frontend/static/themes/*.json'
- 'frontend/static/challenges/*.json'
- 'frontend/static/layouts/*.json'
any-tsscss:
- 'frontend/**/*.scss'
- 'frontend/**/*.ts'
- 'backend/**/*.ts'
ts-scss-fe:
- 'frontend/**/*.ts'
- 'frontend/**/*.scss'
ts-be:
- 'backend/**/*.ts'
anti-cheat:
- 'backend/**/anticheat/**'
any-src:
- 'backend/**/*.{ts,js,json}'
- 'frontend/**/*.{ts,js}'
- 'frontend/src/**/*.scss'
- name: Create stub firebase config
working-directory: ./frontend/src/ts/constants
run: mv ./firebase-config-example.ts ./firebase-config-live.ts
- name: Check Anti-cheat
if: steps.filter.outputs.anti-cheat == 'true'
run: exit 1
- name: Save the PR number in an artifact
shell: bash
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- name: Upload the PR number
uses: actions/upload-artifact@v2
with:
name: pr_num
path: ./pr_num.txt
- name: Cache node modules
if: steps.filter.outputs.changes != '[]'
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set up Node.js
if: steps.filter.outputs.changes != '[]'
uses: actions/setup-node@v1
with:
node-version: "16.13.2"
- name: Install dependencies
if: steps.filter.outputs.changes != '[]'
run: npm run install-all
- name: Pretty Check
if: steps.filter.outputs.any-src == 'true'
run: npm run pretty-code
- name: Lint JSON
if: steps.filter.outputs.any-json == 'true'
run: npm run pr-check-lint-json
- name: Validate languages JSON
if: steps.filter.outputs.language-json == 'true'
run: npm run pr-check-language-json
- name: Validate quotes JSON
if: steps.filter.outputs.quotes-json == 'true'
run: npm run pr-check-quote-json
- name: Validate other JSON
if: steps.filter.outputs.other-json == 'true'
run: npm run pr-check-other-json
- name: Lint
if: steps.filter.outputs.any-tsscss == 'true'
run: npm run lint
- name: Build backend
if: steps.filter.outputs.ts-be == 'true'
run: npm run pr-check-build-be
- name: Test backend
if: steps.filter.outputs.ts-be == 'true'
run: npm run test-backend
- name: Run webpack
if: steps.filter.outputs.ts-scss-fe == 'true'
run: npm run pr-check-ts

View file

@ -11,6 +11,7 @@ on:
jobs:
prettier-fix:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View file

@ -55,6 +55,7 @@
"html-minimizer-webpack-plugin": "3.5.0",
"html-webpack-plugin": "5.5.0",
"json-minimizer-webpack-plugin": "3.3.0",
"jsonschema": "1.4.0",
"madge": "5.0.1",
"mini-css-extract-plugin": "2.6.0",
"sass": "1.49.9",
@ -10552,6 +10553,16 @@
"node": ">=0.10.0"
}
},
"node_modules/jsonschema": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz",
"integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==",
"dev": true,
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/jszip": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
@ -25999,6 +26010,12 @@
"integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==",
"dev": true
},
"jsonschema": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz",
"integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==",
"dev": true
},
"jszip": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",

View file

@ -41,6 +41,7 @@
"html-minimizer-webpack-plugin": "3.5.0",
"html-webpack-plugin": "5.5.0",
"json-minimizer-webpack-plugin": "3.3.0",
"jsonschema": "1.4.0",
"madge": "5.0.1",
"mini-css-extract-plugin": "2.6.0",
"sass": "1.49.9",

16
package-lock.json generated
View file

@ -16,7 +16,6 @@
"eslint-plugin-json": "2.1.2",
"eslint-plugin-require-path-exists": "1.1.9",
"husky": "8.0.1",
"jsonschema": "1.4.0",
"prettier": "2.5.1",
"pretty-quick": "3.1.0",
"typescript": "4.5.5"
@ -1314,15 +1313,6 @@
"integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==",
"dev": true
},
"node_modules/jsonschema": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz",
"integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
@ -3152,12 +3142,6 @@
"integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==",
"dev": true
},
"jsonschema": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz",
"integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==",
"dev": true
},
"levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",

View file

@ -6,11 +6,13 @@
"scripts": {
"prepare": "husky install",
"pre-commit": "pretty-quick --staged",
"lint": "cd backend && eslint \"**/*.ts\" && cd ../frontend && eslint \"**/*.ts\"",
"lint": "npm run lint-be && npm run lint-fe",
"lint-be": "cd backend && eslint \"**/*.ts\"",
"lint-fe": "cd frontend && eslint \"**/*.ts\"",
"install-all": "sh ./bin/install.sh",
"install-windows": ".\\bin\\install.cmd",
"docker": "cd backend && docker-compose up",
"test-backend": "cd backend && npm run test",
"test-be": "cd backend && npm run test",
"dev": "concurrently --kill-others \"npm run dev-fe\" \"npm run dev-be\"",
"dev-be": "cd backend && npm run dev",
"dev-fe": "cd frontend && npm run dev",
@ -20,6 +22,8 @@
"build-fe": "cd ./frontend && npm run build-live",
"pretty": "prettier --check \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./frontend/static/**/*.{json,html,css}\"",
"pretty-code": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\" \"./frontend/**/*.{ts,js}\" \"./frontend/src/**/*.scss\"",
"pretty-code-be": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\"",
"pretty-code-fe": "prettier --check \"./frontend/**/*.{ts,js}\" \"./frontend/src/**/*.scss\"",
"pretty-fix": "prettier --write \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./frontend/static/**/*.{json,html,css}\"",
"pr-check-lint-json": "cd frontend && npx gulp pr-check-lint-json",
"pr-check-quote-json": "cd frontend && npx gulp pr-check-quote-json",
@ -39,7 +43,6 @@
"eslint-plugin-json": "2.1.2",
"eslint-plugin-require-path-exists": "1.1.9",
"husky": "8.0.1",
"jsonschema": "1.4.0",
"prettier": "2.5.1",
"pretty-quick": "3.1.0",
"typescript": "4.5.5"