From df034983af99675820044cca76239c2ebcd2abe6 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 08:09:23 +0000 Subject: [PATCH 01/49] chore: add a workspace for e2e testing --- .../cpp/e2e/workspace/.devcontainer.json | 3 ++ .../cpp/e2e/workspace/CMakeLists.txt | 5 +++ .../cpp/e2e/workspace/CMakePresets.json | 42 +++++++++++++++++++ .devcontainer/cpp/e2e/workspace/main.cpp | 7 ++++ 4 files changed, 57 insertions(+) create mode 100644 .devcontainer/cpp/e2e/workspace/.devcontainer.json create mode 100644 .devcontainer/cpp/e2e/workspace/CMakeLists.txt create mode 100644 .devcontainer/cpp/e2e/workspace/CMakePresets.json create mode 100644 .devcontainer/cpp/e2e/workspace/main.cpp diff --git a/.devcontainer/cpp/e2e/workspace/.devcontainer.json b/.devcontainer/cpp/e2e/workspace/.devcontainer.json new file mode 100644 index 00000000..588ac5cd --- /dev/null +++ b/.devcontainer/cpp/e2e/workspace/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}" +} diff --git a/.devcontainer/cpp/e2e/workspace/CMakeLists.txt b/.devcontainer/cpp/e2e/workspace/CMakeLists.txt new file mode 100644 index 00000000..b67fe424 --- /dev/null +++ b/.devcontainer/cpp/e2e/workspace/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.24) + +project(e2e-test VERSION 1.0.0) + +add_executable(e2e-test main.cpp) diff --git a/.devcontainer/cpp/e2e/workspace/CMakePresets.json b/.devcontainer/cpp/e2e/workspace/CMakePresets.json new file mode 100644 index 00000000..a4f1e919 --- /dev/null +++ b/.devcontainer/cpp/e2e/workspace/CMakePresets.json @@ -0,0 +1,42 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "defaults", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja Multi-Config", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel" + } + }, + { + "name": "host", + "displayName": "host", + "description": "Build for host", + "inherits": "defaults" + } + ], + "buildPresets": [ + { + "name": "host-Debug", + "configuration": "Debug", + "configurePreset": "host" + }, + { + "name": "host-Release", + "configuration": "Release", + "configurePreset": "host" + }, + { + "name": "host-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "host" + }, + { + "name": "host-MinSizeRel", + "configuration": "MinSizeRel", + "configurePreset": "host" + } + ] +} diff --git a/.devcontainer/cpp/e2e/workspace/main.cpp b/.devcontainer/cpp/e2e/workspace/main.cpp new file mode 100644 index 00000000..8e31396b --- /dev/null +++ b/.devcontainer/cpp/e2e/workspace/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "Hello World!" << std::endl; + return 0; +} From 83ddb8a1e3cda7fb71daafb465a5000d9501aeba Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 08:50:05 +0000 Subject: [PATCH 02/49] chore: add a containerized playwright setup --- .devcontainer/cpp/devcontainer.json | 7 +++ .github/dependabot.yml | 14 ++++- .gitignore | 1 + package-lock.json | 87 +++++++++++++++++++++++++++++ package.json | 7 +++ 5 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index 539e02c7..68c27a46 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -3,12 +3,19 @@ "dockerfile": "Dockerfile", "context": "../.." }, + "forwardPorts": [6080], "remoteEnv": { "CONTAINER_FLAVOR": "cpp" }, "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + "features": { + "ghcr.io/devcontainers/features/desktop-lite:1.2.0": {}, + "ghcr.io/devcontainers/features/github-cli:1.0.13": {}, + "ghcr.io/devcontainers/features/node:1.5.0": {} + }, + "postCreateCommand": "npm install && npx playwright install-deps && npx playwright install", "customizations": { "vscode": { "settings": { diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b98be326..9c0fc655 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: - package-ecosystem: github-actions directory: / schedule: - interval: daily + interval: weekly groups: github-actions: update-types: @@ -16,8 +16,16 @@ updates: - package-ecosystem: docker directory: .devcontainer schedule: - interval: daily + interval: weekly + - package-ecosystem: devcontainer + directory: .devcontainer + schedule: + interval: weekly + - package-ecosystem: npm + directory: / + schedule: + interval: weekly - package-ecosystem: pip directory: .devcontainer schedule: - interval: daily + interval: weekly diff --git a/.gitignore b/.gitignore index 25de2ddf..91e664e8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ megalinter-reports/ mutants.out/ +node_modules/ target/ *.profdata *.profraw diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..506c2f37 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,87 @@ +{ + "name": "amp-devcontainer", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@playwright/test": "^1.45.2", + "@types/node": "^20.14.11" + } + }, + "node_modules/@playwright/test": { + "version": "1.45.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.45.2.tgz", + "integrity": "sha512-JxG9eq92ET75EbVi3s+4sYbcG7q72ECeZNbdBlaMkGcNbiDQ4cAi8U2QP5oKkOx+1gpaiL1LDStmzCaEM1Z6fQ==", + "dev": true, + "dependencies": { + "playwright": "1.45.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright": { + "version": "1.45.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.45.2.tgz", + "integrity": "sha512-ReywF2t/0teRvNBpfIgh5e4wnrI/8Su8ssdo5XsQKpjxJj+jspm00jSoz9BTg91TT0c9HRjXO7LBNVrgYj9X0g==", + "dev": true, + "dependencies": { + "playwright-core": "1.45.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.45.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.45.2.tgz", + "integrity": "sha512-ha175tAWb0dTK0X4orvBIqi3jGEt701SMxMhyujxNrgd8K0Uy5wMSwwcQHtyB4om7INUkfndx02XnQ2p6dvLDw==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..5b94eefd --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "@playwright/test": "^1.45.2", + "@types/node": "^20.14.11" + }, + "scripts": {} +} From 1e4e4e98e647504e21a28626f7e53345aa494dff Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 08:57:36 +0000 Subject: [PATCH 03/49] chore: rename .devcontainer.json --- .../cpp/e2e/workspace/{.devcontainer.json => devcontainer.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .devcontainer/cpp/e2e/workspace/{.devcontainer.json => devcontainer.json} (100%) diff --git a/.devcontainer/cpp/e2e/workspace/.devcontainer.json b/.devcontainer/cpp/e2e/workspace/devcontainer.json similarity index 100% rename from .devcontainer/cpp/e2e/workspace/.devcontainer.json rename to .devcontainer/cpp/e2e/workspace/devcontainer.json From aa21602d93d49d8f66fed349abd5d9c25da9184a Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:12:39 +0000 Subject: [PATCH 04/49] chore: move devcontainer.json --- .devcontainer/cpp-test/devcontainer.json | 4 ++++ .devcontainer/cpp/e2e/workspace/devcontainer.json | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/cpp-test/devcontainer.json delete mode 100644 .devcontainer/cpp/e2e/workspace/devcontainer.json diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json new file mode 100644 index 00000000..c80ed6b7 --- /dev/null +++ b/.devcontainer/cpp-test/devcontainer.json @@ -0,0 +1,4 @@ +{ + "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", + "workspaceFolder": "/workspace/cpp/e2e/workspace" +} diff --git a/.devcontainer/cpp/e2e/workspace/devcontainer.json b/.devcontainer/cpp/e2e/workspace/devcontainer.json deleted file mode 100644 index 588ac5cd..00000000 --- a/.devcontainer/cpp/e2e/workspace/devcontainer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}" -} From 38655b9b0f812e1ce09a2faed43ae472dbc3cdae Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:18:09 +0000 Subject: [PATCH 05/49] test: depend on 'latest' for now --- .devcontainer/cpp-test/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index c80ed6b7..efcbc2d6 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,4 @@ { - "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", + "image": "ghcr.io/philips-software/amp-devcontainer-cpp", "workspaceFolder": "/workspace/cpp/e2e/workspace" } From e12bc908cd09685c1597b4249d39cadebc86753c Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:25:37 +0000 Subject: [PATCH 06/49] ci: fix linter findings --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9c0fc655..503219a8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,7 +17,7 @@ updates: directory: .devcontainer schedule: interval: weekly - - package-ecosystem: devcontainer + - package-ecosystem: devcontainers directory: .devcontainer schedule: interval: weekly From a15d62141441ca7dd7cd53b51046a4113ea99278 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:26:50 +0000 Subject: [PATCH 07/49] test: fix incorrect workspaceFolder --- .devcontainer/cpp-test/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index efcbc2d6..01048b29 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,4 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp", - "workspaceFolder": "/workspace/cpp/e2e/workspace" + "workspaceFolder": "/workspace/.devcontainer/cpp/e2e/workspace" } From 31937f71eaf30684a0efd7ce7ca84c03b8ca8969 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:33:37 +0000 Subject: [PATCH 08/49] test: fix workspaceFolder by using ${containerWorkspaceFolder} --- .devcontainer/cpp-test/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index 01048b29..a1229267 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,4 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp", - "workspaceFolder": "/workspace/.devcontainer/cpp/e2e/workspace" + "workspaceFolder": "${containerWorkspaceFolder}/.devcontainer/cpp/e2e/workspace" } From da6fb9c39977361391c96413b1bff18e0da1301f Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:39:45 +0000 Subject: [PATCH 09/49] test: different strategy to move workspace folder --- .devcontainer/cpp-test/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index a1229267..ee660835 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,5 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp", - "workspaceFolder": "${containerWorkspaceFolder}/.devcontainer/cpp/e2e/workspace" + "mounts": ["source=${localWorkspaceFolder}/.devcontainer/cpp/e2e/workspace,target=/workspace,type=bind,consistency=cached"], + "workspaceFolder": "/workspace" } From 929fde738367265f0fc6db2b0cf677e93c7a88c1 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:50:08 +0000 Subject: [PATCH 10/49] test: hard-code workspaceFolder --- .devcontainer/cpp-test/devcontainer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index ee660835..8012c7f3 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,5 +1,4 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp", - "mounts": ["source=${localWorkspaceFolder}/.devcontainer/cpp/e2e/workspace,target=/workspace,type=bind,consistency=cached"], - "workspaceFolder": "/workspace" + "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace" } From fe4d21f977a8a89e0d7bff6f0d6cd52fafe84f2d Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:31:23 +0200 Subject: [PATCH 11/49] test: add authentication flow for GitHub --- .devcontainer/cpp/e2e/playwright.config.ts | 24 +++++++++++++++ .../cpp/e2e/tests/authentication.setup.ts | 30 +++++++++++++++++++ .gitignore | 4 +++ package-lock.json | 27 ++++++++++++++++- package.json | 3 +- 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/cpp/e2e/playwright.config.ts create mode 100644 .devcontainer/cpp/e2e/tests/authentication.setup.ts diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts new file mode 100644 index 00000000..921eb149 --- /dev/null +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -0,0 +1,24 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './tests', + fullyParallel: false, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + workers: 1, + reporter: 'html', + use: { + trace: 'on-first-retry', + }, + projects: [ + { name: 'setup', testMatch: /.*\.setup\.ts/ }, + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + storageState: 'playwright/.auth/user.json' + }, + dependencies: ['setup'] + } + ] +}); diff --git a/.devcontainer/cpp/e2e/tests/authentication.setup.ts b/.devcontainer/cpp/e2e/tests/authentication.setup.ts new file mode 100644 index 00000000..8a8872bc --- /dev/null +++ b/.devcontainer/cpp/e2e/tests/authentication.setup.ts @@ -0,0 +1,30 @@ +import { test as setup, expect } from '@playwright/test'; +import * as OTPAuth from 'otpauth'; + +const authFile = 'playwright/.auth/user.json'; + +setup('authenticate', async ({ page }) => { + await page.goto('https://github.com/login'); + await page.getByLabel('Username or email address').fill(process.env.GITHUB_USER!); + await page.getByLabel('Password').fill(process.env.GITHUB_PASSWORD!); + await page.getByRole('button', { name: 'Sign in', exact: true }).click(); + + let totp = new OTPAuth.TOTP({ + issuer: 'GitHub', + label: 'GitHub', + algorithm: 'SHA1', + digits: 6, + period: 30, + secret: process.env.GITHUB_TOTP_SECRET! + }); + + let code = totp.generate(); + await page.getByPlaceholder('XXXXXX').fill(code); + + // Wait until the page receives the cookies. + // + // Sometimes login flow sets cookies in the process of several redirects. + // Wait for the final URL to ensure that the cookies are actually set. + await page.waitForURL('https://github.com/'); + await page.context().storageState({ path: authFile }); +}); diff --git a/.gitignore b/.gitignore index 91e664e8..8fc1250e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ +.auth/ .xwin-cache/ .xwin-hash/ build/ megalinter-reports/ mutants.out/ node_modules/ +playwright-report/ target/ +test-results/ *.profdata *.profraw +.last-run.json diff --git a/package-lock.json b/package-lock.json index 506c2f37..3538e050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,20 @@ "": { "devDependencies": { "@playwright/test": "^1.45.2", - "@types/node": "^20.14.11" + "@types/node": "^20.14.11", + "otpauth": "^9.3.1" + } + }, + "node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "dev": true, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" } }, "node_modules/@playwright/test": { @@ -47,6 +60,18 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/otpauth": { + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/otpauth/-/otpauth-9.3.1.tgz", + "integrity": "sha512-E6d2tMxPofHNk4sRFp+kqW7vQ+WJGO9VLI2N/W00DnI+ThskU12Qa10kyNSGklrzhN5c+wRUsN4GijVgCU2N9w==", + "dev": true, + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://github.com/hectorm/otpauth?sponsor=1" + } + }, "node_modules/playwright": { "version": "1.45.2", "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.45.2.tgz", diff --git a/package.json b/package.json index 5b94eefd..21a023c5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "devDependencies": { "@playwright/test": "^1.45.2", - "@types/node": "^20.14.11" + "@types/node": "^20.14.11", + "otpauth": "^9.3.1" }, "scripts": {} } From 5483f23888427c8e2a9ccc8150ee610102547a5d Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:32:14 +0200 Subject: [PATCH 12/49] refactor: remove unused import --- .devcontainer/cpp/e2e/tests/authentication.setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp/e2e/tests/authentication.setup.ts b/.devcontainer/cpp/e2e/tests/authentication.setup.ts index 8a8872bc..ec6c6bcd 100644 --- a/.devcontainer/cpp/e2e/tests/authentication.setup.ts +++ b/.devcontainer/cpp/e2e/tests/authentication.setup.ts @@ -1,4 +1,4 @@ -import { test as setup, expect } from '@playwright/test'; +import { test as setup } from '@playwright/test'; import * as OTPAuth from 'otpauth'; const authFile = 'playwright/.auth/user.json'; From 4e0ed9cecfaeedfea9bd675062b4ca4b287b50f9 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:49:04 +0200 Subject: [PATCH 13/49] chore: add npm test --- .gitignore | 1 - package.json | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8fc1250e..50bd9838 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,3 @@ target/ test-results/ *.profdata *.profraw -.last-run.json diff --git a/package.json b/package.json index 21a023c5..7712eb75 100644 --- a/package.json +++ b/package.json @@ -4,5 +4,7 @@ "@types/node": "^20.14.11", "otpauth": "^9.3.1" }, - "scripts": {} + "scripts": { + "test": "npx playwright test" + } } From d406afa9fa9cb03294b117a1e4eaa4b12fb94360 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:14:27 +0200 Subject: [PATCH 14/49] ci: add acceptance tests --- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 6 +++++ .github/workflows/acceptance-test.yml | 27 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .devcontainer/cpp/e2e/tests/smoke.spec.ts create mode 100644 .github/workflows/acceptance-test.yml diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts new file mode 100644 index 00000000..6974c6b6 --- /dev/null +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://github.com/'); + await expect(page).toHaveTitle(/GitHub/); +}); diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml new file mode 100644 index 00000000..0b1433e8 --- /dev/null +++ b/.github/workflows/acceptance-test.yml @@ -0,0 +1,27 @@ +--- +name: Acceptance Test + +on: + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + persist-credentials: false + - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + with: + node-version: 18 + - run: npm ci + - run: npx playwright install --with-deps + - run: cd .devcontainer/cpp/e2e && npm test From 727658b9e0dcde23a9cc9722a8fed1da0caf3727 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:00:49 +0000 Subject: [PATCH 15/49] ci: trying to run setup --- .devcontainer/cpp/e2e/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 921eb149..88f3195d 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ trace: 'on-first-retry', }, projects: [ - { name: 'setup', testMatch: /.*\.setup\.ts/ }, + { name: 'setup', testMatch: '**/*.setup.ts' }, { name: 'chromium', use: { From 9f98d3f137f23d972363b5085732c3a6c9c3a7b8 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:40:31 +0000 Subject: [PATCH 16/49] test: enable running tests from VS Code extension --- .devcontainer/cpp/e2e/playwright.config.ts | 10 ++++++++-- .devcontainer/cpp/e2e/tests/authentication.setup.ts | 5 ++--- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 2 +- .gitignore | 1 + package-lock.json | 13 +++++++++++++ package.json | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 88f3195d..a8d80176 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -1,4 +1,9 @@ import { defineConfig, devices } from '@playwright/test'; +import path from 'path'; + +require('dotenv').config(); + +export const STORAGE_STATE = path.join(__dirname, 'playwright/.auth/user.json'); export default defineConfig({ testDir: './tests', @@ -8,7 +13,8 @@ export default defineConfig({ workers: 1, reporter: 'html', use: { - trace: 'on-first-retry', + baseURL: 'https://github.com', + trace: 'on-first-retry' }, projects: [ { name: 'setup', testMatch: '**/*.setup.ts' }, @@ -16,7 +22,7 @@ export default defineConfig({ name: 'chromium', use: { ...devices['Desktop Chrome'], - storageState: 'playwright/.auth/user.json' + storageState: STORAGE_STATE }, dependencies: ['setup'] } diff --git a/.devcontainer/cpp/e2e/tests/authentication.setup.ts b/.devcontainer/cpp/e2e/tests/authentication.setup.ts index ec6c6bcd..31761201 100644 --- a/.devcontainer/cpp/e2e/tests/authentication.setup.ts +++ b/.devcontainer/cpp/e2e/tests/authentication.setup.ts @@ -1,7 +1,6 @@ import { test as setup } from '@playwright/test'; import * as OTPAuth from 'otpauth'; - -const authFile = 'playwright/.auth/user.json'; +import { STORAGE_STATE } from '../playwright.config'; setup('authenticate', async ({ page }) => { await page.goto('https://github.com/login'); @@ -26,5 +25,5 @@ setup('authenticate', async ({ page }) => { // Sometimes login flow sets cookies in the process of several redirects. // Wait for the final URL to ensure that the cookies are actually set. await page.waitForURL('https://github.com/'); - await page.context().storageState({ path: authFile }); + await page.context().storageState({ path: STORAGE_STATE }); }); diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 6974c6b6..2646f193 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('https://github.com/'); + await page.goto('/'); await expect(page).toHaveTitle(/GitHub/); }); diff --git a/.gitignore b/.gitignore index 50bd9838..1bc48665 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ node_modules/ playwright-report/ target/ test-results/ +.env *.profdata *.profraw diff --git a/package-lock.json b/package-lock.json index 3538e050..b2b03701 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "devDependencies": { "@playwright/test": "^1.45.2", "@types/node": "^20.14.11", + "dotenv": "^16.4.5", "otpauth": "^9.3.1" } }, @@ -46,6 +47,18 @@ "undici-types": "~5.26.4" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", diff --git a/package.json b/package.json index 7712eb75..4e40e379 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "devDependencies": { "@playwright/test": "^1.45.2", "@types/node": "^20.14.11", + "dotenv": "^16.4.5", "otpauth": "^9.3.1" }, "scripts": { From f06a1c7619d28f9b1f15f15f7e5cc49027bf66bf Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:41:15 +0000 Subject: [PATCH 17/49] chore: add required extension --- .devcontainer/cpp/devcontainer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index 68c27a46..be82f6c0 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -30,6 +30,7 @@ "matepek.vscode-catch2-test-adapter@4.12.0", "mhutchie.git-graph@1.30.0", "ms-azuretools.vscode-docker@1.29.1", + "ms-playwright.playwright@1.1.7", "ms-vscode.cmake-tools@1.18.42", "ms-vscode.cpptools@1.20.5", "sonarsource.sonarlint-vscode@4.7.0", From 79fb4aef90a27fc2624668c66a59cf639ad1a8b9 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:52:01 +0000 Subject: [PATCH 18/49] ci: try to dynamically choose the image again --- .devcontainer/cpp-test/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index 8012c7f3..454680b7 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,4 @@ { - "image": "ghcr.io/philips-software/amp-devcontainer-cpp", + "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace" } From e9381e64225c47d8f81f995056cec089a9a1d450 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:04:02 +0000 Subject: [PATCH 19/49] ci: fix starting from incorrect path --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e40e379..191d8d88 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,6 @@ "otpauth": "^9.3.1" }, "scripts": { - "test": "npx playwright test" + "test": "cd $INIT_CWD && npx playwright test" } } From 901475847cee65b8af3ab39ed52f18f53953b83f Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:53:28 +0000 Subject: [PATCH 20/49] ci: inject env secrets --- .github/workflows/acceptance-test.yml | 4 ++++ README.md | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 0b1433e8..1c928514 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -25,3 +25,7 @@ jobs: - run: npm ci - run: npx playwright install --with-deps - run: cd .devcontainer/cpp/e2e && npm test + env: + GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} + GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} + GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} diff --git a/README.md b/README.md index aed080da..818f7ce1 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,22 @@ This project uses [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.htm The containers can be built and tested locally by importing this repository in VS Code with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) plug-in installed. As a prerequisite Docker needs to be installed on the host system. Alternatively a GitHub Codespace can be started. +#### Running the Integration Tests + A test task is available to run the included `bats` tests. Choose `Tasks: Run Test Task` from the command pallette (Ctrl + Shift + P). +#### Running the Acceptance Tests + +Create an .env file with the following contents, this assumes a GitHub account that has rights to create a Codespace on this repository and is configured for time-based one-time password (TOTP) two-factor authentication (2FA). + +```dotenv +GITHUB_USER= +GITHUB_PASSWORD= +GITHUB_TOTP_SECRET= +``` + +Test can now be run using the Test Explorer. The user interface, when selected, is available [here](http://localhost:6080) by-default. When port 6080 is already taken another port will be exposed. This can be seen with the Ports view (Ctrl + Shift + P, Ports: Focus on Ports View). + ## Reporting vulnerabilities If you find a vulnerability, please report it to us! From 7f6d90ec358ec51f4807b55654be943f7696a7bf Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:07:38 +0000 Subject: [PATCH 21/49] ci: create codespace under test --- .github/workflows/acceptance-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 1c928514..dc6fbae0 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -24,6 +24,11 @@ jobs: node-version: 18 - run: npm ci - run: npx playwright install --with-deps + - run: | + gh codespace create --branch ${{ github.head_ref }} --machine basicLinux32gb + env: + GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} + IMAGE_VERSION: pr-${{ github.event.pull_request.number }} - run: cd .devcontainer/cpp/e2e && npm test env: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} From 95440556e4fe96ccdad5d5886b6df85c9c717c0d Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:14:13 +0000 Subject: [PATCH 22/49] ci: fix linter findings --- .devcontainer/cpp/e2e/playwright.config.ts | 2 +- .github/workflows/acceptance-test.yml | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index a8d80176..51b893f1 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: 1, - reporter: 'html', + reporter: 'list', use: { baseURL: 'https://github.com', trace: 'on-first-retry' diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index dc6fbae0..815b79a2 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -15,6 +15,9 @@ permissions: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + flavor: [cpp] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -25,11 +28,12 @@ jobs: - run: npm ci - run: npx playwright install --with-deps - run: | - gh codespace create --branch ${{ github.head_ref }} --machine basicLinux32gb + gh codespace create --branch $HEAD_REF --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json --machine basicLinux32gb env: + HEAD_REF: ${{ github.head_ref }} GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} IMAGE_VERSION: pr-${{ github.event.pull_request.number }} - - run: cd .devcontainer/cpp/e2e && npm test + - run: cd .devcontainer/${{ matrix.flavor }}/e2e && npm test env: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} From 91827bbb909c0a8d091bb451d6a2ad977a6b5205 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:18:41 +0000 Subject: [PATCH 23/49] ci: get codespace going --- .github/workflows/acceptance-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 815b79a2..9e99d557 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -25,10 +25,10 @@ jobs: - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 - - run: npm ci - - run: npx playwright install --with-deps + #- run: npm ci + #- run: npx playwright install --with-deps - run: | - gh codespace create --branch $HEAD_REF --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json --machine basicLinux32gb + gh codespace create --repository ${{ github.repository }} --branch $HEAD_REF --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json --machine basicLinux32gb env: HEAD_REF: ${{ github.head_ref }} GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From b4d0099cbe91cafc873ea0f24dee97b3b42e77a4 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:20:42 +0000 Subject: [PATCH 24/49] ci: rtfm --- .github/workflows/acceptance-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 9e99d557..357e9d8b 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -28,7 +28,7 @@ jobs: #- run: npm ci #- run: npx playwright install --with-deps - run: | - gh codespace create --repository ${{ github.repository }} --branch $HEAD_REF --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json --machine basicLinux32gb + gh codespace create -R ${{ github.repository }} -b $HEAD_REF -m basicLinux32gb --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json env: HEAD_REF: ${{ github.head_ref }} GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From 26db80e369607626a4e14acaeab4f09f860e5629 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Fri, 26 Jul 2024 06:52:22 +0000 Subject: [PATCH 25/49] test: inspect host environment before starting codespace --- .devcontainer/cpp-test/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index 454680b7..ee3525e2 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,5 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", - "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace" + "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace", + "initializeCommand": "env" } From e114d9c7d42fc931ec577c581017e44c61628969 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:36:47 +0000 Subject: [PATCH 26/49] ci: communicate image version via codespaces secret --- .devcontainer/cpp-test/devcontainer.json | 3 +-- .github/workflows/acceptance-test.yml | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index ee3525e2..454680b7 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,5 +1,4 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", - "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace", - "initializeCommand": "env" + "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace" } diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 357e9d8b..192d143c 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -6,8 +6,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true + group: ${{ github.workflow }} + cancel-in-progress: false permissions: contents: read @@ -24,14 +24,16 @@ jobs: persist-credentials: false - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: - node-version: 18 + node-version: 20 #- run: npm ci #- run: npx playwright install --with-deps - run: | + gh auth login -s codespace + gh secret set -a codespaces --body "pr-${{ github.event.pull_request.number }}" gh codespace create -R ${{ github.repository }} -b $HEAD_REF -m basicLinux32gb --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json env: - HEAD_REF: ${{ github.head_ref }} GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} + HEAD_REF: ${{ github.head_ref }} IMAGE_VERSION: pr-${{ github.event.pull_request.number }} - run: cd .devcontainer/${{ matrix.flavor }}/e2e && npm test env: From 6f6b7bbc2f1c2ab30e6a39cae184d16358b74e57 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:41:06 +0000 Subject: [PATCH 27/49] ci: test if token already has correct scopes --- .github/workflows/acceptance-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 192d143c..2968deda 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -28,7 +28,6 @@ jobs: #- run: npm ci #- run: npx playwright install --with-deps - run: | - gh auth login -s codespace gh secret set -a codespaces --body "pr-${{ github.event.pull_request.number }}" gh codespace create -R ${{ github.repository }} -b $HEAD_REF -m basicLinux32gb --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json env: From eaa91ef5b5d8df9f56f945d3aab5bc8e4ee2ab08 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:06:04 +0000 Subject: [PATCH 28/49] ci: able to start codespace, yay --- .github/workflows/acceptance-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 2968deda..b0495cb9 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -25,10 +25,10 @@ jobs: - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 20 - #- run: npm ci - #- run: npx playwright install --with-deps + - run: npm ci + - run: npx playwright install --with-deps - run: | - gh secret set -a codespaces --body "pr-${{ github.event.pull_request.number }}" + gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" gh codespace create -R ${{ github.repository }} -b $HEAD_REF -m basicLinux32gb --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From 74d80e3275d0f6c509ba9ef60d50b9c800f8f283 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:04:13 +0000 Subject: [PATCH 29/49] chore: fix linter findings --- .github/workflows/acceptance-test.yml | 4 +++- README.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index b0495cb9..c1727521 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -27,9 +27,11 @@ jobs: node-version: 20 - run: npm ci - run: npx playwright install --with-deps + # Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable). + # This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. - run: | gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" - gh codespace create -R ${{ github.repository }} -b $HEAD_REF -m basicLinux32gb --devcontainer-path .devcontainer/${{ matrix.flavor }}-test/devcontainer.json + gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} HEAD_REF: ${{ github.head_ref }} diff --git a/README.md b/README.md index 818f7ce1..6a74608a 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ GITHUB_PASSWORD= GITHUB_TOTP_SECRET= ``` -Test can now be run using the Test Explorer. The user interface, when selected, is available [here](http://localhost:6080) by-default. When port 6080 is already taken another port will be exposed. This can be seen with the Ports view (Ctrl + Shift + P, Ports: Focus on Ports View). +Test can now be run using the Test Explorer. The user interface is available on port 6080 by-default. When port 6080 is already taken another port will be exposed. This can be seen with the Ports view (Ctrl + Shift + P, Ports: Focus on Ports View). ## Reporting vulnerabilities From 2413e8583c5a5405259195afc4e62eab4f31e251 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:24:07 +0000 Subject: [PATCH 30/49] chore: first working test --- .devcontainer/cpp/devcontainer.json | 3 ++- .devcontainer/cpp/e2e/playwright.config.ts | 6 +++++- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 7 +++++-- .github/workflows/acceptance-test.yml | 3 +-- .gitignore | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index be82f6c0..a3ac95e8 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -5,7 +5,8 @@ }, "forwardPorts": [6080], "remoteEnv": { - "CONTAINER_FLAVOR": "cpp" + "CONTAINER_FLAVOR": "cpp", + "NODE_EXTRA_CA_CERTS": "/usr/local/share/ca-certificates/Cisco_Umbrella_Root_CA.crt" }, "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 51b893f1..1ef51015 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -12,8 +12,12 @@ export default defineConfig({ retries: process.env.CI ? 2 : 0, workers: 1, reporter: 'list', + timeout: 2 * 60 * 1000, + expect: { + timeout: 30 * 1000 + }, use: { - baseURL: 'https://github.com', + baseURL: 'https://' + process.env.CODESPACE_NAME + '.github.dev', trace: 'on-first-retry' }, projects: [ diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 2646f193..48142c0f 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -1,6 +1,9 @@ import { test, expect } from '@playwright/test'; -test('has title', async ({ page }) => { +test('build project', async ({ page }) => { await page.goto('/'); - await expect(page).toHaveTitle(/GitHub/); + await expect(page.getByLabel('host, Build for host')).toBeVisible(); + await page.getByRole('button', { name: 'Build the selected target' }).click(); + await page.getByLabel('host, Build for host').locator('a').click(); + await expect(page.getByText('[build] Build finished with')).toBeVisible(); }); diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index c1727521..4d3e1c97 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -31,11 +31,10 @@ jobs: # This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. - run: | gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" - gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h + echo CODESPACE_NAME=$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h) >> "$GITHUB_ENV" env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} HEAD_REF: ${{ github.head_ref }} - IMAGE_VERSION: pr-${{ github.event.pull_request.number }} - run: cd .devcontainer/${{ matrix.flavor }}/e2e && npm test env: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} diff --git a/.gitignore b/.gitignore index 1bc48665..1f58bd88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.auth/ .xwin-cache/ .xwin-hash/ build/ @@ -11,3 +10,4 @@ test-results/ .env *.profdata *.profraw +**/playwright/.auth/user.json From 422f165b01c0953c20ac475ef7481652742c3b92 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:28:13 +0000 Subject: [PATCH 31/49] chore: fix linter findings --- .github/workflows/acceptance-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 4d3e1c97..a58b756b 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -31,7 +31,7 @@ jobs: # This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. - run: | gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" - echo CODESPACE_NAME=$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h) >> "$GITHUB_ENV" + echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} HEAD_REF: ${{ github.head_ref }} From ba0f5c7b577508d83fb9ce71b6ae3546c5c320ab Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:28:06 +0000 Subject: [PATCH 32/49] ci: add harden-runner action --- .github/workflows/acceptance-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index a58b756b..ceeae99c 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -19,6 +19,9 @@ jobs: matrix: flavor: [cpp] steps: + - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v9.0.1 + with: + egress-policy: audit - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false From 577ea708f36fcb798397778508332af41e2b3b4c Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:14:36 +0000 Subject: [PATCH 33/49] test: use a page object model paradigm --- .devcontainer/cpp/e2e/playwright.config.ts | 3 +- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 30 ++++++++++++++++++++ .devcontainer/cpp/e2e/tests/smoke.spec.ts | 10 +++++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/cpp/e2e/tests/codespace.pom.ts diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 1ef51015..60b955f6 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -12,12 +12,11 @@ export default defineConfig({ retries: process.env.CI ? 2 : 0, workers: 1, reporter: 'list', - timeout: 2 * 60 * 1000, + timeout: 3 * 60 * 1000, expect: { timeout: 30 * 1000 }, use: { - baseURL: 'https://' + process.env.CODESPACE_NAME + '.github.dev', trace: 'on-first-retry' }, projects: [ diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts new file mode 100644 index 00000000..e7568693 --- /dev/null +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -0,0 +1,30 @@ +import { expect, type Locator, type Page } from '@playwright/test'; + +export class CodespacePage { + readonly page: Page; + + constructor(page: Page) { + this.page = page; + } + + async goto() { + await this.page.goto('https://' + process.env.CODESPACE_NAME + '.github.dev'); + } + + async arePluginsActive(plugins: string[]) { + for (const plugin of plugins) { + await expect(this.page.getByRole('tab', { name: plugin })).toBeVisible(); + } + } + + async executeInTerminal(commands: string | string[]) { + let commandsWithExit = Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']; + + await this.page.keyboard.press('Control+Shift+`'); + + for (const command of commandsWithExit) { + await this.page.keyboard.type(command); + await this.page.keyboard.press('Enter'); + } + } +} diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 48142c0f..da1d6e64 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -1,8 +1,14 @@ import { test, expect } from '@playwright/test'; +import { CodespacePage } from './codespace.pom'; + +test.beforeEach(async ({ page }) => { + const codespace = new CodespacePage(page); + await codespace.goto(); + await codespace.arePluginsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); + await codespace.executeInTerminal('git clean -fdx'); +}); test('build project', async ({ page }) => { - await page.goto('/'); - await expect(page.getByLabel('host, Build for host')).toBeVisible(); await page.getByRole('button', { name: 'Build the selected target' }).click(); await page.getByLabel('host, Build for host').locator('a').click(); await expect(page.getByText('[build] Build finished with')).toBeVisible(); From ddd455557fb1efc70928d674d340da4a4e7ca771 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:39:58 +0000 Subject: [PATCH 34/49] test: mark the beforeEach as slow because of first-time-start --- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index da1d6e64..69024b6f 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test'; import { CodespacePage } from './codespace.pom'; test.beforeEach(async ({ page }) => { + test.slow(); const codespace = new CodespacePage(page); await codespace.goto(); await codespace.arePluginsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); From f39b8af765c3040767afb16ff2e141e43e2ad178 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:08:44 +0000 Subject: [PATCH 35/49] test: make start-up more robust --- .devcontainer/cpp/e2e/playwright.config.ts | 4 ++-- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 9 +++++++-- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 60b955f6..4e68325b 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -12,9 +12,9 @@ export default defineConfig({ retries: process.env.CI ? 2 : 0, workers: 1, reporter: 'list', - timeout: 3 * 60 * 1000, + timeout: 2 * 60 * 1000, expect: { - timeout: 30 * 1000 + timeout: 1 * 60 * 1000 }, use: { trace: 'on-first-retry' diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index e7568693..f0cec339 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -11,9 +11,9 @@ export class CodespacePage { await this.page.goto('https://' + process.env.CODESPACE_NAME + '.github.dev'); } - async arePluginsActive(plugins: string[]) { + async areExtensionsActive(plugins: string[]) { for (const plugin of plugins) { - await expect(this.page.getByRole('tab', { name: plugin })).toBeVisible(); + await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible(); } } @@ -21,10 +21,15 @@ export class CodespacePage { let commandsWithExit = Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']; await this.page.keyboard.press('Control+Shift+`'); + expect(this.page.locator('.terminal-widget-container')).toBeVisible(); for (const command of commandsWithExit) { await this.page.keyboard.type(command); await this.page.keyboard.press('Enter'); } } + + async openTabByName(name: string) { + await this.page.getByRole('tab', { name: name }).locator('a').click(); + } } diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 69024b6f..e896f400 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -5,7 +5,7 @@ test.beforeEach(async ({ page }) => { test.slow(); const codespace = new CodespacePage(page); await codespace.goto(); - await codespace.arePluginsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); + await codespace.areExtensionsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); await codespace.executeInTerminal('git clean -fdx'); }); From 2fb06dc2247bd2cd02baf3caafda65c9cae33edf Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:15:59 +0000 Subject: [PATCH 36/49] test: different timeout strategy --- .devcontainer/cpp/e2e/playwright.config.ts | 4 ---- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.devcontainer/cpp/e2e/playwright.config.ts b/.devcontainer/cpp/e2e/playwright.config.ts index 4e68325b..939d644b 100644 --- a/.devcontainer/cpp/e2e/playwright.config.ts +++ b/.devcontainer/cpp/e2e/playwright.config.ts @@ -12,10 +12,6 @@ export default defineConfig({ retries: process.env.CI ? 2 : 0, workers: 1, reporter: 'list', - timeout: 2 * 60 * 1000, - expect: { - timeout: 1 * 60 * 1000 - }, use: { trace: 'on-first-retry' }, diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index f0cec339..dd244783 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -13,7 +13,7 @@ export class CodespacePage { async areExtensionsActive(plugins: string[]) { for (const plugin of plugins) { - await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible(); + await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 }); } } @@ -21,7 +21,7 @@ export class CodespacePage { let commandsWithExit = Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']; await this.page.keyboard.press('Control+Shift+`'); - expect(this.page.locator('.terminal-widget-container')).toBeVisible(); + expect(this.page.locator('.terminal-widget-container').first()).toBeVisible(); for (const command of commandsWithExit) { await this.page.keyboard.type(command); From 3ca0754dc7491b1476a3df6aa4312c234d42f25a Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:25:26 +0000 Subject: [PATCH 37/49] ci: fail on create codespace and clean-up afterwards --- .github/workflows/acceptance-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index ceeae99c..2872fafe 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -33,6 +33,7 @@ jobs: # Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable). # This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. - run: | + set -Eeuo pipefail gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" env: @@ -43,3 +44,7 @@ jobs: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} + - run: gh codespace delete --yes "$CODESPACE_NAME" + if: always() + env: + GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From ccfa4f19dd50b1fd04811a4966988946dcbfd4c4 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:37:36 +0000 Subject: [PATCH 38/49] test: more timeout --- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 4 +++- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 1 - .github/workflows/acceptance-test.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index dd244783..22415e18 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -1,4 +1,4 @@ -import { expect, type Locator, type Page } from '@playwright/test'; +import { test, expect, type Page } from '@playwright/test'; export class CodespacePage { readonly page: Page; @@ -12,6 +12,8 @@ export class CodespacePage { } async areExtensionsActive(plugins: string[]) { + test.setTimeout(3 * 60 * 1000); + for (const plugin of plugins) { await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 }); } diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index e896f400..531c0fa9 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -2,7 +2,6 @@ import { test, expect } from '@playwright/test'; import { CodespacePage } from './codespace.pom'; test.beforeEach(async ({ page }) => { - test.slow(); const codespace = new CodespacePage(page); await codespace.goto(); await codespace.areExtensionsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 2872fafe..a6f0ed3b 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -44,7 +44,7 @@ jobs: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} - - run: gh codespace delete --yes "$CODESPACE_NAME" + - run: gh codespace delete --force --codespace "$CODESPACE_NAME" if: always() env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From c53628352b7e2132b01d49487292a3d9c5e9f26d Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:49:27 +0000 Subject: [PATCH 39/49] test: give the build more time to finish --- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 20 ++++++++++++++++++-- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index 22415e18..c1ddc416 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -11,10 +11,26 @@ export class CodespacePage { await this.page.goto('https://' + process.env.CODESPACE_NAME + '.github.dev'); } - async areExtensionsActive(plugins: string[]) { + /** + * Wait for the extensions to be active in the Codespace. + * + * This method is used to verify that the extensions in `extensions` are active in the Codespace. + * Used when waiting for the Codespace to be ready for testing. As the + * extensions are typically activated last, before the Codespace is ready for use. + * + * ** USAGE ** + * + * ```ts + * const codespace = new CodespacePage(page); + * await codespace.areExtensionsActive(['SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); + * ``` + * + * @param extensions List of extensions to wait for. + */ + async areExtensionsActive(extensions: string[]) { test.setTimeout(3 * 60 * 1000); - for (const plugin of plugins) { + for (const plugin of extensions) { await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 }); } } diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 531c0fa9..dfc20078 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -11,5 +11,5 @@ test.beforeEach(async ({ page }) => { test('build project', async ({ page }) => { await page.getByRole('button', { name: 'Build the selected target' }).click(); await page.getByLabel('host, Build for host').locator('a').click(); - await expect(page.getByText('[build] Build finished with')).toBeVisible(); + await expect(page.getByText('[build] Build finished with')).toBeVisible({ timeout: 1 * 60 * 1000 }); }); From d4e855455ecc91d6dae110a87e19584efb5d6616 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:36:42 +0000 Subject: [PATCH 40/49] test: increase timeout even more --- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index dfc20078..7faeaed9 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -11,5 +11,5 @@ test.beforeEach(async ({ page }) => { test('build project', async ({ page }) => { await page.getByRole('button', { name: 'Build the selected target' }).click(); await page.getByLabel('host, Build for host').locator('a').click(); - await expect(page.getByText('[build] Build finished with')).toBeVisible({ timeout: 1 * 60 * 1000 }); + await expect(page.getByText('[build] Build finished with')).toBeVisible({ timeout: 5 * 60 * 1000 }); }); From 5aa3d8990fc936c991a520f0f1aeb0c68d894b0a Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:36:58 +0000 Subject: [PATCH 41/49] ci: move acceptance test to the right place --- .github/workflows/acceptance-test.yml | 12 ++++++------ .github/workflows/build-push.yml | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index a6f0ed3b..bc7b2e9d 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -2,8 +2,11 @@ name: Acceptance Test on: - pull_request: - workflow_dispatch: + workflow_call: + inputs: + flavor: + required: true + type: string concurrency: group: ${{ github.workflow }} @@ -15,9 +18,6 @@ permissions: jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - flavor: [cpp] steps: - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v9.0.1 with: @@ -39,7 +39,7 @@ jobs: env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} HEAD_REF: ${{ github.head_ref }} - - run: cd .devcontainer/${{ matrix.flavor }}/e2e && npm test + - run: cd .devcontainer/${{ inputs.flavor }}/e2e && npm test env: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 3616f422..36ad1a0f 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -33,6 +33,9 @@ jobs: matrix: flavor: ["cpp", "rust"] steps: + - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v9.0.1 + with: + egress-policy: audit - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false @@ -126,3 +129,8 @@ jobs: DIGEST: ${{ steps.build-and-push.outputs.digest }} run: | cosign sign --yes --recursive "${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}@${DIGEST}" + - uses: ./.github/workflows/acceptance-test.yml + if: github.event_name == 'pull_request' + with: + flavor: ${{ matrix.flavor }} + secrets: inherit From 072c5edf1f6342846751eb7bf26fabbc69707113 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:56:01 +0000 Subject: [PATCH 42/49] ci: correct issues --- .github/workflows/acceptance-test.yml | 2 +- .github/workflows/build-push.yml | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index bc7b2e9d..44b2924a 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -35,7 +35,7 @@ jobs: - run: | set -Eeuo pipefail gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" - echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ matrix.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" + echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} HEAD_REF: ${{ github.head_ref }} diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 36ad1a0f..f1a1827a 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -129,8 +129,10 @@ jobs: DIGEST: ${{ steps.build-and-push.outputs.digest }} run: | cosign sign --yes --recursive "${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}@${DIGEST}" - - uses: ./.github/workflows/acceptance-test.yml - if: github.event_name == 'pull_request' - with: - flavor: ${{ matrix.flavor }} - secrets: inherit + acceptance-test: + if: github.event_name == 'pull_request' + needs: build-push + secrets: inherit + uses: ./.github/workflows/acceptance-test.yml + with: + flavor: cpp From 1d6209c7597b0ae7c16c349bdc9dd92bc25b0b7d Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:00:10 +0000 Subject: [PATCH 43/49] test: add more tests and make them robust --- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 58 +++++++++++++++++--- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 33 +++++++++-- 2 files changed, 78 insertions(+), 13 deletions(-) diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index c1ddc416..fc155a9d 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -1,10 +1,17 @@ -import { test, expect, type Page } from '@playwright/test'; +import { test, expect, type Page, type Locator } from '@playwright/test'; + +type CommandAndPrompt = { + command: string, + prompt?: string +}; export class CodespacePage { readonly page: Page; + readonly outputPanel: Locator; constructor(page: Page) { this.page = page; + this.outputPanel = page.locator('[id="workbench.panel.output"]'); } async goto() { @@ -18,14 +25,14 @@ export class CodespacePage { * Used when waiting for the Codespace to be ready for testing. As the * extensions are typically activated last, before the Codespace is ready for use. * - * ** USAGE ** + * **Usage** * * ```ts * const codespace = new CodespacePage(page); * await codespace.areExtensionsActive(['SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); * ``` * - * @param extensions List of extensions to wait for. + * @param extensions - The list of extensions to wait for. */ async areExtensionsActive(extensions: string[]) { test.setTimeout(3 * 60 * 1000); @@ -35,18 +42,51 @@ export class CodespacePage { } } + /** + * Executes the given commands in the terminal. + * + * **Usage** + * + * ```ts + * const codespace = new CodespacePage(page); + * await codespace.executeInTerminal('git clean -fdx'); + * ``` + * + * @param commands - The commands to execute in the terminal. It can be a single command or an array of commands. + */ async executeInTerminal(commands: string | string[]) { - let commandsWithExit = Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']; - await this.page.keyboard.press('Control+Shift+`'); - expect(this.page.locator('.terminal-widget-container').first()).toBeVisible(); - for (const command of commandsWithExit) { - await this.page.keyboard.type(command); - await this.page.keyboard.press('Enter'); + for (const command of Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']) { + await this.page.locator('.terminal-widget-container').first().pressSequentially(command); + await this.page.locator('.terminal-widget-container').first().press('Enter'); + } + } + + /** + * Executes the given commands in the command palette. + * + * This method waits for `prompt` to appear and then types `command` and presses Enter. + * When no prompt is given the default prompt is used. + * + * @param commands - The commands to execute in the command palette. It can be a single command or an array of commands. + */ + async executeFromCommandPalette(commands: CommandAndPrompt | CommandAndPrompt[]) { + await this.page.keyboard.press('Control+Shift+P'); + + for (const command of Array.isArray(commands) ? [...commands] : [commands]) { + let prompt = this.page.getByPlaceholder(command.prompt || 'Type the name of a command to run'); + + await prompt.pressSequentially(command.command); + await prompt.press('Enter'); } } + /** + * Opens the tab with the given name. + * + * @param name - The name of the tab to open. + */ async openTabByName(name: string) { await this.page.getByRole('tab', { name: name }).locator('a').click(); } diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index 7faeaed9..fb2bab43 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -1,15 +1,40 @@ import { test, expect } from '@playwright/test'; import { CodespacePage } from './codespace.pom'; +import { describe } from 'node:test'; test.beforeEach(async ({ page }) => { const codespace = new CodespacePage(page); + await codespace.goto(); await codespace.areExtensionsActive(['Testing', 'SonarLint', 'CMake', 'Live Share', 'GitHub Pull Requests']); await codespace.executeInTerminal('git clean -fdx'); }); -test('build project', async ({ page }) => { - await page.getByRole('button', { name: 'Build the selected target' }).click(); - await page.getByLabel('host, Build for host').locator('a').click(); - await expect(page.getByText('[build] Build finished with')).toBeVisible({ timeout: 5 * 60 * 1000 }); +describe('CMake', () => { + test('should succesfully build without selecting configuration', async ({ page }) => { + const codespace = new CodespacePage(page); + + await page.getByRole('button', { name: 'Build the selected target' }).click(); + await page.getByLabel('host, Build for host').locator('a').click(); + await expect(codespace.outputPanel).toContainText('Build finished with exit code 0', { timeout: 5 * 60 * 1000 }); + }); + + test('should succesfully build after selecting configuration', async ({ page }) => { + const codespace = new CodespacePage(page); + + await codespace.openTabByName('CMake'); + await expect(page.getByRole('treeitem', { name: 'Change Configure Preset' })).toContainText('[No Configure Preset Selected]'); + await expect(page.getByRole('treeitem', { name: 'Change Build Preset' })).toContainText('[No Build Preset Selected]'); + + await codespace.executeFromCommandPalette([{ command: 'CMake: Select Configure Preset' }, + { command: 'host', prompt: 'Select a configure preset' }]); + await expect(page.getByRole('treeitem', { name: 'Change Configure Preset' })).toContainText('host'); + + await codespace.executeFromCommandPalette([{ command: 'CMake: Select Build Preset' }, + { command: 'host-Release', prompt: 'Select a build preset' }]); + await expect(page.getByRole('treeitem', { name: 'Change Build Preset' })).toContainText('host-Release'); + + await page.getByRole('button', { name: 'Build the selected target' }).click(); + await expect(codespace.outputPanel).toContainText('Build finished with exit code 0', { timeout: 5 * 60 * 1000 }); + }); }); From 55ff0079d69cd8f7b67c9d5e0ef269a3b6c74c56 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:03:45 +0000 Subject: [PATCH 44/49] test: use proper test.describe --- .devcontainer/cpp/e2e/tests/smoke.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/cpp/e2e/tests/smoke.spec.ts b/.devcontainer/cpp/e2e/tests/smoke.spec.ts index fb2bab43..bee322fc 100644 --- a/.devcontainer/cpp/e2e/tests/smoke.spec.ts +++ b/.devcontainer/cpp/e2e/tests/smoke.spec.ts @@ -1,6 +1,5 @@ import { test, expect } from '@playwright/test'; import { CodespacePage } from './codespace.pom'; -import { describe } from 'node:test'; test.beforeEach(async ({ page }) => { const codespace = new CodespacePage(page); @@ -10,7 +9,7 @@ test.beforeEach(async ({ page }) => { await codespace.executeInTerminal('git clean -fdx'); }); -describe('CMake', () => { +test.describe('CMake', () => { test('should succesfully build without selecting configuration', async ({ page }) => { const codespace = new CodespacePage(page); From ee4036c2f27a13555054656ca28b1c9f8c40a4e2 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:23:49 +0000 Subject: [PATCH 45/49] test: increase robustness --- .devcontainer/cpp-test/devcontainer.json | 9 ++++++++- .devcontainer/cpp/e2e/tests/codespace.pom.ts | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.devcontainer/cpp-test/devcontainer.json b/.devcontainer/cpp-test/devcontainer.json index 454680b7..02940f28 100644 --- a/.devcontainer/cpp-test/devcontainer.json +++ b/.devcontainer/cpp-test/devcontainer.json @@ -1,4 +1,11 @@ { "image": "ghcr.io/philips-software/amp-devcontainer-cpp:${localEnv:IMAGE_VERSION}", - "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace" + "workspaceFolder": "/workspaces/amp-devcontainer/.devcontainer/cpp/e2e/workspace", + "customizations": { + "vscode": { + "settings": { + "cmake.automaticReconfigure": false + } + } + } } diff --git a/.devcontainer/cpp/e2e/tests/codespace.pom.ts b/.devcontainer/cpp/e2e/tests/codespace.pom.ts index fc155a9d..e521cd15 100644 --- a/.devcontainer/cpp/e2e/tests/codespace.pom.ts +++ b/.devcontainer/cpp/e2e/tests/codespace.pom.ts @@ -8,10 +8,12 @@ type CommandAndPrompt = { export class CodespacePage { readonly page: Page; readonly outputPanel: Locator; + readonly terminal: Locator; constructor(page: Page) { this.page = page; this.outputPanel = page.locator('[id="workbench.panel.output"]'); + this.terminal = page.locator('.terminal-widget-container').first(); } async goto() { @@ -40,6 +42,8 @@ export class CodespacePage { for (const plugin of extensions) { await expect(this.page.getByRole('tab', { name: plugin }).locator('a')).toBeVisible({ timeout: 5 * 60 * 1000 }); } + + await expect(this.page.getByRole('button', { name: 'Activating Extensions...' })).toBeHidden(); } /** @@ -56,10 +60,11 @@ export class CodespacePage { */ async executeInTerminal(commands: string | string[]) { await this.page.keyboard.press('Control+Shift+`'); + await expect(this.page.locator('.terminal-wrapper.active')).toBeVisible(); for (const command of Array.isArray(commands) ? [...commands + 'exit'] : [commands, 'exit']) { - await this.page.locator('.terminal-widget-container').first().pressSequentially(command); - await this.page.locator('.terminal-widget-container').first().press('Enter'); + await this.terminal.pressSequentially(command); + await this.terminal.press('Enter'); } } @@ -74,7 +79,7 @@ export class CodespacePage { async executeFromCommandPalette(commands: CommandAndPrompt | CommandAndPrompt[]) { await this.page.keyboard.press('Control+Shift+P'); - for (const command of Array.isArray(commands) ? [...commands] : [commands]) { + for (const command of Array.isArray(commands) ? commands : [commands]) { let prompt = this.page.getByPlaceholder(command.prompt || 'Type the name of a command to run'); await prompt.pressSequentially(command.command); @@ -90,4 +95,9 @@ export class CodespacePage { async openTabByName(name: string) { await this.page.getByRole('tab', { name: name }).locator('a').click(); } + + async openFileInEditor(name: string) { + await this.page.getByRole('treeitem', { name: name }).locator('a').click(); + await expect(this.page.locator('[id="workbench.parts.editor"]')).toContainText(name); + } } From 75020d9db447bc0d1cd978bdd734bc9768eb2d35 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:24:07 +0000 Subject: [PATCH 46/49] test: enable discovery of code smells --- .devcontainer/cpp/e2e/workspace/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.devcontainer/cpp/e2e/workspace/main.cpp b/.devcontainer/cpp/e2e/workspace/main.cpp index 8e31396b..37a56944 100644 --- a/.devcontainer/cpp/e2e/workspace/main.cpp +++ b/.devcontainer/cpp/e2e/workspace/main.cpp @@ -1,5 +1,10 @@ #include +void SmellyFunction() +{ + auto array = new int[10]; +} + int main() { std::cout << "Hello World!" << std::endl; From fe07e95f5bfdc135a180af163bfa46be432b79d3 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:17:19 +0000 Subject: [PATCH 47/49] docs: fix badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c169ac3f..f2b965dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # amp-devcontainer -[![Linting & Formatting](https://github.com/philips-software/amp-devcontainer/actions/workflows/linting-formatting.yml/badge.svg)](https://github.com/philips-software/amp-devcontainer/actions/workflows/linting-formatting.yml) [![Build & Push](https://github.com/philips-software/amp-devcontainer/actions/workflows/build-push.yml/badge.svg?branch=main)](https://github.com/philips-software/amp-devcontainer/actions/workflows/build-push.yml) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/philips-software/amp-devcontainer/badge)](https://securityscorecards.dev/viewer/?uri=github.com/philips-software/amp-devcontainer) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9267/badge)](https://www.bestpractices.dev/projects/9267) +[![Linting & Formatting](https://github.com/philips-software/amp-devcontainer/actions/workflows/linting-formatting.yml/badge.svg)](https://github.com/philips-software/amp-devcontainer/actions/workflows/linting-formatting.yml) [![Build & Push](https://github.com/philips-software/amp-devcontainer/actions/workflows/build-push.yml/badge.svg)](https://github.com/philips-software/amp-devcontainer/actions/workflows/build-push.yml) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9267/badge)](https://www.bestpractices.dev/projects/9267) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/philips-software/amp-devcontainer/badge)](https://securityscorecards.dev/viewer/?uri=github.com/philips-software/amp-devcontainer) ## Overview From 74c379c9809ca16230cc27f6ac11f923b4aa1826 Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:49:14 +0000 Subject: [PATCH 48/49] chore: reset IMAGE_VERSION after job completion --- .github/workflows/acceptance-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index 44b2924a..20bb9ecc 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -10,7 +10,6 @@ on: concurrency: group: ${{ github.workflow }} - cancel-in-progress: false permissions: contents: read @@ -44,7 +43,10 @@ jobs: GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} - - run: gh codespace delete --force --codespace "$CODESPACE_NAME" + - run: | + set -Eeuo pipefail + gh codespace delete --force --codespace "$CODESPACE_NAME" + gh secret set -a codespaces IMAGE_VERSION --body "latest" if: always() env: GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} From 47f5a785cfcd20a472d1386552b418dc4a312e9b Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:21:00 +0000 Subject: [PATCH 49/49] chore: update feature desktop-lite --- .devcontainer/cpp/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/cpp/devcontainer.json b/.devcontainer/cpp/devcontainer.json index a3ac95e8..565d067a 100644 --- a/.devcontainer/cpp/devcontainer.json +++ b/.devcontainer/cpp/devcontainer.json @@ -12,11 +12,11 @@ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], "features": { - "ghcr.io/devcontainers/features/desktop-lite:1.2.0": {}, + "ghcr.io/devcontainers/features/desktop-lite:1.2.4": {}, "ghcr.io/devcontainers/features/github-cli:1.0.13": {}, "ghcr.io/devcontainers/features/node:1.5.0": {} }, - "postCreateCommand": "npm install && npx playwright install-deps && npx playwright install", + "postCreateCommand": "npm install && npx playwright install --with-deps", "customizations": { "vscode": { "settings": {