From f17bf7107da40b7453ea2a37118eea243446fc92 Mon Sep 17 00:00:00 2001 From: Caleb Shafer <31107829+calebmshafer@users.noreply.github.com> Date: Mon, 30 Jan 2023 19:03:57 -0500 Subject: [PATCH] Clean up build pipelines (#4995) * Update template path * fix use of template * clean up variables * Regression test updates * Fix node version of integration tests * Fix regression testing machine pool * Fix uses of fs.rmSync for Node 12 compatibility * Do not limit the max parallel runs * rush change * Fix regression integration test on Mac and Windows * fix issues with the params passed to removeSync * fix lint rules * Only run regression on 12.x as 12.22 is the latest minor version * set timeout to an hr, run appui tests in node12, ?? not added til node14 * hacky fix for https://github.com/nodejs/node/issues/45171\#issuecomment-1290833591 until patched in node 18 * rush change * fix more tests * rush change * use || because ?? not supported til node14. again --------- Co-authored-by: Arun George --- README.md | 4 +- .../fix-public-ci_2023-01-30-21-16.json | 10 ++++ .../fix-public-ci_2023-01-29-16-38.json | 10 ++++ .../fix-public-ci_2023-01-30-19-39.json | 10 ++++ common/config/azure-pipelines/ci.yaml | 21 +------- ...ation-client-regression-pr-validation.yaml | 4 +- .../integration-pr-validation.yaml | 2 +- .../integration-validation.yaml | 22 +++----- .../config/azure-pipelines/jobs/fast-ci.yaml | 7 +-- .../jobs/regression-testing.yaml | 37 ++++---------- .../azure-pipelines/jobs/version-bump.yaml | 4 +- .../azure-pipelines/templates/core-build.yaml | 5 +- .../templates/integration-test-steps.yaml | 45 ++++++++++++----- .../templates/publish-test-results.yaml | 50 +++++++++---------- core/backend/src/workspace/Workspace.ts | 4 +- .../src/integration/Checkpoints.test.ts | 4 +- .../presentation/src/IntegrationTests.ts | 3 +- full-stack-tests/presentation/src/Utils.ts | 4 +- .../src/test/common/DateUtils.test.ts | 4 +- .../src/test/editors/DateTimeEditor.test.tsx | 4 +- .../test/timeline/TimelineComponent.test.tsx | 2 +- ui/scripts/setup-tests-noreact.js | 8 +-- ui/scripts/setup-tests.js | 8 +-- 23 files changed, 139 insertions(+), 133 deletions(-) create mode 100644 common/changes/@itwin/components-react/fix-public-ci_2023-01-30-21-16.json create mode 100644 common/changes/@itwin/core-backend/fix-public-ci_2023-01-29-16-38.json create mode 100644 common/changes/@itwin/imodel-components-react/fix-public-ci_2023-01-30-19-39.json diff --git a/README.md b/README.md index aa0614ccf5c5..163f52cb5763 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Each package has its own **node_modules** directory that contains symbolic links ## Prerequisites - [Git](https://git-scm.com/) -- [Node](https://nodejs.org/en/):an installation of the latest security patch of Node 18. The Node installation also includes the **npm** package manager. +- [Node](https://nodejs.org/en/): an installation of the latest security patch of Node 18. The Node installation also includes the **npm** package manager. - [Rush](https://github.com/Microsoft/web-build-tools/wiki/Rush): to install `npm install -g @microsoft/rush` - [TypeScript](https://www.typescriptlang.org/): this is listed as a devDependency, so if you're building it from source, you will get it with `rush install`. - [Visual Studio Code](https://code.visualstudio.com/): an optional dependency, but the repository structure is optimized for its use @@ -49,7 +49,7 @@ For incremental builds, the `rush build` command can be used to only build packa 3. Ensure linting passes when run locally: `rush lint` 4. Locally commit changes: `git commit` (or use the Visual Studio Code user interface) 5. Repeat steps 1-4 until ready to push changes -6. Check for API signature changes: `rush extract-api`. This will update the signature files, located in `common/api`. __Note:__ before doing this, first do the following: +6. Check for API signature changes: `rush extract-api`. This will update the signature files, located in `common/api`. **Note:** before doing this, first do the following: - Be sure that your branch is up to date with the target branch (i.e. `git merge origin/master`) - Cleanup your build output: `rush clean` - Rebuild the project: `rush build` diff --git a/common/changes/@itwin/components-react/fix-public-ci_2023-01-30-21-16.json b/common/changes/@itwin/components-react/fix-public-ci_2023-01-30-21-16.json new file mode 100644 index 000000000000..d2d24b087cf6 --- /dev/null +++ b/common/changes/@itwin/components-react/fix-public-ci_2023-01-30-21-16.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/components-react", + "comment": "", + "type": "none" + } + ], + "packageName": "@itwin/components-react" +} \ No newline at end of file diff --git a/common/changes/@itwin/core-backend/fix-public-ci_2023-01-29-16-38.json b/common/changes/@itwin/core-backend/fix-public-ci_2023-01-29-16-38.json new file mode 100644 index 000000000000..99b35bb89b62 --- /dev/null +++ b/common/changes/@itwin/core-backend/fix-public-ci_2023-01-29-16-38.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-backend", + "comment": "", + "type": "none" + } + ], + "packageName": "@itwin/core-backend" +} \ No newline at end of file diff --git a/common/changes/@itwin/imodel-components-react/fix-public-ci_2023-01-30-19-39.json b/common/changes/@itwin/imodel-components-react/fix-public-ci_2023-01-30-19-39.json new file mode 100644 index 000000000000..98181801665f --- /dev/null +++ b/common/changes/@itwin/imodel-components-react/fix-public-ci_2023-01-30-19-39.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/imodel-components-react", + "comment": "", + "type": "none" + } + ], + "packageName": "@itwin/imodel-components-react" +} \ No newline at end of file diff --git a/common/config/azure-pipelines/ci.yaml b/common/config/azure-pipelines/ci.yaml index cdd32198bb7b..f3431b44d58e 100644 --- a/common/config/azure-pipelines/ci.yaml +++ b/common/config/azure-pipelines/ci.yaml @@ -25,28 +25,14 @@ schedules: jobs: - job: - variables: - - name: linuxPool - value: "iModeljs Linux" - - name: mac_pool - value: iModelTechCI - - name: win_pool - value: iModelTechCI - strategy: matrix: "Windows_Node_18": OS: windows-latest - platform: Windows_NT - name: $(win_pool) "Linux_Node_18": OS: ubuntu-latest - platform: Linux - name: $(linux_pool) "MacOS_Node_18": OS: macOS-latest - platform: Darwin - name: $(mac_pool) pool: vmImage: $(OS) @@ -58,9 +44,6 @@ jobs: steps: - checkout: self - - template: ../templates/core-build.yaml + - template: ./templates/core-build.yaml parameters: - name: Node_18 - nodeVersion: 18.12.x - pool: - vmImage: $(OS) + nodeVersion: 18.x diff --git a/common/config/azure-pipelines/integration-client-regression-pr-validation.yaml b/common/config/azure-pipelines/integration-client-regression-pr-validation.yaml index 9f1258eb3546..eb92c9d4a924 100644 --- a/common/config/azure-pipelines/integration-client-regression-pr-validation.yaml +++ b/common/config/azure-pipelines/integration-client-regression-pr-validation.yaml @@ -12,11 +12,11 @@ variables: - group: iModel.js Integration Test Users jobs: - - job: Node_14_x + - job: Node_18_x condition: succeeded() pool: vmImage: ubuntu-latest steps: - template: templates/integration-test-steps.yaml parameters: - Node_Version: 14.x + nodeVersion: 18.x diff --git a/common/config/azure-pipelines/integration-pr-validation.yaml b/common/config/azure-pipelines/integration-pr-validation.yaml index c6bf774a4b5f..fc7f0c025307 100644 --- a/common/config/azure-pipelines/integration-pr-validation.yaml +++ b/common/config/azure-pipelines/integration-pr-validation.yaml @@ -37,4 +37,4 @@ jobs: steps: - template: templates/integration-test-steps.yaml parameters: - Node_Version: 18.x + nodeVersion: 18.x diff --git a/common/config/azure-pipelines/integration-validation.yaml b/common/config/azure-pipelines/integration-validation.yaml index 844aa557f521..3cdde73cf5ee 100644 --- a/common/config/azure-pipelines/integration-validation.yaml +++ b/common/config/azure-pipelines/integration-validation.yaml @@ -7,11 +7,11 @@ trigger: none pr: none schedules: -- cron: "0 0 * * Sun" - displayName: Weekly Sunday build - branches: - include: - - master + - cron: "0 0 * * Sun" + displayName: Weekly Sunday build + branches: + include: + - master variables: - group: iTwin.js non-secret config variables @@ -20,11 +20,7 @@ variables: jobs: - job: Integration_Tests_Full strategy: - maxParallel: 3 matrix: - Linux_node_12_7: - imageName: ubuntu-latest - nodeVersion: 12.17.0 Linux_node_12_x: imageName: ubuntu-latest nodeVersion: 12.x @@ -34,9 +30,6 @@ jobs: linux_node_16_x: imageName: ubuntu-latest nodeVersion: 16.x - Windows_node_12_7: - imageName: windows-latest - nodeVersion: 12.17.0 Windows_node_12_x: imageName: windows-latest nodeVersion: 12.x @@ -46,9 +39,6 @@ jobs: Windows_node_16_x: imageName: windows-latest nodeVersion: 16.x - MacOS_node_12_7: - imageName: macos-latest - nodeVersion: 12.17.0 MacOS_node_12_x: imageName: macos-latest nodeVersion: 12.x @@ -63,4 +53,4 @@ jobs: steps: - template: templates/integration-test-steps.yaml parameters: - Node_Version: $(nodeVersion) + nodeVersion: $(nodeVersion) diff --git a/common/config/azure-pipelines/jobs/fast-ci.yaml b/common/config/azure-pipelines/jobs/fast-ci.yaml index 89ea7d3674af..de0d1383bd43 100644 --- a/common/config/azure-pipelines/jobs/fast-ci.yaml +++ b/common/config/azure-pipelines/jobs/fast-ci.yaml @@ -32,15 +32,12 @@ jobs: strategy: matrix: "Windows_Node_18": - OS: windows-latest platform: Windows_NT name: $(win_pool) "Linux_Node_18": - OS: ubuntu-latest platform: Linux name: $(linux_pool) "MacOS_Node_18": - OS: macOS-latest platform: Darwin name: $(mac_pool) @@ -59,11 +56,11 @@ jobs: clean: true - template: ../templates/core-build.yaml parameters: - nodeVersion: 18.12.x + nodeVersion: 18.x buildIos: ${{ eq(variables['Agent.OS'], 'Darwin') }} # Will run if even there is a failure somewhere else in the pipeline. - template: ../templates/publish-test-results.yaml parameters: - NodeVersion: 18.12.x + nodeVersion: 18.x # The publish script identifies any new packages not previously published and tags the build - template: ../templates/publish.yaml diff --git a/common/config/azure-pipelines/jobs/regression-testing.yaml b/common/config/azure-pipelines/jobs/regression-testing.yaml index 2a8cb039196e..81652601c6c4 100644 --- a/common/config/azure-pipelines/jobs/regression-testing.yaml +++ b/common/config/azure-pipelines/jobs/regression-testing.yaml @@ -1,8 +1,8 @@ # iTwin.js Core Regression Testing Build # -# Tests all supported versions of iTwin.js on 3 main supported platforms; Windows 10, Ubuntu 20.04, and MacOS . +# Tests all supported versions of iTwin.js on 3 main supported platforms; Windows 10, Ubuntu 20.04, and MacOS. # -# Starts with the minimum version (currently 12.20.0) and then follows the tip of each subsequent minor version. +# Starts with the minimum version (currently 12.20.0) and then follows the tip of each subsequent major LTS (even-numbered) version. # # The current LTS is tested in all normal CI/PR builds so no need to test it here. @@ -19,7 +19,7 @@ schedules: jobs: - job: variables: - - name: linuxPool + - name: linux_pool value: "iModeljs Linux" - name: mac_pool value: iModelTechCI @@ -28,21 +28,21 @@ jobs: strategy: matrix: - "Windows_Node_18": + "Windows_Node_18_12_0": OS: windows-latest platform: Windows_NT name: $(win_pool) - node_version: 18.x - "Linux_Node_18": + node_version: 18.12.0 + "Linux_Node_18_12_0": OS: ubuntu-latest platform: Linux name: $(linux_pool) - node_version: 18.x - "MacOS_Node_18": + node_version: 18.12.0 + "MacOS_Node_18_12_0": OS: macOS-latest platform: Darwin name: $(mac_pool) - node_version: 18.x + node_version: 18.12.0 "Windows_Node_16": OS: windows-latest @@ -91,29 +91,14 @@ jobs: platform: Darwin name: $(mac_pool) node_version: 12.x - - "Windows_Node_12_22": - OS: windows-latest - platform: Windows_NT - name: $(win_pool) - node_version: 12.22.0 - "Linux_Node_12_22": - OS: ubuntu-latest - platform: Linux - name: $(linux_pool) - node_version: 12.22.0 - "MacOS_Node_12_22": - OS: macOS-latest - platform: Darwin - name: $(mac_pool) - node_version: 12.22.0 maxParallel: 3 pool: + name: $(name) demands: - Agent.OS -equals $(platform) - timeoutInMinutes: 120 + timeoutInMinutes: 60 workspace: clean: all diff --git a/common/config/azure-pipelines/jobs/version-bump.yaml b/common/config/azure-pipelines/jobs/version-bump.yaml index 91a7cda690df..cd5f24136dfc 100644 --- a/common/config/azure-pipelines/jobs/version-bump.yaml +++ b/common/config/azure-pipelines/jobs/version-bump.yaml @@ -46,9 +46,9 @@ jobs: - checkout: self - task: NodeTool@0 - displayName: Use Node 12.x + displayName: Use Node 18.x inputs: - versionSpec: 12.x + versionSpec: 18.x checkLatest: true - bash: | diff --git a/common/config/azure-pipelines/templates/core-build.yaml b/common/config/azure-pipelines/templates/core-build.yaml index 6b3d8ea4dcbd..242b717d4ffa 100644 --- a/common/config/azure-pipelines/templates/core-build.yaml +++ b/common/config/azure-pipelines/templates/core-build.yaml @@ -1,6 +1,9 @@ # This defines the core steps for building and validating iTwin.js Core parameters: + - name: nodeVersion # name of the parameter; required + type: string # data type of the parameter; required + - name: workingDir type: string default: $(System.DefaultWorkingDirectory) @@ -10,8 +13,6 @@ parameters: - name: buildIos type: boolean default: false - - name: nodeVersion - default: "" - name: currentBranch default: $(Build.SourceBranch) - name: targetBranch diff --git a/common/config/azure-pipelines/templates/integration-test-steps.yaml b/common/config/azure-pipelines/templates/integration-test-steps.yaml index ccafd232a4b9..b5d264344e00 100644 --- a/common/config/azure-pipelines/templates/integration-test-steps.yaml +++ b/common/config/azure-pipelines/templates/integration-test-steps.yaml @@ -1,5 +1,5 @@ parameters: - - name: Node_Version # name of the parameter; required + - name: nodeVersion # name of the parameter; required type: string # data type of the parameter; required steps: @@ -10,9 +10,9 @@ steps: - template: setup-integration-users.yaml - task: NodeTool@0 - displayName: "Use Node ${{ parameters.Node_Version }}" + displayName: "Use Node ${{ parameters.nodeVersion }}" inputs: - versionSpec: "${{ parameters.Node_Version }}" + versionSpec: "${{ parameters.nodeVersion }}" checkLatest: true - script: "git config --local user.email imodeljs-admin@users.noreply.github.com" @@ -66,7 +66,13 @@ steps: - script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' npm run test workingDirectory: "full-stack-tests/rpc" displayName: "Run RPC Full Stack Tests" - condition: succeededOrFailed() + condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Linux')) + + # MacOS and Windows agents work without any virtual display + - script: npm run test + workingDirectory: "full-stack-tests/rpc" + displayName: "Run RPC Full Stack Tests" + condition: and(succeededOrFailed(), ne(variables['Agent.OS'], 'Linux')) - script: npm run test:integration workingDirectory: "full-stack-tests/rpc-interface" @@ -82,18 +88,31 @@ steps: - script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' npm run test:integration:frontend:ci workingDirectory: "core/electron" displayName: "Run Electron Frontend Tests" - condition: succeededOrFailed() + condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Linux')) + + # MacOS and Windows agents work without any virtual display + - script: npm run test:integration:frontend:ci + workingDirectory: "core/electron" + displayName: "Run Electron Frontend Tests" + condition: and(succeededOrFailed(), ne(variables['Agent.OS'], 'Linux')) + # By default linux agents do not have a real display so use the virtual framebuffer - script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' npm run test:integration:backend workingDirectory: "core/electron" displayName: "Run Electron Backend Tests" - condition: succeededOrFailed() + condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Linux')) + + # MacOS and Windows agents work without any virtual display + - script: npm run test:integration:backend + workingDirectory: "core/electron" + displayName: "Run Electron Backend Tests" + condition: and(succeededOrFailed(), ne(variables['Agent.OS'], 'Linux')) - task: PublishTestResults@2 displayName: "Publish Backend Test Results" inputs: testResultsFiles: "full-stack-tests/backend/lib/test/junit_results.xml" - testRunTitle: "Core - Backend Tests - ${{ parameters.Node_Version }}" + testRunTitle: "Core - Backend Tests - ${{ parameters.nodeVersion }}" continueOnError: true condition: succeededOrFailed() @@ -101,40 +120,40 @@ steps: displayName: "Publish Core Integration Test Results" inputs: testResultsFiles: "full-stack-tests/core/lib/test/junit_results.xml" - testRunTitle: "Core - Integration Tests - ${{ parameters.Node_Version }}" + testRunTitle: "Core - Integration Tests - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish ECSchema Rpc Interface Integration Test Results" inputs: testResultsFiles: "full-stack-tests/ecschema-rpc-interface/ecschema-rpcinterface-tests-result/ecschema-rpcinterface-tests-result.xml" - testRunTitle: "ECSchema Rpc Interface - Integration Tests - ${{ parameters.Node_Version }}" + testRunTitle: "ECSchema Rpc Interface - Integration Tests - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish RPC Full Stack Test Results" inputs: testResultsFiles: "full-stack-tests/rpc/lib/test/junit_results.xml" - testRunTitle: "RPC Full Stack - ${{ parameters.Node_Version }}" + testRunTitle: "RPC Full Stack - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Rpc Interface Integration Test Results" inputs: testResultsFiles: "full-stack-tests/rpc-interface/full_stack_test_results/full_stack_test_result.xml" - testRunTitle: "Rpc Interface - Integration Tests - ${{ parameters.Node_Version }}" + testRunTitle: "Rpc Interface - Integration Tests - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Integration Test Results" inputs: testResultsFiles: full-stack-tests/presentation/lib/test/junit_results.xml - testRunTitle: "Presentation - Integration Tests - ${{ parameters.Node_Version }}" + testRunTitle: "Presentation - Integration Tests - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Electron Test Results" inputs: testResultsFiles: core/electron/lib/test/*_junit_results.xml - testRunTitle: "Core - Electron Tests - ${{ parameters.Node_Version }}" + testRunTitle: "Core - Electron Tests - ${{ parameters.nodeVersion }}" condition: succeededOrFailed() diff --git a/common/config/azure-pipelines/templates/publish-test-results.yaml b/common/config/azure-pipelines/templates/publish-test-results.yaml index 2311b9b20e1d..5ffcd0de83d3 100644 --- a/common/config/azure-pipelines/templates/publish-test-results.yaml +++ b/common/config/azure-pipelines/templates/publish-test-results.yaml @@ -1,5 +1,5 @@ parameters: - - name: NodeVersion # name of the parameter; required + - name: nodeVersion # name of the parameter; required type: string # data type of the parameter; required - name: workingDir type: string @@ -13,63 +13,63 @@ steps: displayName: "Publish Backend Test Results" inputs: testResultsFiles: "core/backend/lib/test/junit_results.xml" - testRunTitle: "Core - Backend Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Backend Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Bentley Test Results" inputs: testResultsFiles: "core/bentley/lib/test/junit_results.xml" - testRunTitle: "Core - Bentley Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Bentley Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Common Backend Test Results" inputs: testResultsFiles: "core/common/lib/test/junit_results.xml" - testRunTitle: "Core - Common Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Common Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish ECSchema Locaters Test Results" inputs: testResultsFiles: "core/ecschema-locaters/lib/test/junit_results.xml" - testRunTitle: "Core - ECSchema Locaters Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - ECSchema Locaters Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish ECSchema Metadata Test Results" inputs: testResultsFiles: "core/ecschema-metadata/lib/test/junit_results.xml" - testRunTitle: "Core - ECSchema Metadata Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - ECSchema Metadata Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Frontend Test Results" inputs: testResultsFiles: "core/frontend/lib/test/junit_results.xml" - testRunTitle: "Core - Frontend Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Frontend Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Geometry Test Results" inputs: testResultsFiles: "core/geometry/lib/test/junit_results.xml" - testRunTitle: "Core - Geometry Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Geometry Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish i18n Test Results" inputs: testResultsFiles: "core/i18n/lib/test/junit_results.xml" - testRunTitle: "Core - i18n Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - i18n Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Quantity Test Results" inputs: testResultsFiles: "core/quantity/lib/test/junit_results.xml" - testRunTitle: "Core - Quantity Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core - Quantity Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() #------- @@ -79,35 +79,35 @@ steps: displayName: "Publish Presentation Backend Test Results" inputs: testResultsFiles: "presentation/backend/lib/test/junit_results.xml" - testRunTitle: "Presentation - Backend Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation - Backend Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Common Test Results" inputs: testResultsFiles: "presentation/common/lib/test/junit_results.xml" - testRunTitle: "Presentation - Common Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation - Common Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Components Test Results" inputs: testResultsFiles: "presentation/components/lib/test/junit_results.xml" - testRunTitle: "Presentation - Components Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation - Components Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Frontend Test Results" inputs: testResultsFiles: "presentation/frontend/lib/test/junit_results.xml" - testRunTitle: "Presentation - Frontend Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation - Frontend Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Testing Test Results" inputs: testResultsFiles: "presentation/testing/lib/test/junit_results.xml" - testRunTitle: "Presentation - Testing Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation - Testing Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() @@ -118,35 +118,35 @@ steps: displayName: "Publish UI Abstract Test Results" inputs: testResultsFiles: "ui/abstract/lib/test/junit_results.xml" - testRunTitle: "UI - Abstract Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "UI - Abstract Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish UI Components Test Results" inputs: testResultsFiles: "ui/components/lib/test/junit_results.xml" - testRunTitle: "UI - Components Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "UI - Components Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish UI Core Test Results" inputs: testResultsFiles: "ui/core/lib/test/junit_results.xml" - testRunTitle: "UI - Core Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "UI - Core Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish UI Framework Test Results" inputs: testResultsFiles: "ui/framework/lib/test/junit_results.xml" - testRunTitle: "UI - Framework Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "UI - Framework Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish UI Ninezone Test Results" inputs: testResultsFiles: "ui/ninezone/lib/test/junit_results.xml" - testRunTitle: "UI - Ninezone Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "UI - Ninezone Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() @@ -157,21 +157,21 @@ steps: displayName: "Publish Core Full Stack Test Results" inputs: testResultsFiles: "full-stack-tests/core/lib/test/junit_results.xml" - testRunTitle: "Core Full Stack - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Core Full Stack - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Presentation Full Stack Test Results" inputs: testResultsFiles: "full-stack-tests/presentation/lib/test/junit_results.xml" - testRunTitle: "Presentation Full Stack - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Presentation Full Stack - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish RPC Full Stack Test Results" inputs: testResultsFiles: "full-stack-tests/rpc/lib/test/junit_results.xml" - testRunTitle: "RPC Full Stack - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "RPC Full Stack - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() @@ -182,14 +182,14 @@ steps: displayName: "Publish Example App" inputs: testResultsFiles: "example-code/app/lib/test/junit_results.xml" - testRunTitle: "Example Apps - App Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Example Apps - App Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() - task: PublishTestResults@2 displayName: "Publish Example Snippets" inputs: testResultsFiles: "example-code/snippets/lib/test/junit_results.xml" - testRunTitle: "Example Apps - Snippets Tests - $(Agent.OS) - ${{ parameters.NodeVersion }}" + testRunTitle: "Example Apps - Snippets Tests - $(Agent.OS) - ${{ parameters.nodeVersion }}" searchFolder: ${{ parameters.workingDir }} condition: succeededOrFailed() #------- diff --git a/core/backend/src/workspace/Workspace.ts b/core/backend/src/workspace/Workspace.ts index c0a96ad27b0d..202e5a6c975f 100644 --- a/core/backend/src/workspace/Workspace.ts +++ b/core/backend/src/workspace/Workspace.ts @@ -761,11 +761,11 @@ export class EditableWorkspaceDb extends ITwinWorkspaceDb { // currently the only way to create a workspaceDb in a cloud container is to create a temporary workspaceDb and upload it. const tempDbFile = join(KnownLocations.tmpdir, `empty.${ITwinWorkspaceDb.fileExt}`); if (fs.existsSync(tempDbFile)) - fs.rmSync(tempDbFile); + IModelJsFs.removeSync(tempDbFile); EditableWorkspaceDb.createEmpty(tempDbFile); this.dbFileName = ITwinWorkspaceContainer.makeDbFileName(this.dbName, version); await CloudSqlite.uploadDb(this.container.cloudContainer, { localFileName: tempDbFile, dbName: this.dbFileName }); - fs.rmSync(tempDbFile); + IModelJsFs.removeSync(tempDbFile); } this.open(); } diff --git a/full-stack-tests/backend/src/integration/Checkpoints.test.ts b/full-stack-tests/backend/src/integration/Checkpoints.test.ts index 11ca9db8a8ce..1d7683a0ff04 100644 --- a/full-stack-tests/backend/src/integration/Checkpoints.test.ts +++ b/full-stack-tests/backend/src/integration/Checkpoints.test.ts @@ -57,7 +57,7 @@ describe("Checkpoints", () => { before(async () => { originalEnv = { ...process.env }; process.env.CHECKPOINT_CACHE_DIR = cloudcacheDir; - fs.rmSync(cloudcacheDir, { recursive: true, force: true }); + IModelJsFs.removeSync(cloudcacheDir); // Props for daemon accountProps = { @@ -139,7 +139,7 @@ describe("Checkpoints", () => { changeset: testChangeSet, })).eventually.rejectedWith(/Cannot create CloudCache: invalid cache directory or directory does not exist/); } finally { - fs.rmSync(portfile); + IModelJsFs.removeSync(portfile); } }); diff --git a/full-stack-tests/presentation/src/IntegrationTests.ts b/full-stack-tests/presentation/src/IntegrationTests.ts index 4ffeaf2779cc..fec1880f5117 100644 --- a/full-stack-tests/presentation/src/IntegrationTests.ts +++ b/full-stack-tests/presentation/src/IntegrationTests.ts @@ -10,6 +10,7 @@ import Backend from "i18next-http-backend"; import * as path from "path"; import sinon from "sinon"; import sinonChai from "sinon-chai"; +import { IModelJsFs } from "@itwin/core-backend"; import { Logger, LogLevel } from "@itwin/core-bentley"; import { EmptyLocalization, Localization } from "@itwin/core-common"; import { IModelApp, IModelAppOptions, NoRenderApp } from "@itwin/core-frontend"; @@ -89,7 +90,7 @@ const initializeCommon = async (props: { backendTimeout?: number, useClientServi // prepare an empty, process-unique output directory const outputRoot = getOutputRoot(); - fs.existsSync(outputRoot) && fs.rmSync(outputRoot, { recursive: true, force: true }); + fs.existsSync(outputRoot) && IModelJsFs.removeSync(outputRoot); fs.mkdirSync(outputRoot, { recursive: true }); const tempCachesDir = path.join(outputRoot, "caches"); diff --git a/full-stack-tests/presentation/src/Utils.ts b/full-stack-tests/presentation/src/Utils.ts index d5885cb0f799..e37ff062500a 100644 --- a/full-stack-tests/presentation/src/Utils.ts +++ b/full-stack-tests/presentation/src/Utils.ts @@ -3,9 +3,9 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import * as fs from "fs"; import * as path from "path"; import { Field } from "@itwin/presentation-common"; +import { IModelJsFs } from "@itwin/core-backend"; /** * Simplified type for `sinon.SinonSpy`. @@ -72,6 +72,6 @@ export function getOutputRoot() { /** Given a file name, returns a path that is safe to use for read-write scenarios when running the tests */ export function prepareOutputFilePath(fileName: string): string { const filePath = path.join(getOutputRoot(), fileName); - fs.rmSync(filePath, { force: true }); + IModelJsFs.removeSync(filePath); return filePath; } diff --git a/ui/components-react/src/test/common/DateUtils.test.ts b/ui/components-react/src/test/common/DateUtils.test.ts index e9dabdf4d737..60bccb7548d4 100644 --- a/ui/components-react/src/test/common/DateUtils.test.ts +++ b/ui/components-react/src/test/common/DateUtils.test.ts @@ -25,9 +25,9 @@ describe("DateUtils", () => { }); it("toTimeString", () => { expect(toTimeString(new Date("June 30, 2016, 00:00:00 GMT -0000"), 0, - { locales: "en-US", options: { hour: "2-digit", minute: "numeric", second: "numeric", hour12: true } })).to.equal("12:00:00 AM"); + { locales: "en-US", options: { hour: "2-digit", minute: "numeric", second: "numeric", hour12: true } }).replace("\u202f", " ")).to.equal("12:00:00 AM"); expect(toTimeString(new Date("June 30, 2016, 00:00:00 GMT -0000"), undefined, - { locales: "en-US", options: { hour: "2-digit", minute: "numeric", second: "numeric", hour12: true } }) + { locales: "en-US", options: { hour: "2-digit", minute: "numeric", second: "numeric", hour12: true } }).replace("\u202f", " ") ).to.match(/\d{2}:\d{2}:\d{2} (AM|PM)/).not.to.be.null; }); diff --git a/ui/components-react/src/test/editors/DateTimeEditor.test.tsx b/ui/components-react/src/test/editors/DateTimeEditor.test.tsx index 6e93b13f07f9..bc202ae2e4cf 100644 --- a/ui/components-react/src/test/editors/DateTimeEditor.test.tsx +++ b/ui/components-react/src/test/editors/DateTimeEditor.test.tsx @@ -125,7 +125,7 @@ describe("", () => { const spyOnCommit = sinon.spy(); const record = createDateProperty("Test", date, 0); // 0 creates a long DateTime record const renderedComponent = render(); - expect(await waitFor(() => renderedComponent.getByText(date.toLocaleString()))).to.exist; + expect(await waitFor(() => renderedComponent.getByText(date.toLocaleString().replace("\u202f", " ")))).to.exist; const originalValue = (record.value as PrimitiveValue).value as Date; expect(originalValue.getTime()).to.be.equal(date.getTime()); expect(renderedComponent).not.to.be.undefined; @@ -254,7 +254,7 @@ describe("", () => { it("should receive focus", async () => { const record = createDateProperty("Test", date, 0); // 0 creates a long DateTime record const renderedComponent = render(); - expect(await waitFor(() => renderedComponent.getByText(date.toLocaleString()))).to.exist; + expect(await waitFor(() => renderedComponent.getByText(date.toLocaleString().replace("\u202f", " ")))).to.exist; const popupButton = await renderedComponent.findByTestId("components-popup-button"); expect(popupButton).not.to.be.null; popupButton.focus(); diff --git a/ui/imodel-components-react/src/test/timeline/TimelineComponent.test.tsx b/ui/imodel-components-react/src/test/timeline/TimelineComponent.test.tsx index 9e866c282791..422cad8e5be2 100644 --- a/ui/imodel-components-react/src/test/timeline/TimelineComponent.test.tsx +++ b/ui/imodel-components-react/src/test/timeline/TimelineComponent.test.tsx @@ -886,7 +886,7 @@ describe("", () => { const startTimeLabel = renderedComponent.getByTestId("test-start-time"); expect(startTimeLabel).not.to.be.null; - expect(startTimeLabel.innerHTML).to.equal("07:00:00 PM"); + expect(startTimeLabel.innerHTML.replace("\u202f", " ")).to.equal("07:00:00 PM"); }); it("should mark today's date on the timeline", () => { diff --git a/ui/scripts/setup-tests-noreact.js b/ui/scripts/setup-tests-noreact.js index 3d106fd3f775..08fb35b1441a 100644 --- a/ui/scripts/setup-tests-noreact.js +++ b/ui/scripts/setup-tests-noreact.js @@ -22,10 +22,10 @@ global.WheelEvent = global.MouseEvent; // See https://github.com/jsdom/jsdom/pull/2926 global.DOMRect = class DOMRect { constructor(x, y, width, height) { - this.x = x ?? 0; - this.y = y ?? 0; - this.width = width ?? 0; - this.height = height ?? 0; + this.x = x || 0; + this.y = y || 0; + this.width = width || 0; + this.height = height || 0; this.top = this.y; this.left = this.x; this.right = this.x + this.width; diff --git a/ui/scripts/setup-tests.js b/ui/scripts/setup-tests.js index 1853505441e8..be6a3d1660d9 100644 --- a/ui/scripts/setup-tests.js +++ b/ui/scripts/setup-tests.js @@ -30,10 +30,10 @@ global.WheelEvent = global.MouseEvent; // See https://github.com/jsdom/jsdom/pull/2926 global.DOMRect = class DOMRect { constructor(x, y, width, height) { - this.x = x ?? 0; - this.y = y ?? 0; - this.width = width ?? 0; - this.height = height ?? 0; + this.x = x || 0; + this.y = y || 0; + this.width = width || 0; + this.height = height || 0; this.top = this.y; this.left = this.x; this.right = this.x + this.width;