diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..3008dbaaf --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + branches: + - "master" + pull_request: + branches: + - "*" + +jobs: + test: + name: nodejs v${{ matrix.node_version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + node_version: [10.x, 12.x] + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - name: set git config + run: | + git config --global core.eol lf + git config --global core.autocrlf false + + - uses: actions/checkout@v1 + + - name: setup nodejs + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node_version }} + + - name: install yarn + run: npm install -g yarn + + - name: get yarn cache dir + id: yarn-cache-dir + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir.outputs.dir }} + key: ${{ runner.os }}-${{ runner.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.node_version }}-yarn- + + - name: install dependencies + working-directory: ./app + run: yarn + + - name: lint code + working-directory: ./app + run: yarn lint + + - name: typescript compile + working-directory: ./app + run: yarn tsc + + - name: unit tests + working-directory: ./app + run: yarn test:ci + + - name: build app + working-directory: ./app + run: yarn build diff --git a/.vscode/settings.json b/.vscode/settings.json index 60aadc127..022394a41 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -62,5 +62,6 @@ ], "editor.codeActionsOnSave": { "source.fixAll.eslint": true - } + }, + "eslint.workingDirectories": ["./app"] } diff --git a/README.md b/README.md index b8c93eb7a..cd0632b2b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ > This document is currently a scratchpad for developer setup and temporary hacks to run the project. It will be made more user-friendly in the future +![CI](https://github.com/lightninglabs/shushtar/workflows/CI/badge.svg) + Requirements: [Go](https://golang.org/doc/install), [protoc](https://github.com/protocolbuffers/protobuf/releases), [nodejs](https://nodejs.org/en/download/) ## One-time Setup diff --git a/app/.eslintignore b/app/.eslintignore new file mode 100644 index 000000000..07aaf6323 --- /dev/null +++ b/app/.eslintignore @@ -0,0 +1,11 @@ +# testing +/coverage + +# production +/build + +# generated from GRPC proto compiler +/src/types/generated/ + +# mocks for dependencies +/src/__mocks__ \ No newline at end of file diff --git a/app/package.json b/app/package.json index d19cd430b..ca2b1864c 100644 --- a/app/package.json +++ b/app/package.json @@ -8,8 +8,10 @@ "start": "BROWSER=none react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "test:ci": "CI=true yarn test --coverage", + "test:ci": "cross-env CI=true yarn test --coverage", "eject": "react-scripts eject", + "lint": "eslint --ext .ts,.tsx --ignore-path .eslintignore .", + "tsc": "tsc --noEmit", "protos": "./scripts/build-protos.sh" }, "proxy": "https://localhost:8443", @@ -37,6 +39,10 @@ "@types/react-dom": "^16.9.0", "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", + "cross-env": "7.0.2", + "eslint-config-prettier": "6.10.1", + "eslint-plugin-prettier": "3.1.3", + "eslint-plugin-react": "7.19.0", "google-protobuf": "3.11.4", "prettier": "2.0.4", "ts-protoc-gen": "0.12.0", diff --git a/app/yarn.lock b/app/yarn.lock index 46082513a..aca691299 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -3164,6 +3164,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-env@7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9" + integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw== + dependencies: + cross-spawn "^7.0.1" + cross-spawn@7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.1.tgz#0ab56286e0f7c24e153d04cc2aa027e43a9a5d14" @@ -3184,6 +3191,15 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" +cross-spawn@^7.0.1: + version "7.0.2" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6" + integrity sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -3944,6 +3960,13 @@ escodegen@^1.11.0, escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@6.10.1: + version "6.10.1" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.10.1.tgz#129ef9ec575d5ddc0e269667bf09defcd898642a" + integrity sha512-svTy6zh1ecQojvpbJSgH3aei/Rt7C6i090l5f2WQ4aB05lYHeZIR1qL4wZyyILTbtmnbHP5Yn8MrsOJMGa8RkQ== + dependencies: + get-stdin "^6.0.0" + eslint-config-react-app@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.2.1.tgz#698bf7aeee27f0cea0139eaef261c7bf7dd623df" @@ -4018,6 +4041,13 @@ eslint-plugin-jsx-a11y@6.2.3: has "^1.0.3" jsx-ast-utils "^2.2.1" +eslint-plugin-prettier@3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz#ae116a0fc0e598fdae48743a4430903de5b4e6ca" + integrity sha512-+HG5jmu/dN3ZV3T6eCD7a4BlAySdN7mLIbJYo0z1cFQuI+r2DiTJEFeF68ots93PsnrMxbzIZ2S/ieX+mkrBeQ== + dependencies: + prettier-linter-helpers "^1.0.0" + eslint-plugin-react-hooks@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04" @@ -4341,6 +4371,11 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^2.0.2: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -4704,6 +4739,11 @@ get-own-enumerable-property-symbols@^3.0.0: resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664" integrity sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g== +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stream@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" @@ -8309,6 +8349,13 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + prettier@2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.4.tgz#2d1bae173e355996ee355ec9830a7a1ee05457ef"