Skip to content

Commit

Permalink
Merge pull request #112 from scalprum/adopt-nx
Browse files Browse the repository at this point in the history
[WIP] Adopt NX to manage the monorepo packages
  • Loading branch information
Hyperkid123 authored Dec 1, 2023
2 parents 41ef708 + 59d7dc8 commit 1331ec6
Show file tree
Hide file tree
Showing 150 changed files with 25,616 additions and 31,664 deletions.
63 changes: 0 additions & 63 deletions .circleci/config.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"body-max-line-length": [0]
}
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/**/node_modules
/**/dist
/**/coverage
node_modules
74 changes: 47 additions & 27 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
}
},
"settings": {
"import/resolver": { "typescript": {} }
},
"plugins": ["prettier"],
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx", "prettier"],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
"plugin:prettier/recommended"
],
"overrides": [
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
],
"env": {
"es6": true,
"browser": true,
"node": true,
"jest": true
},
"rules": {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "argsIgnorePattern": "^_", "ignoreRestSiblings": false }]
"@nx/dependency-checks": "off"
}
}
11 changes: 11 additions & 0 deletions .github/actions/cypress-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Cypress runner cache
description: Retrieve and cache the cypress runner
runs:
using: "composite"
steps:
# cache cypress runner
- uses: actions/cache@v3
id: cypress-cache
with:
path: /home/runner/.cache/Cypress
key: cypress-runner-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
14 changes: 14 additions & 0 deletions .github/actions/lint/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint project
description: verify linting rules
runs:
using: "composite"
steps:
- uses: nrwl/nx-set-shas@v3
- uses: './.github/actions/node-cache'
- name: Install deps
shell: bash
run: npm i
- name: Lint affected
shell: bash
run: npx nx affected -t lint

12 changes: 12 additions & 0 deletions .github/actions/node-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Node modules cache
description: Retrieve and cache project node_modules
runs:
using: "composite"
steps:
# cache node modules for all jobs to use
- uses: actions/cache@v3
id: node_modules-cache
with:
path: |
**/node_modules
key: install-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
48 changes: 48 additions & 0 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release job
description: build affected packages and publish them to npm
inputs:
npm_token:
description: 'NPM token'
required: true
gh_token:
description: 'Github token'
required: true
gh_actor:
description: 'Github actor'
required: true
runs:
using: "composite"
steps:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- uses: './.github/actions/node-cache'
- name: Install deps
shell: bash
run: npm i
- name: git config
shell: bash
run: |
git config user.name "${{ inputs.gh_actor }}"
git config user.email "${{ inputs.gh_actor }}@users.noreply.github.com"
- name: Build
shell: bash
run: npx nx run-many -t build
- name: Set publish config
env:
NPM_TOKEN: ${{ inputs.npm_token }}
shell: bash
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- name: Version
shell: bash
env:
GH_TOKEN: ${{ inputs.gh_token }}
GITHUB_TOKEN: ${{ inputs.gh_token }}
run: npx nx affected --base=last-release --parallel=1 --target=version --postTargets=syncDependencies,npm,github --trackDeps
- name: Tag last-release
shell: bash
run: |
git tag -f last-release
git push origin last-release --force
16 changes: 16 additions & 0 deletions .github/actions/test-e2e/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: E2E tests
description: verify e2e tests
runs:
using: "composite"
steps:
- uses: nrwl/nx-set-shas@v3
- uses: './.github/actions/node-cache'
- uses: './.github/actions/cypress-cache'
- uses: './.github/actions/webpack-cache'
- name: Install deps
shell: bash
run: npm i
- name: Run e2e tests
shell: bash
run: npx nx run test-app-e2e:e2e --ci

14 changes: 14 additions & 0 deletions .github/actions/test-unit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Unit tests
description: verify unit tests
runs:
using: "composite"
steps:
- uses: nrwl/nx-set-shas@v3
- uses: './.github/actions/node-cache'
- name: Install deps
shell: bash
run: npm i
- name: Test affected
shell: bash
run: npx nx affected -t test --configuration=ci

12 changes: 12 additions & 0 deletions .github/actions/webpack-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Webpack dev server cache
description: Cache for e2e test runs
runs:
using: "composite"
steps:
# cache node modules for all jobs to use
- uses: actions/cache@v3
id: webpack-cache
with:
path: |
**/.webpack-cache
key: webpack-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
# cache node modules for all jobs to use
- uses: './.github/actions/node-cache'
# cache cypress runner
- uses: './.github/actions/cypress-cache'
- name: Install deps
run: npm ci
lint:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: './.github/actions/lint'
test:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: './.github/actions/test-unit'
build:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: './.github/actions/node-cache'
- name: Install deps
run: npm i
- name: Build affected
run: npx nx affected -t build
test-e2e:
runs-on: ubuntu-latest
needs: [install, build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: './.github/actions/test-e2e'
release:
runs-on: ubuntu-latest
needs: [install, lint, test, build, test-e2e]
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: './.github/actions/release'
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN }}
gh_actor: ${GITHUB_ACTOR}
Loading

0 comments on commit 1331ec6

Please sign in to comment.