From 45c96b7542a2976a87cab6d4e6fb759c8b4af827 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 9 Dec 2024 20:08:46 -0500 Subject: [PATCH 1/3] Update versions of node and workflow items in GitHub Actions --- .github/workflows/build-pr.yml | 20 ++++++++++---------- .github/workflows/build-push.yml | 21 ++++++++++----------- .github/workflows/report.yml | 6 +++--- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 43fa363d..76541e10 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -8,10 +8,10 @@ jobs: name: Build & Test on Ubuntu runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '14' + node-version: '20' - name: Install GCC & GDB & other build essentials run: | sudo apt-get update @@ -29,13 +29,13 @@ jobs: - name: Test run: yarn test-ci - name: Log file artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-logs-ubuntu path: test-logs/ - name: Upload Test Report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-results-ubuntu @@ -49,10 +49,10 @@ jobs: name: Build & Test on Windows runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '14' + node-version: '20' - name: Install GCC & GDB & other build essentials run: | choco install mingw @@ -70,13 +70,13 @@ jobs: - name: Test run: yarn test-ci - name: Log file artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-logs-windows path: test-logs/ - name: Upload Test Report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-results-windows diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 8ab32f1f..869de7d1 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -9,10 +9,10 @@ jobs: name: Build & Test on Ubuntu runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '14' + node-version: '20' - name: Install GCC & GDB & other build essentials run: | sudo apt-get update @@ -30,13 +30,13 @@ jobs: - name: Test run: yarn test-ci - name: Log file artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-logs-ubuntu path: test-logs/ - name: Publish Test Report - uses: mikepenz/action-junit-report@v3 + uses: mikepenz/action-junit-report@v5 if: success() || failure() with: commit: ${{github.event.workflow_run.head_sha}} @@ -50,10 +50,10 @@ jobs: name: Build & Test on Windows runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '14' + node-version: '20' - name: Install GCC & GDB & other build essentials run: | choco install mingw @@ -71,14 +71,13 @@ jobs: - name: Test run: yarn test-ci - name: Log file artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-logs-windows path: test-logs/ - name: Publish Test Report - uses: mikepenz/action-junit-report@v3 - if: success() || failure() + uses: mikepenz/action-junit-report@v5 with: commit: ${{github.event.workflow_run.head_sha}} report_paths: 'test-reports/*.xml' diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml index a96be500..9b037f0f 100644 --- a/.github/workflows/report.yml +++ b/.github/workflows/report.yml @@ -16,21 +16,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Download Test Report - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v7 with: name: test-results-ubuntu path: ubuntu workflow: ${{ github.event.workflow.id }} run_id: ${{ github.event.workflow_run.id }} - name: Download Test Report - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v7 with: name: test-results-windows path: windows workflow: ${{ github.event.workflow.id }} run_id: ${{ github.event.workflow_run.id }} - name: Publish Test Report - uses: mikepenz/action-junit-report@v3 + uses: mikepenz/action-junit-report@v5 with: commit: ${{github.event.workflow_run.head_sha}} report_paths: '**/*.xml' From 8c1d36268565c596e55c309be8baed0e74134a20 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 9 Dec 2024 20:51:25 -0500 Subject: [PATCH 2/3] Remove unnecessary check in test The UART fails to open test was looking for a `0` in the error message, corresponding to the port number that was being opened. However, depending on the specific machine run on, the actual error from the backend may vary. On GitHub actions instead of referring to the port number it says: "error on socket connection\n - AggregateError" And on my local machine it shows "error on socket connection\n - Error: connect ECONNREFUSED 127.0.0.1" With this change we still require the adapter to report an error on socket connection, but the specific error details are not required to match any particular pattern. --- src/integration-tests/launchRemote.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/integration-tests/launchRemote.spec.ts b/src/integration-tests/launchRemote.spec.ts index 267ba56f..75def234 100644 --- a/src/integration-tests/launchRemote.spec.ts +++ b/src/integration-tests/launchRemote.spec.ts @@ -140,7 +140,7 @@ describe('launch remote', function () { }); it('can show user error on debug console if UART fails to open - Socket', async function () { - const output = await dc.getDebugConsoleOutput( + await dc.getDebugConsoleOutput( fillDefaults(this.test, { program: emptyProgram, openGdbConsole: false, @@ -155,6 +155,5 @@ describe('launch remote', function () { 'error on socket connection', true ); - expect(output.body.output).contains('0'); }); }); From 9272451145d56bfd3c60b9cd67a6746b2c023adb Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 9 Dec 2024 21:21:42 -0500 Subject: [PATCH 3/3] Ensure the terminating newline is received from gdbserver before parsing port We were parsing the port number from gdbserver before it had been fully output. Use a regex now to wait for terminating newline so we know gdbserver has output full port. --- src/integration-tests/attachRemote.spec.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/integration-tests/attachRemote.spec.ts b/src/integration-tests/attachRemote.spec.ts index aaf715b4..190435b9 100644 --- a/src/integration-tests/attachRemote.spec.ts +++ b/src/integration-tests/attachRemote.spec.ts @@ -26,7 +26,7 @@ import { expect } from 'chai'; describe('attach remote', function () { let dc: CdtDebugClient; let gdbserver: cp.ChildProcess; - let port: number; + let port: string; const emptyProgram = path.join(testProgramsDir, 'empty'); const emptySrc = path.join(testProgramsDir, 'empty.c'); @@ -39,19 +39,18 @@ describe('attach remote', function () { cwd: testProgramsDir, } ); - port = await new Promise((resolve, reject) => { + port = await new Promise((resolve, reject) => { + const regex = new RegExp(/Listening on port ([0-9]+)\r?\n/); let accumulatedStderr = ''; if (gdbserver.stderr) { gdbserver.stderr.on('data', (data) => { - const line = String(data); - accumulatedStderr += line; - const LISTENING_ON_PORT = 'Listening on port '; - const index = accumulatedStderr.indexOf(LISTENING_ON_PORT); - if (index >= 0) { - const portStr = accumulatedStderr - .substr(index + LISTENING_ON_PORT.length, 6) - .trim(); - resolve(parseInt(portStr, 10)); + if (!port) { + const line = String(data); + accumulatedStderr += line; + const m = regex.exec(accumulatedStderr); + if (m !== null) { + resolve(m[1]); + } } }); } else {