Skip to content

Commit

Permalink
chore(ci): Nx for github validations (#6095)
Browse files Browse the repository at this point in the history
* chore(ci): Nx for github validations

* chore: tune config

* chore: eslint scripts faster and unified settings

* chore: check formatting using nx

* chore: read-only NX token
  • Loading branch information
Nodonisko authored Aug 25, 2022
1 parent a4445e3 commit a446583
Show file tree
Hide file tree
Showing 66 changed files with 602 additions and 122 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: "true"
fetch-depth: 0
- name: Install node and yarn
uses: actions/setup-node@v3
with:
Expand All @@ -18,20 +19,22 @@ jobs:
run: npm install -g yarn
- name: install deps
run: yarn --immutable
- name: check code formatting
run: yarn format:verify
- name: check files for correct formatting
run: yarn nx format:check
- name: verify TS project references
run: yarn verify-project-references
- name: msg-system config validation
run: yarn workspace @trezor/suite-data msg-system-validate-config
- run: git status
- name: build libs
run: yarn build:libs
run: yarn nx:build:libs
- run: git status
- name: type check
run: yarn type-check
run: yarn nx:type-check
- run: git status
- name: lint
run: yarn lint
- name: msg-system config validation
run: yarn workspace @trezor/suite-data msg-system-validate-config
- name: lint js
run: yarn nx:lint:js
- name: lint styles
run: yarn nx:lint:styles
- name: unit tests
run: lerna run --stream test:unit
run: yarn nx:test-unit
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ logs
.attic
.env*
!.env.dev
nx-cloud.env

# cache
*.code-workspace
Expand All @@ -52,6 +53,7 @@ libDev
dist
public
coverage
tmp


## React Native section ##
Expand Down Expand Up @@ -137,3 +139,9 @@ buck-out/
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# @trezor/suite-data
packages/suite-data/files/browser-detection
packages/suite-data/files/message-system
packages/suite-data/files/guide
packages/suite-data/files/translations/master.json
170 changes: 170 additions & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
.next
build
build-electron
build-renderer
.build-storybook
\*.cpuprofile

# Dependency directory

node_modules

# OSX

.DS_Store

# Editors

.idea
_.sublime-project
_.sublime-workspace
.vscode/\*_/_
!.vscode/launch.json
!.vscode/tasks.json
!.vscode/settings.json
!.vscode/\*.code-snippets

# Logs

logs
\*.log
.yarnclean

.attic
.env\*
!.env.dev

# cache

_.code-workspace
**docker-snapshots**
**pycache**/
.cache/
.eslintcache
.stylelintcache
_.tsbuildinfo

# model 1 emulation file

docker/trezor-user-env/controller/emulator.img

# Vagrant

.vagrant

# build outputs

lib
libDev
dist
public
coverage
tmp

## React Native section

# Xcode

build/
_.pbxuser
!default.pbxuser
_.mode1v3
!default.mode1v3
_.mode2v3
!default.mode2v3
_.perspectivev3
!default.perspectivev3
xcuserdata
_.xccheckout
_.moved-aside
DerivedData
_.hmap
_.ipa
_.dSYM.zip
_.xcuserstate

# Android/IntelliJ

build/
.idea
.gradle
local.properties
_.iml
_.hprof

# BUCK

buck-out/
\.buckd/
\*.keystore
!debug.keystore

# fastlane

#

# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the

# screenshots whenever they are needed.

# For more information about the recommended setup visit:

# https://docs.fastlane.tools/best-practices/source-control/

**/android/fastlane/report.xml
**/android/fastlane/Preview.html
**/android/fastlane/screenshots
**/ios/fastlane/report.xml
**/ios/fastlane/Preview.html
**/ios/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
\*\*/fastlane/screenshots

_.cer
_.certSigningRequest
_.p12
_.mobileprovision

# scan temporary files

\*\*/android/fastlane/test_output

# ios

**/ios/\*.xcarchive
**/ios/builds/\*

# Ruby / CocoaPods

**/ios/Pods/
**/vendor/bundle/

# android

\*_/android/builds/_

# fastlane supply (google service account - upload key)

\*\*/android/upload-key.json

# Bundle artifact

\*.jsbundle

# Yarn 3

.yarn/\*
.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# @trezor/suite-data

packages/suite-data/files/browser-detection
packages/suite-data/files/message-system
packages/suite-data/files/guide
packages/suite-data/files/translations/master.json
43 changes: 43 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"extends": "nx/presets/npm.json",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": [
"lint",
"test:unit",
"type-check",
"lint:js",
"lint:styles",
"build:lib"
],
"accessToken": "NmE2NmFlYTUtN2JhZi00ZmQ3LWEyYzMtYWRkNzc3MTg0YmUyfHJlYWQ=",
"parallel": 5
}
}
},
"targetDefaults": {
"build:lib": {
"dependsOn": ["^build:lib"],
"outputs": ["./lib"]
},
"type-check": {
"dependsOn": ["^build:lib"],
"outputs": []
},
"test:unit": {
"dependsOn": ["^build:lib"],
"outputs": []
},
"lint:js": {
"inputs": ["{projectRoot}/**/*.js", "{projectRoot}/**/*.ts", "{projectRoot}/**/*.tsx"]
},
"lint:styles": {
"inputs": ["{projectRoot}/**/*.tsx"]
}
},
"affected": {
"defaultBase": "origin/develop"
}
}
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@
"type-check": "yarn lerna run type-check",
"type-check:force": "rimraf -rf -- **/libDev && yarn type-check",
"test:unit": "yarn lerna run test:unit",
"lint:js": "eslint --report-unused-disable-directives --cache --ignore-path .gitignore --ext .js,.ts,.tsx ./",
"lint:js": "yarn lerna run lint:js",
"lint": "yarn lerna run lint:styles && yarn lint:js",
"lint-staged": "npx lint-staged",
"lint:shellcheck": "./scripts/shellcheck.sh",
"_______ Global Scripts _______": "Shared scripts for running in all workspaces",
"g:eslint": "cd $INIT_CWD && eslint --report-unused-disable-directives --cache --ignore-path ../../.gitignore",
"_______ Nx testing _______": "Nx wrapped commands for testing, linting, type checking...",
"nx:build:libs": "yarn nx affected --target=build:lib",
"nx:type-check": "yarn nx affected --target=type-check",
"nx:test-unit": "yarn nx affected --target=test:unit",
"nx:lint:js": "yarn nx affected --target=lint:js",
"nx:lint:styles": "yarn nx affected --target=lint:styles",
"_______ Commands _______": "Useful commands and scripts.",
"patch": "yarn patch-package",
"update-project-references": "yarn tsx ./scripts/updateProjectReferences.js --ignore packages/suite-desktop",
Expand All @@ -49,7 +57,8 @@
"_______ Aliases _______": "Aliases for longer commands which we often have to run manually. Names don't have to be pretty or make total sense.",
"refs": "yarn update-project-references",
"types": "yarn type-check",
"messages": "yarn msg-system-sign-config"
"messages": "yarn msg-system-sign-config",
"validate": "yarn verify-project-references && yarn nx:lint:js && yarn nx:lint:styles && yarn nx:build:libs && yarn nx:type-check && yarn nx:test-unit"
},
"lint-staged": {
"packages/**/*.{ts,tsx}": [
Expand Down Expand Up @@ -78,6 +87,7 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@nrwl/nx-cloud": "14.5.1",
"@types/jest": "^26.0.20",
"@types/node": "^16.11.49",
"@types/prettier": "^2.7.0",
Expand All @@ -99,6 +109,7 @@
"lerna": "^3.20.2",
"metro-react-native-babel-preset": "^0.71.3",
"npm-run-all": "^4.1.5",
"nx": "14.5.10",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"sideEffects": false,
"main": "src/index",
"scripts": {
"lint": "eslint '**/*.{ts,tsx,js}'",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest -c ../../jest.config.base.js",
"type-check": "tsc --build"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"sideEffects": false,
"main": "src/index",
"scripts": {
"lint": "eslint '**/*.{ts,tsx,js}'",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "tsc --build",
"dev": "tsx watch ./src/index.ts",
"build": "rimraf ./lib && yarn tsc --build tsconfig.lib.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"build:workers": "rimraf build && yarn build:workers-web && yarn build:workers-module",
"build:workers-web": "webpack --config ./webpack/workers.web.js",
"build:workers-module": "webpack --config ./webpack/workers.module.js",
"lint": "eslint '**/*.{ts,tsx,js}'",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest --verbose -c jest.config.unit.js",
"test:integration": "jest -c jest.config.integration.js",
"type-check": "tsc --build tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"sideEffects": false,
"scripts": {
"lint": "yarn lint:js && yarn lint:styles",
"lint:js": "eslint '**/*.{ts,tsx,js}'",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"lint:styles": "npx stylelint './src/**/*{.tsx,.ts}' --cache",
"lint-fix": "npx eslint ./src --fix",
"type-check": "tsc --build tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"scripts": {
"lint": "eslint '**/*.{ts,tsx,js}'",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest --coverage",
"build:lib": "rimraf lib && yarn tsc --build ./tsconfig.lib.json",
"type-check": "tsc --build tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "rimraf build && TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/dev.webpack.config.ts",
"build": "rimraf build && TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/prod.webpack.config.ts",
"lint": "eslint '**/*{.ts,.tsx}'",
"lint:js": "yarn g:eslint '**/*{.ts,.tsx}'",
"type-check": "tsc --build tsconfig.json"
},
"dependencies": {
Expand Down
Loading

0 comments on commit a446583

Please sign in to comment.