Change tests

* Try to fix check for generated files to create a comment on a PR.
* Check for generated files does not count as a failure.
* Lint doesn't fail based on stuff in dist. Prettier and lint no longer use the "diff" version.
* Removed some commands that weren't really used (specific version electron packager commands that require you to have already ran npm run electron to generate .package folder)
This commit is contained in:
omuretsu 2023-02-04 07:42:35 -05:00
parent 37f41c89bc
commit 6459b1ab48
5 changed files with 37 additions and 74 deletions

@ -1,26 +1,16 @@
node_modules/
.dist
.tmp
.package
.build
.cypress/
.app
dist/
input/
assets/
doc/
markdown/
dist
input
assets
doc
markdown
electron
tools
src/ThirdParty
test/netscript/
electron/lib
electron/greenworks.js
src/ThirdParty/*
src/JSInterpreter.js
tools/engines-check/
editor.main.js
main.bundle.js
webpack.config.js

@ -35,51 +35,30 @@ jobs:
- name: Warn when bundle files were changed
id: warn-bundles-changed
if: steps.changed-bundle-files.outputs.any_changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "One or more files in the bundle files were changed." >> warnings.txt
echo "Creating label (if it does not exist)"
LABEL="validation: bundle files modified"
gh --repo "${{ github.repository }}" \
label create "$LABEL" --description "Modifications to this pull request are suggested" --color D93F0B || true
- name: Warn when documentation markdown files were changed
id: warn-markdown-changed
if: steps.changed-markdown-doc-files.outputs.any_changed == 'true'
run: |
echo "One or more files in the markdown documentation were changed." >> warnings.txt
- name: Print Warnings
id: get-warnings
run: |
if [ -f warnings.txt ]
then
echo "::set-output name=has_warnings::true"
if [ "${{ steps.changed-bundle-files.outputs.any_changed }}" == "false" ]; then
echo "No forbidden files included, removing warning"
gh --repo "${{ github.repository }}" \
pr edit "${{ github.event.number }}" --remove-label "$LABEL" || true
else
echo "::set-output name=has_warnings::false"
touch warnings.txt
echo "Forbidden files included, generating warning"
touch comment.txt
echo "## Generated build or documentation files were included. PRs should not normally contain any generated files." >> comment.txt
echo "" >> comment.txt
echo "Review the changes and ensure that including built files was necessary." >> comment.txt
echo "Add pr label"
gh --repo "${{ github.repository }}" \
pr edit "${{ github.event.number }}" --add-label "$LABEL"
echo "And comment on the pr"
gh --repo "${{ github.repository }}" \
pr comment "${{ github.event.number }}" --body-file comment.txt
fi
- name: Get Comment Body
id: get-comment-body
if: steps.get-warnings.outputs.has_warnings == 'true'
run: |
cat warnings.txt > comment.txt
echo "" >> comment.txt
echo "Please do not commit files generated by webpack or generated markdown" >> comment.txt
echo "" >> comment.txt
echo "See [CONTRIBUTING.md](https://github.com/bitburner-official/bitburner-src/blob/dev/doc/CONTRIBUTING.md) for details." >> comment.txt
body=$(cat comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Add github comment on problem
if: steps.get-warnings.outputs.has_warnings == 'true'
uses: peter-evans/commit-comment@v1
with:
body: ${{ steps.get-comment-body.outputs.body }}
- name: Flag as error
if: steps.get-warnings.outputs.has_warnings == 'true'
run: |
COMMIT_WARNINGS=$(cat warnings.txt)
echo "::warning:: $COMMIT_WARNINGS"
exit 1

@ -1,7 +1,7 @@
name: CI Pull Request
on:
# Triggers the workflow on pull request events but only for the dev branch, checking only diffs
# Triggers the workflow on pull request events but only for the dev branch
pull_request:
branches: [dev]
@ -38,7 +38,7 @@ jobs:
- name: Install npm dependencies
run: npm ci
- name: Run linter
run: npm run lint:report-diff
run: npm run lint:report
prettier:
name: Prettier
runs-on: ubuntu-latest
@ -54,7 +54,7 @@ jobs:
- name: Install npm dependencies
run: npm ci
- name: Run prettier check
run: npm run format:report-diff
run: npm run format:report
test:
name: Test
runs-on: ubuntu-latest

@ -1,10 +1,11 @@
node_modules
package.json
dist
doc/build/
doc/build
doc/source
.build
.package
.app
editor.main.js
main.bundle.js

@ -102,14 +102,12 @@
"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": "bash -c '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 serve --progress --env devServer --mode development",
"build": "bash ./tools/build.sh production",
"build:dev": "bash ./tools/build.sh development",
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src",
"lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src",
"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",
@ -117,11 +115,6 @@
"watch": "webpack --watch --mode production",
"watch:dev": "webpack --watch --mode development",
"electron": "bash ./tools/package-electron.sh",
"electron:packager": "electron-packager .package bitburner --platform all --arch x64,armv7l,arm64,mips64el --out .build --overwrite --icon .package/icon.png --no-prune",
"electron:packager-all": "electron-packager .package bitburner --platform all --arch x64,armv7l,arm64,mips64el --out .build --overwrite --icon .package/icon.png",
"electron:packager-win": "electron-packager .package bitburner --platform win32 --arch x64 --out .build --overwrite --icon .package/icon.png",
"electron:packager-mac": "electron-packager .package bitburner --platform darwin --arch x64 --out .build --overwrite --icon .package/icon.png",
"electron:packager-linux": "electron-packager .package bitburner --platform linux --arch x64 --out .build --overwrite --icon .package/icon.png",
"allbuild": "npm run build && npm run electron && git add --all && git commit -m \"allbuild commit $(git rev-parse --short HEAD)\" && git push -u origin dev",
"preversion": "npm install && npm run test",
"version": "sh ./tools/build-release.sh && git add --all",