Skip to content

Commit

Permalink
fix: clean script and dependency task management
Browse files Browse the repository at this point in the history
  • Loading branch information
tracy-french committed Dec 11, 2024
1 parent eb43803 commit 79849bc
Show file tree
Hide file tree
Showing 6 changed files with 616 additions and 46 deletions.
135 changes: 123 additions & 12 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,66 @@ jobs:
- name: Git
run: npm run test:git

unit:
needs: repo
build-pack:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
package:
[
core,
core-util,
dashboard,
doc-site,
helpers,
react-components,
scene-composer,
source-iotsitewise,
source-iottwinmaker,
tools-iottwinmaker,
]
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: '.turbo'
key: ${{ runner.os }}-turbo-build-pack-${{ matrix.package}}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-build-pack-${{ matrix.package}}-
- name: Validate
run: npx turbo build pack -F @iot-app-kit/${{ matrix.package }}

lint:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -67,6 +123,7 @@ jobs:
scene-composer,
source-iotsitewise,
source-iottwinmaker,
testing-util,
tools-iottwinmaker,
vite-config,
]
Expand Down Expand Up @@ -101,25 +158,79 @@ jobs:
uses: actions/cache@v4
with:
path: '.turbo'
key: ${{ runner.os }}-turbo-unit-${{ matrix.package}}-${{ github.sha }}
key: ${{ runner.os }}-turbo-lint-${{ matrix.package}}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-unit-${{ matrix.package}}-
${{ runner.os }}-turbo-lint-${{ matrix.package}}-
- name: Test and lint cache
- name: Lint cache
uses: actions/cache@v4
with:
path: '**/.cache'
key: ${{ runner.os }}-test-lint-${{ matrix.package}}-${{ github.sha }}
key: ${{ runner.os }}-lint-${{ matrix.package}}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-test-lint-${{ matrix.package}}-
${{ runner.os }}-lint-${{ matrix.package}}-
- name: Validate
run: npx turbo build lint test pack --filter=@iot-app-kit/${{ matrix.package }}
run: npx turbo lint -F @iot-app-kit/${{ matrix.package }}

unit:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
package:
[
core,
core-util,
dashboard,
react-components,
scene-composer,
source-iotsitewise,
source-iottwinmaker,
tools-iottwinmaker,
]
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: '.turbo'
key: ${{ runner.os }}-turbo-unit-${{ matrix.package}}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-unit-${{ matrix.package}}-
- name: Validate
run: npx turbo test -F @iot-app-kit/${{ matrix.package }}

playwright:
needs: repo
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -190,7 +301,7 @@ jobs:

- name: Playwright
run: |
npx turbo test:ui:ci --filter=@iot-app-kit/${{ matrix.package.name }} -- --shard=${{ matrix.package.shardIndex }}/${{ matrix.package.totalShards }}
npx turbo test:ui:ci -F @iot-app-kit/${{ matrix.package.name }} -- --shard=${{ matrix.package.shardIndex }}/${{ matrix.package.totalShards }}
- name: Test report
id: upload-test-report
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
"start": "npm run dev",
"dev": "turbo dev -F @iot-app-kit/dev-env",
"build": "turbo build",
"clean": "npx rimraf .turbo .vscode",
"clean:nuke": "npx rimraf .turbo node_modules",
"clean": "turbo clean",
"clean:root": "npx rimraf .vscode",
"clean:turbo": "turbo clean:turbo",
"clean:turbo:root": "npx rimraf .turbo",
"clean:nuke": "turbo clean:nuke",
"clean:nuke:root": "npm run clean:root && npm run clean:turbo:root && npx rimraf node_modules",
"fix": "turbo fix && npm run fix:stylelint",
"fix:stylelint": "stylelint '**/*.css' --fix --ignore-path .gitignore",
"test": "turbo test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('asset drop-down', () => {

await dropDown.open();

expect(screen.getByText('No assets.')).toBeVisible();
expect(screen.getAllByText('No assets.')[0]).toBeVisible();
});

it('renders a multi-select drop-down without configuration', async () => {
Expand All @@ -52,7 +52,7 @@ describe('asset drop-down', () => {

await dropDown.open();

expect(screen.getByText('No assets.')).toBeVisible();
expect(screen.getAllByText('No assets.')[0]).toBeVisible();
});

it('renders drop-down options', async () => {
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('asset drop-down', () => {
expect(dropDown.getOption(asset1)).toBeVisible();
expect(dropDown.getOption(asset2)).toBeVisible();
expect(dropDown.queryOption(asset3)).not.toBeInTheDocument();
expect(screen.getByText('(2/3) assets matched')).toBeVisible();
expect(screen.getAllByText('(2/3) assets matched')[0]).toBeVisible();

await dropDown.clearFilter();

Expand All @@ -353,15 +353,15 @@ describe('asset drop-down', () => {
expect(dropDown.queryOption(asset1)).not.toBeInTheDocument();
expect(dropDown.queryOption(asset2)).not.toBeInTheDocument();
expect(dropDown.getOption(asset3)).toBeVisible();
expect(screen.getByText('(1/3) assets matched')).toBeVisible();
expect(screen.getAllByText('(1/3) assets matched')[0]).toBeVisible();

await dropDown.clearFilter();
await user.keyboard('Similar Description');

expect(dropDown.queryOption(asset1)).not.toBeInTheDocument();
expect(dropDown.getOption(asset2)).toBeVisible();
expect(dropDown.getOption(asset3)).toBeVisible();
expect(screen.getByText('(2/3) assets matched')).toBeVisible();
expect(screen.getAllByText('(2/3) assets matched')[0]).toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('asset model drop-down', () => {

await dropDown.open();

expect(screen.getByText('No asset models.')).toBeVisible();
expect(screen.getAllByText('No asset models.')[0]).toBeVisible();
});

it('renders a multi-select drop-down without configuration', async () => {
Expand All @@ -54,7 +54,7 @@ describe('asset model drop-down', () => {

await dropDown.open();

expect(screen.getByText('No asset models.')).toBeVisible();
expect(screen.getAllByText('No asset models.')[0]).toBeVisible();
});

it('renders drop-down options', async () => {
Expand Down Expand Up @@ -326,7 +326,6 @@ describe('asset model drop-down', () => {
});
});

// TODO: fix this flaky test ASAP
describe('filtering', () => {
it('filters asset models', async () => {
const assetModel1 = {
Expand Down Expand Up @@ -369,7 +368,9 @@ describe('asset model drop-down', () => {
expect(dropDown.getOption(assetModel1)).toBeVisible();
expect(dropDown.getOption(assetModel2)).toBeVisible();
expect(dropDown.queryOption(assetModel3)).not.toBeInTheDocument();
expect(screen.getByText('(2/3) asset models matched')).toBeVisible();
expect(
screen.getAllByText('(2/3) asset models matched')[0]
).toBeVisible();

await dropDown.clearFilter();

Expand All @@ -382,15 +383,19 @@ describe('asset model drop-down', () => {
expect(dropDown.queryOption(assetModel1)).not.toBeInTheDocument();
expect(dropDown.queryOption(assetModel2)).not.toBeInTheDocument();
expect(dropDown.getOption(assetModel3)).toBeVisible();
expect(screen.getByText('(1/3) asset models matched')).toBeVisible();
expect(
screen.getAllByText('(1/3) asset models matched')[0]
).toBeVisible();

await dropDown.clearFilter();
await user.keyboard('Similar Description');

expect(dropDown.queryOption(assetModel1)).not.toBeInTheDocument();
expect(dropDown.getOption(assetModel2)).toBeVisible();
expect(dropDown.getOption(assetModel3)).toBeVisible();
expect(screen.getByText('(2/3) asset models matched')).toBeVisible();
}, 40000);
expect(
screen.getAllByText('(2/3) asset models matched')[0]
).toBeVisible();
}, 10000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('asset property drop-down', () => {

await dropDown.open();

expect(screen.getByText('No asset properties.')).toBeVisible();
expect(screen.getAllByText('No asset properties.')[0]).toBeVisible();
});

it('renders a multi-select drop-down without configuration', async () => {
Expand All @@ -65,7 +65,7 @@ describe('asset property drop-down', () => {

await dropDown.open();

expect(screen.getByText('No asset properties.')).toBeVisible();
expect(screen.getAllByText('No asset properties.')[0]).toBeVisible();
});

it('renders drop-down options', async () => {
Expand Down Expand Up @@ -494,7 +494,9 @@ describe('asset property drop-down', () => {
expect(dropDown.getOption(assetModelProperty1)).toBeVisible();
expect(dropDown.getOption(assetModelProperty2)).toBeVisible();
expect(dropDown.queryOption(assetModelProperty3)).not.toBeInTheDocument();
expect(screen.getByText('(2/3) asset properties matched')).toBeVisible();
expect(
screen.getAllByText('(2/3) asset properties matched')[0]
).toBeVisible();

await dropDown.clearFilter();

Expand All @@ -507,7 +509,9 @@ describe('asset property drop-down', () => {
expect(dropDown.queryOption(assetModelProperty1)).not.toBeInTheDocument();
expect(dropDown.queryOption(assetModelProperty2)).not.toBeInTheDocument();
expect(dropDown.getOption(assetModelProperty3)).toBeVisible();
expect(screen.getByText('(1/3) asset properties matched')).toBeVisible();
expect(
screen.getAllByText('(1/3) asset properties matched')[0]
).toBeVisible();
});
});
});
Loading

0 comments on commit 79849bc

Please sign in to comment.