From 6dae811dae20c7af85fa09cafd59c5ae774a58ed Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 14:47:35 -0700 Subject: [PATCH 1/7] Migrate to GitHub Actions Fixes #3297 --- .github/workflows/ci.yml | 133 +++++++++++++++++++ .github/workflows/codeql-analysis.yml | 72 ---------- .github/workflows/codeql.yml | 35 +++++ .github/workflows/release.yml | 30 +++++ azure-pipelines.yml | 182 -------------------------- bin/publish.js | 23 ++-- package.json | 3 +- 7 files changed, 210 insertions(+), 268 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/release.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..491f6a79 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,133 @@ +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: 'yarn' + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Build + run: yarn setup + - name: Zip artifacts + run: | + zip -r compressed-build \ + ./out/* \ + ./out-test/* \ + ./addons/xterm-addon-attach/out/* \ + ./addons/xterm-addon-attach/out-test/* \ + ./addons/xterm-addon-canvas/out/* \ + ./addons/xterm-addon-canvas/out-test/* \ + ./addons/xterm-addon-fit/out/* \ + ./addons/xterm-addon-fit/out-test/* \ + ./addons/xterm-addon-image/inwasm-builds/out/* \ + ./addons/xterm-addon-image/out/* \ + ./addons/xterm-addon-image/out-test/* \ + ./addons/xterm-addon-ligatures/out/* \ + ./addons/xterm-addon-ligatures/out-test/* \ + ./addons/xterm-addon-search/out/* \ + ./addons/xterm-addon-search/out-test/* \ + ./addons/xterm-addon-serialize/out/* \ + ./addons/xterm-addon-serialize/out-test/* \ + ./addons/xterm-addon-unicode11/out/* \ + ./addons/xterm-addon-unicode11/out-test/* \ + ./addons/xterm-addon-web-links/out/* \ + ./addons/xterm-addon-web-links/out-test/* \ + ./addons/xterm-addon-webgl/out/* \ + ./addons/xterm-addon-webgl/out-test/* + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: compressed-build.zip + if-no-files-found: error + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: 'yarn' + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Lint code + run: yarn lint + - name: Lint API + run: yarn lint-api + + unit-tests: + needs: build + strategy: + matrix: + node-version: [16.x, 18.x] + runs-on: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: build-artifacts + - name: Unzip artifacts (Linux, macOS) + if: runner.os != 'Windows' + run: unzip -o compressed-build.zip + - name: Unzip artifacts (Windows) + if: runner.os == 'Windows' + run: 7z x compressed-build.zip -aoa -o${{ github.workspace }} + - name: Print directory structure + run: ls -R + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Unit tests + run: yarn test-unit --forbid-only + + integration-tests: + needs: build + strategy: + matrix: + node-version: [18.x] + runs-on: [ubuntu-latest, windows-latest] # macos-latest is flaky + browser: [chromium, firefox] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: build-artifacts + - name: Unzip artifacts (Linux, macOS) + if: runner.os != 'Windows' + run: unzip -o compressed-build.zip + - name: Unzip artifacts (Windows) + if: runner.os == 'Windows' + run: 7z x compressed-build.zip -aoa -o${{ github.workspace }} + - name: Print directory structure + run: ls -R + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Install playwright + run: npx playwright install + - name: Integration tests (${{ matrix.browser }}) + run: yarn test-api-${{ matrix.browser }} --headless --forbid-only diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index f8c8362a..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '41 17 * * 0' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..3ba91f7e --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,35 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '41 17 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1e26e438 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: Release + +on: + push: + # If a commit reaches master, assume it has passed CI via PR and publish + # without running tests to save time to publish + branches: [ "master" ] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: 'yarn' + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Build + run: yarn setup + - name: Package headless + run: | + yarn package-headless + node ./bin/package_headless.js + - name: Publish to npm + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: node ./bin/publish.js diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index f96a0e8a..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,182 +0,0 @@ -pr: - branches: - include: ["main"] - -trigger: - branches: - include: ["main"] - -jobs: -- job: Linux - pool: - vmImage: 'ubuntu-20.04' - steps: - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - task: YarnInstaller@3 - inputs: - versionSpec: '1.x' - displayName: 'Install Yarn' - - task: CacheBeta@1 - inputs: - key: yarn2 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache node modules - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: | - yarn test-unit-coverage --forbid-only - EXIT_CODE=$? - ./node_modules/.bin/nyc report --reporter=cobertura - exit $EXIT_CODE - displayName: 'Unit tests' - - script: yarn lint - displayName: 'Lint code' - - script: yarn lint-api - displayName: 'Lint API' - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml' - displayName: 'Publish coverage' - -- job: macOS - pool: - vmImage: 'macOS-11' - steps: - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - task: CacheBeta@1 - inputs: - key: yarn2 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache node modules - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: yarn test-unit --forbid-only - displayName: 'Unit tests' - - script: yarn lint - displayName: 'Lint code' - - script: yarn lint-api - displayName: 'Lint API' - -- job: Windows - pool: - vmImage: 'windows-2019' - steps: - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - task: CacheBeta@1 - inputs: - key: yarn2 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache node modules - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: yarn test-unit --forbid-only - displayName: 'Unit tests' - - script: yarn lint - displayName: 'Lint code' - - script: yarn lint-api - displayName: 'Lint API' - -- job: Linux_IntegrationTests - pool: - vmImage: 'ubuntu-20.04' - steps: - - script: | - # source: https://github.com/microsoft/playwright/issues/1041 - sudo apt update - sudo apt install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libnotify4 libxslt1.1 libevent-2.1-6 libgles2 libgl1 libegl1 libvpx5 - # for chromium - sudo apt install libnss3 libxss1 libasound2 - # for firefox - sudo apt install libdbus-glib-1-2 libxt6 - displayName: Install required packages - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - task: YarnInstaller@3 - inputs: - versionSpec: '1.x' - displayName: 'Install Yarn' - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: yarn test-api-chromium --headless --forbid-only - displayName: 'Integration tests (Chromium)' - - script: xvfb-run --auto-servernum -- bash -c "yarn test-api-firefox --headless --forbid-only" - displayName: 'Integration tests (Firefox)' - -# Integration tests are too flaky on macOS https://github.com/xtermjs/xterm.js/issues/3590 -# - job: macOS_IntegrationTests -# pool: -# vmImage: 'macOS-11' -# steps: -# - task: NodeTool@0 -# inputs: -# versionSpec: '18.x' -# displayName: 'Install Node.js' -# - script: yarn --frozen-lockfile -# displayName: 'Install dependencies and build' -# - script: yarn test-api-chromium --headless --forbid-only -# displayName: 'Integration tests (Chromium)' -# - script: yarn test-api-firefox --headless --forbid-only -# displayName: 'Integration tests (Firefox)' -# - script: yarn test-api-webkit --headless --forbid-only -# displayName: 'Integration tests (Webkit)' - -- job: Windows_IntegrationTests - pool: - vmImage: 'windows-2019' - steps: - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: yarn test-api-chromium --headless --forbid-only - displayName: 'Integration tests (Chromium)' - - script: yarn test-api-firefox --headless --forbid-only - displayName: 'Integration tests (Firefox)' - -- job: Release - dependsOn: - - Linux - - macOS - - Windows - - Linux_IntegrationTests - # - macOS_IntegrationTests - - Windows_IntegrationTests - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) - pool: - vmImage: 'ubuntu-20.04' - steps: - - task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - - task: YarnInstaller@3 - inputs: - versionSpec: '1.x' - displayName: 'Install Yarn' - - task: CacheBeta@1 - inputs: - key: yarn2 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache node modules - - script: yarn --frozen-lockfile - displayName: 'Install dependencies and build' - - script: | - yarn package-headless - node ./bin/package_headless.js - displayName: 'Package xterm-headless' - - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js - displayName: 'Package and publish to npm' diff --git a/bin/publish.js b/bin/publish.js index e65048db..ec089e7b 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -67,25 +67,24 @@ function checkAndPublishPackage(packageDir) { const packageJsonFile = path.join(packageDir, 'package.json'); packageJson.version = nextVersion; console.log(`Set version of ${packageJsonFile} to ${nextVersion}`); - if (!isDryRun) { - fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2)); - } + fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2)); // Publish const args = ['publish']; if (!isStableRelease) { args.push('--tag', 'beta'); } + if (isDryRun) { + args.push('--dry-run'); + } console.log(`Spawn: npm ${args.join(' ')}`); - if (!isDryRun) { - const result = cp.spawnSync('npm', args, { - cwd: packageDir, - stdio: 'inherit' - }); - if (result.status) { - console.error(`Spawn exited with code ${result.status}`); - process.exit(result.status); - } + const result = cp.spawnSync('npm', args, { + cwd: packageDir, + stdio: 'inherit' + }); + if (result.status) { + console.error(`Spawn exited with code ${result.status}`); + process.exit(result.status); } console.groupEnd(); diff --git a/package.json b/package.json index 5fc4e558..4fb383fd 100644 --- a/package.json +++ b/package.json @@ -41,9 +41,8 @@ "test-unit-coverage": "node ./bin/test.js --coverage", "test-unit-dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", - "prepare": "npm run setup", "setup": "npm run build", - "presetup": "node ./bin/install-addons.js", + "postinstall": "node ./bin/install-addons.js", "postsetup": "npm run inwasm", "prepublishOnly": "npm run package", "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput", From 60db1e7f82695b6a76f429c43e710fe4726bdf9d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 14:57:25 -0700 Subject: [PATCH 2/7] Remove Azure Pipelines badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2eeba51b..0abcd32c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # [![xterm.js logo](logo-full.png)](https://xtermjs.org) -[![Build Status](https://dev.azure.com/xtermjs/xterm.js/_apis/build/status/xtermjs.xterm.js)](https://dev.azure.com/xtermjs/xterm.js/_build/latest?definitionId=3) - Xterm.js is a front-end component written in TypeScript that lets applications bring fully-featured terminals to their users in the browser. It's used by popular projects such as VS Code, Hyper and Theia. ## Features From a9015c0ee6296bc9aa46e2046934e6a52c5a0d72 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:05:32 -0700 Subject: [PATCH 3/7] Revert codeql file name change --- .github/workflows/{codeql.yml => codeql-analysis.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{codeql.yml => codeql-analysis.yml} (100%) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql-analysis.yml similarity index 100% rename from .github/workflows/codeql.yml rename to .github/workflows/codeql-analysis.yml From 67f46a54b8bf35053c0ad2082b2b07d556cfa687 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:17:11 -0700 Subject: [PATCH 4/7] Split up StringToUtf32 decoder tests Part of #4696 --- src/common/input/TextDecoder.test.ts | 81 +++++++++++++++------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/common/input/TextDecoder.test.ts b/src/common/input/TextDecoder.test.ts index b8db8a03..20fd3508 100644 --- a/src/common/input/TextDecoder.test.ts +++ b/src/common/input/TextDecoder.test.ts @@ -29,6 +29,8 @@ function fromByteString(s: string): Uint8Array { return result; } +const BATCH_SIZE = 2048; + const TEST_STRINGS = [ 'Лорем ипсум долор сит амет, ех сеа аццусам диссентиет. Ан еос стет еирмод витуперата. Иус дицерет урбанитас ет. Ан при алтера долорес сплендиде, цу яуо интегре денияуе, игнота волуптариа инструцтиор цу вим.', 'ლორემ იფსუმ დოლორ სით ამეთ, ფაცერ მუციუს ცონსეთეთურ ყუო იდ, ფერ ვივენდუმ ყუაერენდუმ ეა, ესთ ამეთ მოვეთ სუავითათე ცუ. ვითაე სენსიბუს ან ვიხ. ეხერცი დეთერრუისსეთ უთ ყუი. ვოცენთ დებითის ადიფისცი ეთ ფერ. ნეც ან ფეუგაით ფორენსიბუს ინთერესსეთ. იდ დიცო რიდენს იუს. დისსენთიეთ ცონსეყუუნთურ სედ ნე, ნოვუმ მუნერე ეუმ ათ, ნე ეუმ ნიჰილ ირაცუნდია ურბანითას.', @@ -52,38 +54,42 @@ describe('text encodings', () => { assert.equal(utf32ToString(data), s); }); - describe('StringToUtf32 decoder', () => { + describe.only('StringToUtf32 decoder', () => { describe('full codepoint test', () => { - it('0..65535', () => { - const decoder = new StringToUtf32(); - const target = new Uint32Array(5); - for (let i = 0; i < 65536; ++i) { - // skip surrogate pairs and a BOM - if ((i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF) { - continue; + for (let min = 0; min < 65535; min += BATCH_SIZE) { + const max = Math.min(min + BATCH_SIZE, 65536); + it(`${formatRange(min, max)}`, () => { + const decoder = new StringToUtf32(); + const target = new Uint32Array(5); + for (let i = min; i < max; ++i) { + // skip surrogate pairs and a BOM + if ((i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF) { + continue; + } + const length = decoder.decode(String.fromCharCode(i), target); + assert.equal(length, 1); + assert.equal(target[0], i); + assert.equal(utf32ToString(target, 0, length), String.fromCharCode(i)); + decoder.clear(); } - const length = decoder.decode(String.fromCharCode(i), target); - assert.equal(length, 1); - assert.equal(target[0], i); - assert.equal(utf32ToString(target, 0, length), String.fromCharCode(i)); - decoder.clear(); - } - }); - - it('65536..0x10FFFF (surrogates)', function (): void { - this.timeout(20000); - const decoder = new StringToUtf32(); - const target = new Uint32Array(5); - for (let i = 65536; i < 0x10FFFF; ++i) { - const codePoint = i - 0x10000; - const s = String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00); - const length = decoder.decode(s, target); - assert.equal(length, 1); - assert.equal(target[0], i); - assert.equal(utf32ToString(target, 0, length), s); - decoder.clear(); - } - }); + }); + } + for (let min = 65536; min < 0x10FFFF; min += BATCH_SIZE) { + const max = Math.min(min + BATCH_SIZE, 0x10FFFF); + it(`${formatRange(min, max)} (surrogates)`, () => { + const decoder = new StringToUtf32(); + const target = new Uint32Array(5); + for (let i = min; i < max; ++i) { + const codePoint = i - 0x10000; + const s = String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00); + const length = decoder.decode(s, target); + assert.equal(length, 1); + assert.equal(target[0], i); + assert.equal(utf32ToString(target, 0, length), s); + decoder.clear(); + } + }); + } it('0xFEFF(BOM)', () => { const decoder = new StringToUtf32(); @@ -121,11 +127,8 @@ describe('text encodings', () => { describe('Utf8ToUtf32 decoder', () => { describe('full codepoint test', () => { - function formatRange(min: number, max: number): string { - return `${min}..${max} (0x${min.toString(16).toUpperCase()}..0x${max.toString(16).toUpperCase()})`; - } - for (let min = 0; min < 65535; min += 10000) { - const max = Math.min(min + 10000, 65536); + for (let min = 0; min < 65535; min += BATCH_SIZE) { + const max = Math.min(min + BATCH_SIZE, 65536); it(`${formatRange(min, max)} (1/2/3 byte sequences)`, () => { const decoder = new Utf8ToUtf32(); const target = new Uint32Array(5); @@ -142,9 +145,9 @@ describe('text encodings', () => { } }); } - for (let minRaw = 60000; minRaw < 0x10FFFF; minRaw += 10000) { + for (let minRaw = 60000; minRaw < 0x10FFFF; minRaw += BATCH_SIZE) { const min = Math.max(minRaw, 65536); - const max = Math.min(minRaw + 10000, 0x10FFFF); + const max = Math.min(minRaw + BATCH_SIZE, 0x10FFFF); it(`${formatRange(min, max)} (4 byte sequences)`, function (): void { const decoder = new Utf8ToUtf32(); const target = new Uint32Array(5); @@ -265,3 +268,7 @@ describe('text encodings', () => { }); }); }); + +function formatRange(min: number, max: number): string { + return `${min}..${max} (0x${min.toString(16).toUpperCase()}..0x${max.toString(16).toUpperCase()})`; +} From 905707284dc72cf9d975657ea81894579a5a8824 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:18:44 -0700 Subject: [PATCH 5/7] Up parser unti test timeout 10s -> 30s --- src/common/parser/DcsParser.test.ts | 4 ++-- src/common/parser/OscParser.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/parser/DcsParser.test.ts b/src/common/parser/DcsParser.test.ts index 096ebb58..c6cc0994 100644 --- a/src/common/parser/DcsParser.test.ts +++ b/src/common/parser/DcsParser.test.ts @@ -227,7 +227,7 @@ describe('DcsParser', () => { assert.deepEqual(reports, [['two', [1, 2, 3], 'Here comes the mouse!'], ['one', [1, 2, 3], 'Here comes the mouse!']]); }); it('should work up to payload limit', function(): void { - this.timeout(10000); + this.timeout(30000); parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); const data = toUtf32('A'.repeat(1000)); @@ -238,7 +238,7 @@ describe('DcsParser', () => { assert.deepEqual(reports, [[[1, 2, 3], 'A'.repeat(PAYLOAD_LIMIT)]]); }); it('should abort for payload limit +1', function(): void { - this.timeout(10000); + this.timeout(30000); parser.registerHandler(identifier({intermediates: '+', final: 'p'}), new DcsHandler((data, params) => { reports.push([params.toArray(), data]); return true; })); parser.hook(identifier({intermediates: '+', final: 'p'}), Params.fromArray([1, 2, 3])); let data = toUtf32('A'.repeat(1000)); diff --git a/src/common/parser/OscParser.test.ts b/src/common/parser/OscParser.test.ts index 5c7f5777..b88171c8 100644 --- a/src/common/parser/OscParser.test.ts +++ b/src/common/parser/OscParser.test.ts @@ -221,7 +221,7 @@ describe('OscParser', () => { assert.deepEqual(reports, [['two', 'Here comes the mouse!'], ['one', 'Here comes the mouse!']]); }); it('should work up to payload limit', function(): void { - this.timeout(10000); + this.timeout(30000); parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;'); @@ -234,7 +234,7 @@ describe('OscParser', () => { assert.deepEqual(reports, [[1234, 'A'.repeat(PAYLOAD_LIMIT)]]); }); it('should abort for payload limit +1', function(): void { - this.timeout(10000); + this.timeout(30000); parser.registerHandler(1234, new OscHandler(data => { reports.push([1234, data]); return true; })); parser.start(); let data = toUtf32('1234;'); From 1c5596de66de859c45a23cd213a49a56c1650966 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:21:42 -0700 Subject: [PATCH 6/7] Split up Base64Decoder decoding tests Fixes #4696 --- addons/xterm-addon-image/src/base64.test.ts | 33 ++++++++++----------- src/common/input/TextDecoder.test.ts | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-image/src/base64.test.ts b/addons/xterm-addon-image/src/base64.test.ts index 6b82893a..2d4e6d76 100644 --- a/addons/xterm-addon-image/src/base64.test.ts +++ b/addons/xterm-addon-image/src/base64.test.ts @@ -45,10 +45,9 @@ describe('Base64Decoder', () => { assert.deepEqual(dec.data8, inp); } }); - it('1+2 bytes', function() { - this.timeout(20000); - const dec = new Base64Decoder(0); - for (let a = 0; a < 256; ++a) { + for (let a = 0; a < 256; ++a) { + it(`1+2 bytes (${a})`, function() { + const dec = new Base64Decoder(0); for (let b = 0; b < 256; ++b) { dec.init(2); const inp = new Uint8Array([a, b]); @@ -57,12 +56,11 @@ describe('Base64Decoder', () => { assert.strictEqual(dec.end(), 0); assert.deepEqual(dec.data8, inp); } - } - }); - it('2+3 bytes', function() { - this.timeout(20000); - const dec = new Base64Decoder(0); - for (let a = 0; a < 256; ++a) { + }); + } + for (let a = 0; a < 256; ++a) { + it(`2+3 bytes (${a})`, function() { + const dec = new Base64Decoder(0); for (let b = 0; b < 256; ++b) { dec.init(3); const inp = new Uint8Array([0, a, b]); @@ -71,12 +69,11 @@ describe('Base64Decoder', () => { assert.strictEqual(dec.end(), 0); assert.deepEqual(dec.data8, inp); } - } - }); - it('3+4 bytes', function() { - this.timeout(20000); - const dec = new Base64Decoder(0); - for (let a = 0; a < 256; ++a) { + }); + } + for (let a = 0; a < 256; ++a) { + it(`3+4 bytes (${a})`, function() { + const dec = new Base64Decoder(0); for (let b = 0; b < 256; ++b) { dec.init(4); const inp = new Uint8Array([0, 0, a, b]); @@ -85,8 +82,8 @@ describe('Base64Decoder', () => { assert.strictEqual(dec.end(), 0); assert.deepEqual(dec.data8, inp); } - } - }); + }); + } it('padding', () => { const dec = new Base64Decoder(0); const d = fromBs('Hello, here comes the mouse'); diff --git a/src/common/input/TextDecoder.test.ts b/src/common/input/TextDecoder.test.ts index 20fd3508..abf9e47f 100644 --- a/src/common/input/TextDecoder.test.ts +++ b/src/common/input/TextDecoder.test.ts @@ -54,7 +54,7 @@ describe('text encodings', () => { assert.equal(utf32ToString(data), s); }); - describe.only('StringToUtf32 decoder', () => { + describe('StringToUtf32 decoder', () => { describe('full codepoint test', () => { for (let min = 0; min < 65535; min += BATCH_SIZE) { const max = Math.min(min + BATCH_SIZE, 65536); From db4567599b3468f9331c2b75cc3c60156ca72f2b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:28:44 -0700 Subject: [PATCH 7/7] Make GH actions strategy more concise --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 491f6a79..eaf22d67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,9 +73,9 @@ jobs: needs: build strategy: matrix: - node-version: [16.x, 18.x] - runs-on: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.runs-on }} + node-version: [16, 18] + runs-on: [ubuntu, macos, windows] + runs-on: ${{ matrix.runs-on }}-latest steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 @@ -89,10 +89,10 @@ jobs: run: 7z x compressed-build.zip -aoa -o${{ github.workspace }} - name: Print directory structure run: ls -R - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js ${{ matrix.node-version }}.x uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ matrix.node-version }}.x cache: 'yarn' - name: Install dependencies run: yarn --frozen-lockfile @@ -103,10 +103,10 @@ jobs: needs: build strategy: matrix: - node-version: [18.x] - runs-on: [ubuntu-latest, windows-latest] # macos-latest is flaky + node-version: [18] + runs-on: [ubuntu, windows] # macos is flaky browser: [chromium, firefox] - runs-on: ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }}-latest steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 @@ -120,10 +120,10 @@ jobs: run: 7z x compressed-build.zip -aoa -o${{ github.workspace }} - name: Print directory structure run: ls -R - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js ${{ matrix.node-version }}.x uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ matrix.node-version }}.x cache: 'yarn' - name: Install dependencies run: yarn --frozen-lockfile