Skip to content

Commit

Permalink
chore: remove need to build packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tracy-french committed Nov 27, 2024
1 parent 3204abc commit c9bb02c
Show file tree
Hide file tree
Showing 274 changed files with 1,025 additions and 1,147 deletions.
98 changes: 84 additions & 14 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Git
run: npm run test:git

unit:
validation:
needs: repo
runs-on: ubuntu-latest
timeout-minutes: 30
Expand All @@ -69,6 +69,7 @@ jobs:
source-iottwinmaker,
tools-iottwinmaker,
]
task: [build, lint]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -100,20 +101,73 @@ jobs:
uses: actions/cache@v4
with:
path: '.turbo'
key: ${{ runner.os }}-turbo-unit-${{ matrix.package}}-${{ github.sha }}
key: ${{ runner.os }}-turbo-${{ matrix.task }}-${{ matrix.package }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-unit-${{ matrix.package}}-
${{ runner.os }}-turbo-${{ matrix.task }}-${{ matrix.package }}-
- name: Test and lint cache
- name: Validate
run: npx turbo ${{ matrix.task }} --filter=@iot-app-kit/${{ matrix.package }}

unit-test:
needs: repo
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
package:
[
{ name: 'core', shardIndex: 1, totalShards: 1 },
{ name: 'core-util', shardIndex: 1, totalShards: 1 },
{ name: 'dashboard', shardIndex: 1, totalShards: 2 },
{ name: 'dashboard', shardIndex: 2, totalShards: 2 },
{ name: 'react-components', shardIndex: 1, totalShards: 2 },
{ name: 'react-components', shardIndex: 2, totalShards: 2 },
{ name: 'scene-composer', shardIndex: 1, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 2, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 3, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 4, totalShards: 4 },
{ name: 'source-iotsitewise', shardIndex: 1, totalShards: 1 },
{ name: 'source-iottwinmaker', shardIndex: 1, totalShards: 1 },
{ name: 'tools-iottwinmaker', shardIndex: 1, totalShards: 1 },
]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: node_modules cache
id: npm-cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-node_modules-${{hashFiles('**/package-lock.json')}}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.npm-cache.outputs.cache-hit != 'true'
shell: bash
env:
NODE_OPTIONS: '--max_old_space_size=8192'
run: npm ci --prefer-offline --no-audit --progress=false --workspaces --include-workspace-root

- name: Turbo cache
uses: actions/cache@v4
with:
path: '**/.cache'
key: ${{ runner.os }}-test-lint-${{ matrix.package}}-${{ github.sha }}
path: '.turbo'
key: ${{ runner.os }}-turbo-unit-test-${{ matrix.package.name }}-${{ matrix.package.shardIndex }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-test-lint-${{ matrix.package}}-
${{ runner.os }}-turbo-unit-test-${{ matrix.package.name }}-${{ matrix.package.shardIndex }}-
- name: Validate
run: npx turbo build:cjs build:es lint test --filter=@iot-app-kit/${{ matrix.package }}
run: npx turbo test --filter=@iot-app-kit/${{ matrix.package.name }} -- --shard=${{ matrix.package.shardIndex }}/${{ matrix.package.totalShards }}

playwright:
needs: repo
Expand All @@ -124,12 +178,28 @@ jobs:
matrix:
package:
[
{ name: 'dev-env', shardIndex: 1, totalShards: 4 },
{ name: 'dev-env', shardIndex: 2, totalShards: 4 },
{ name: 'dev-env', shardIndex: 3, totalShards: 4 },
{ name: 'dev-env', shardIndex: 4, totalShards: 4 },
{ name: 'react-components', totalShards: 1, shardIndex: 1 },
{ name: 'scene-composer', totalShards: 1, shardIndex: 1 },
{ name: 'dev-env', shardIndex: 1, totalShards: 16 },
{ name: 'dev-env', shardIndex: 2, totalShards: 16 },
{ name: 'dev-env', shardIndex: 3, totalShards: 16 },
{ name: 'dev-env', shardIndex: 4, totalShards: 16 },
{ name: 'dev-env', shardIndex: 5, totalShards: 16 },
{ name: 'dev-env', shardIndex: 6, totalShards: 16 },
{ name: 'dev-env', shardIndex: 7, totalShards: 16 },
{ name: 'dev-env', shardIndex: 8, totalShards: 16 },
{ name: 'dev-env', shardIndex: 9, totalShards: 16 },
{ name: 'dev-env', shardIndex: 10, totalShards: 16 },
{ name: 'dev-env', shardIndex: 11, totalShards: 16 },
{ name: 'dev-env', shardIndex: 12, totalShards: 16 },
{ name: 'dev-env', shardIndex: 13, totalShards: 16 },
{ name: 'dev-env', shardIndex: 14, totalShards: 16 },
{ name: 'dev-env', shardIndex: 15, totalShards: 16 },
{ name: 'dev-env', shardIndex: 16, totalShards: 16 },
{ name: 'react-components', shardIndex: 1, totalShards: 2 },
{ name: 'react-components', shardIndex: 2, totalShards: 2 },
{ name: 'scene-composer', shardIndex: 1, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 2, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 3, totalShards: 4 },
{ name: 'scene-composer', shardIndex: 4, totalShards: 4 },
]
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion apps/dev-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"clean": "rimraf storybook-static .turbo .cache test-results playwright-report",
"clean:nuke": "npm run clean && rimraf node_modules",
"dev": "storybook dev -p 6006",
"lint": "eslint . --max-warnings=0 --cache --cache-location .cache/eslint/ & tsc --noEmit",
"lint": "eslint . --max-warnings=0 --cache --cache-location .cache/eslint/",
"fix": "eslint --fix . --cache --cache-location ./cache/eslint/",
"test:ui": "npx playwright test",
"test:ui:ci": "npx playwright test",
Expand Down
2 changes: 0 additions & 2 deletions apps/dev-env/stories/dashboard/sitewise-dashboard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ type Story = StoryObj<typeof Dashboard>;

export const Main: Story = {
render: (_story, { args }) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [initialViewMode, setInitialViewMode] = useState<'preview' | 'edit'>(
'edit'
);

// on save not only updates local storage but forces the dashboard to reload given the updated config
// this is done to more realistically match the dashboard implementation in iot-application
// eslint-disable-next-line react-hooks/rules-of-hooks
const onSave = useCallback(
async (
dashboard: DashboardConfiguration,
Expand Down
3 changes: 3 additions & 0 deletions apps/dev-env/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
conditions: ['development'],
},
});
4 changes: 3 additions & 1 deletion configuration/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module.exports = {
pragma: 'h',
},
'import/resolver': {
typescript: true,
typescript: {
conditionNames: ['development'],
},
node: true,
},
},
Expand Down
8 changes: 3 additions & 5 deletions configuration/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"clean:nuke": "rimraf node_modules"
},
"dependencies": {
"@types/node": "^18.16.18",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.45.0",
Expand All @@ -17,6 +18,7 @@
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "8.8.0",
"eslint-config-turbo": "^2.2.3",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-formatjs": "4.10.3",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jest": "^27.2.3",
Expand All @@ -25,11 +27,7 @@
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-unused-imports": "2.0.0"
},
"devDependencies": {
"@types/node": "^18.16.18",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-unused-imports": "2.0.0",
"typescript": "^5.5.4"
}
}
3 changes: 2 additions & 1 deletion configuration/ts-config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ESNEXT",
"jsx": "react-jsx"
"jsx": "react-jsx",
"customConditions": ["development"]
}
}
3 changes: 2 additions & 1 deletion configuration/ts-config/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"incremental": true
"incremental": true,
"customConditions": null
}
}
3 changes: 2 additions & 1 deletion configuration/ts-config/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.build.json",
"compilerOptions": {
"module": "ESNext"
"module": "ESNext",
"customConditions": ["esm"]
}
}
22 changes: 2 additions & 20 deletions docs/DevEnv.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,14 @@

### Useful commands

#### Run dev-env (no live packages)
#### Run dev-env

```sh
turbo dev --filter=@iot-app-kit/dev-env
```

#### Run dev-env + live dashboard

```sh
turbo dev --filter=@iot-app-kit/dev-env --filter=@iot-app-kit/dashboard
```

#### Run dev-env + multiple live packages

```sh
turbo dev --filter=@iot-app-kit/dev-env --filter=@iot-app-kit/dashboard --filter=@iot-app-kit/react-components
npm start
```

#### Run react-components dev env (to be removed in favor of @iot-app-kit/dev-env)

```sh
turbo dev:react-components --filter=@iot-app-kit/react-components
```

#### Run react-components dev env + live packages (to be removed in favor of @iot-app-kit/dev-env)

```sh
turbo dev:react-components --filter=@iot-app-kit/react-components --filter=@iot-app-kit/source-iotsitewise
```
2 changes: 1 addition & 1 deletion examples/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]
},
"browserslist": {
"production": [
"default": [
">0.2%",
"not dead",
"not op_mini all"
Expand Down
17 changes: 3 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,9 @@
"scripts": {
"install-ws": "npm install --prefer-offline --no-audit --workspaces --include-workspace-root",
"bootstrap": "npm run install-ws && npm run build",
"start": "cd packages/components && npm start",
"start": "npm run dev",
"dev": "npm run dev --workspace=@iot-app-kit/dev-env",
"build": "turbo run build",
"build:core": "turbo run build --filter=@iot-app-kit/core",
"build:core-util": "turbo run build --filter=@iot-app-kit/core-util",
"build:dashboard": "turbo run build --filter=@iot-app-kit/dashboard",
"build:doc-site": "turbo run build --filter=@iot-app-kit/doc-site",
"build:react-components": "turbo run build --filter=@iot-app-kit/react-components",
"build:scene-composer": "turbo run build --filter=@iot-app-kit/scene-composer",
"build:source-iotsitewise": "turbo run build --filter=@iot-app-kit/source-iotsitewise",
"build:source-iottwinmaker": "turbo run build --filter=@iot-app-kit/source-iottwinmaker",
"build:testing-util": "turbo run build --filter=@iot-app-kit/testing-util",
"build:tools-iottwinmaker": "turbo run build --filter=@iot-app-kit/tools-iottwinmaker",
"clean": "turbo run clean && rimraf .turbo",
"clean:nuke": "turbo run clean:nuke && rimraf .turbo node_modules",
"fix": "turbo run fix && npm run fix:stylelint",
Expand Down
Loading

0 comments on commit c9bb02c

Please sign in to comment.