From 18766e66459194b7d44db0ee29cae867a7522429 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 10:53:23 +0200 Subject: [PATCH 001/157] initial commit Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 057be6f..30f3399 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -16,7 +16,7 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - run-pytest: + run-tests: needs: run-provisioner-workflow runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: From 9e13fb6b4e8ec85283fe15deab95f4857ddb4cd1 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 10:55:44 +0200 Subject: [PATCH 002/157] added execute tests command Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 30f3399..4440d1f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,6 +36,7 @@ jobs: - name: Run tests run: | echo "Executing tests" + npx playwright test remove-ec2-runner: needs: [ run-provisioner-workflow,execute-script ] From 7f1e8f946bb677eec1c0621c6ad6688314c0162d Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 10:57:13 +0200 Subject: [PATCH 003/157] fixed wrong name Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4440d1f..e5cda65 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -39,7 +39,7 @@ jobs: npx playwright test remove-ec2-runner: - needs: [ run-provisioner-workflow,execute-script ] + needs: [ run-provisioner-workflow,run-tests ] uses: ./.github/workflows/remove-runner.yml with: ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} From 3badd741bb2834b469769c6e89e7a66619d9aba4 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 10:59:39 +0200 Subject: [PATCH 004/157] changed github token secret name to GH_RUNNER_API_TOKEN Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index e5cda65..0e0ecba 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -14,7 +14,7 @@ jobs: secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} run-tests: needs: run-provisioner-workflow From 96034ef4e6c95446adf34566cc1bec1347c990dd Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 11:30:44 +0200 Subject: [PATCH 005/157] install vscode script Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0e0ecba..72209f8 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -20,22 +20,36 @@ jobs: needs: run-provisioner-workflow runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: - - name: Install vscode + - name: Install dependencies run: | - echo "installing vscode" + sudo apt-get update + sudo apt-get install -y wget apt-transport-https + + - name: Install Visual Studio Code + run: | + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg + sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/ + sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list' + rm -f packages.microsoft.gpg + sudo apt-get update + sudo apt-get install -y code + + - name: Check VSCode installation + run: code --version + - name: Clone kai-ci repo run: | mkdir ./kai-ci-temp cd ./kai-ci-temp git clone https://github.com/konveyor/kai-ci.git cd kai-ci - echo "repo cloned" + - name: Install npm dependencies run: | npm install . + - name: Run tests run: | - echo "Executing tests" npx playwright test remove-ec2-runner: From d8000157e0efdcdcfc66bfa66bd52b709e4ad8ac Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 11:50:04 +0200 Subject: [PATCH 006/157] run `remove-ec2-runner` even if the run-tests failed Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 72209f8..957176f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -54,6 +54,7 @@ jobs: remove-ec2-runner: needs: [ run-provisioner-workflow,run-tests ] + if: always() uses: ./.github/workflows/remove-runner.yml with: ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} From a700c01248e8c415642c434b663c2084918836c7 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 12:53:53 +0200 Subject: [PATCH 007/157] fix token name Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 957176f..0f7d271 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -62,4 +62,4 @@ jobs: secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file From 600267d13b47cde9bb380a636e425324a92a4de3 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 19 Nov 2024 16:39:00 +0200 Subject: [PATCH 008/157] change script Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0f7d271..ec04400 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -20,19 +20,11 @@ jobs: needs: run-provisioner-workflow runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y wget apt-transport-https - name: Install Visual Studio Code run: | - wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg - sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/ - sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list' - rm -f packages.microsoft.gpg - sudo apt-get update - sudo apt-get install -y code + Invoke-WebRequest -Uri "https://update.code.visualstudio.com/latest/win32-x64-user/stable" -OutFile "$env:TEMP\vscode-installer.exe" + Start-Process -FilePath "$env:TEMP\vscode-installer.exe" -ArgumentList "/silent" -Wait - name: Check VSCode installation run: code --version From 0d3d3a2b7ca78b3da3c897a1831426faef5f48e9 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 21 Nov 2024 14:24:47 +0200 Subject: [PATCH 009/157] change script again Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index ec04400..f2b6c94 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,12 +21,13 @@ jobs: runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: - - name: Install Visual Studio Code + - name: Install Visual Studio Code using winget + shell: pwsh run: | - Invoke-WebRequest -Uri "https://update.code.visualstudio.com/latest/win32-x64-user/stable" -OutFile "$env:TEMP\vscode-installer.exe" - Start-Process -FilePath "$env:TEMP\vscode-installer.exe" -ArgumentList "/silent" -Wait + winget install -e --id Microsoft.VisualStudioCode -h --silent - name: Check VSCode installation + shell: pwsh run: code --version - name: Clone kai-ci repo From 1eaa3070397d2131e2c776e98517e3e7d8870dd5 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 21 Nov 2024 15:25:58 +0200 Subject: [PATCH 010/157] add shell specification Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index f2b6c94..b848afd 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -22,12 +22,12 @@ jobs: steps: - name: Install Visual Studio Code using winget - shell: pwsh + shell: powershell run: | winget install -e --id Microsoft.VisualStudioCode -h --silent - name: Check VSCode installation - shell: pwsh + shell: powershell run: code --version - name: Clone kai-ci repo From 8e7c2b2bd45efe96c9a24ff146e813b9a06bbe6f Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 21 Nov 2024 16:19:27 +0200 Subject: [PATCH 011/157] try different installation way Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index b848afd..8ca3c54 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,10 +21,12 @@ jobs: runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: - - name: Install Visual Studio Code using winget + - name: Install Visual Studio Code shell: powershell run: | - winget install -e --id Microsoft.VisualStudioCode -h --silent + $InstallerPath = "C:\vscode-installer.exe" + Invoke-WebRequest -Uri "https://update.code.visualstudio.com/latest/win32-x64-user/stable" -OutFile $InstallerPath + Start-Process -FilePath $InstallerPath -ArgumentList "/silent" -Wait - name: Check VSCode installation shell: powershell From 6ecd9eb2e5b490d4413bc74d2d60aa9a0b0c08ba Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 21 Nov 2024 17:37:53 +0200 Subject: [PATCH 012/157] added max retries Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 8ca3c54..dbc1cc1 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -25,8 +25,24 @@ jobs: shell: powershell run: | $InstallerPath = "C:\vscode-installer.exe" - Invoke-WebRequest -Uri "https://update.code.visualstudio.com/latest/win32-x64-user/stable" -OutFile $InstallerPath - Start-Process -FilePath $InstallerPath -ArgumentList "/silent" -Wait + $Uri = "https://update.code.visualstudio.com/latest/win32-x64-user/stable" + $RetryCount = 0 + $MaxRetries = 3 + $Success = $false + + while (-not $Success -and $RetryCount -lt $MaxRetries) { + try { + Invoke-WebRequest -Uri $Uri -OutFile $InstallerPath -TimeoutSec 60 + $Success = $true + } catch { + $RetryCount++ + Write-Output "Download failed. Retry $RetryCount of $MaxRetries..." + Start-Sleep -Seconds 10 + } + } + if (-not $Success) { + throw "Failed to download VSCode installer after $MaxRetries attempts." + } - name: Check VSCode installation shell: powershell From ef106ab0ec9c2b3bc8a8f2121b02e7a5522acac6 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 21 Nov 2024 17:56:55 +0200 Subject: [PATCH 013/157] install winget and try to use it to install vscode Signed-off-by: midays --- .github/workflows/provision-runner.yml | 13 ++++++++++++- .github/workflows/windows-nightly-ci.yml | 20 +------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 70a51d4..64d3481 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,4 +78,15 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" + + - name: Install winget (Windows only) + if: ${{ inputs.ec2-os-type == 'windows' }} + shell: powershell + run: | + $InstallerUrl = "https://aka.ms/MicrosoftAppInstaller" + $InstallerPath = "C:\appinstaller.appxbundle" + Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath + Add-AppxPackage -Path $InstallerPath + # Wait for winget to be available + Start-Sleep -Seconds 10 \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index dbc1cc1..0dac793 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -24,25 +24,7 @@ jobs: - name: Install Visual Studio Code shell: powershell run: | - $InstallerPath = "C:\vscode-installer.exe" - $Uri = "https://update.code.visualstudio.com/latest/win32-x64-user/stable" - $RetryCount = 0 - $MaxRetries = 3 - $Success = $false - - while (-not $Success -and $RetryCount -lt $MaxRetries) { - try { - Invoke-WebRequest -Uri $Uri -OutFile $InstallerPath -TimeoutSec 60 - $Success = $true - } catch { - $RetryCount++ - Write-Output "Download failed. Retry $RetryCount of $MaxRetries..." - Start-Sleep -Seconds 10 - } - } - if (-not $Success) { - throw "Failed to download VSCode installer after $MaxRetries attempts." - } + winget install -e --id Microsoft.VisualStudioCode - name: Check VSCode installation shell: powershell From 5ee2b32b58f78cbb2f699aaff6e5849fce1f163c Mon Sep 17 00:00:00 2001 From: midays Date: Sat, 23 Nov 2024 15:55:30 +0200 Subject: [PATCH 014/157] remove winget installation, assuming vscode is already installed Signed-off-by: midays --- .github/workflows/provision-runner.yml | 13 +------------ .github/workflows/windows-nightly-ci.yml | 5 ----- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 64d3481..70a51d4 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,15 +78,4 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" - - - name: Install winget (Windows only) - if: ${{ inputs.ec2-os-type == 'windows' }} - shell: powershell - run: | - $InstallerUrl = "https://aka.ms/MicrosoftAppInstaller" - $InstallerPath = "C:\appinstaller.appxbundle" - Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath - Add-AppxPackage -Path $InstallerPath - # Wait for winget to be available - Start-Sleep -Seconds 10 \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0dac793..df4c724 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,11 +21,6 @@ jobs: runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: - - name: Install Visual Studio Code - shell: powershell - run: | - winget install -e --id Microsoft.VisualStudioCode - - name: Check VSCode installation shell: powershell run: code --version From f7f27204febd77be94e5a16e7c00006e3dfc559a Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 01:53:28 +0200 Subject: [PATCH 015/157] print the env variable name to test if vscode is found and recognizable by the runner Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index df4c724..9ef025d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,11 +21,16 @@ jobs: runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} steps: + - name: Check Env PATH variable + shell: pwsh + run: echo $env:PATH + - name: Check VSCode installation - shell: powershell + shell: pwsh run: code --version - name: Clone kai-ci repo + shell: pwsh run: | mkdir ./kai-ci-temp cd ./kai-ci-temp @@ -33,10 +38,12 @@ jobs: cd kai-ci - name: Install npm dependencies + shell: pwsh run: | npm install . - name: Run tests + shell: pwsh run: | npx playwright test From d8a0863be338208a77f38b34260db69b58b31a67 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:02:00 +0200 Subject: [PATCH 016/157] change pwsh to powershell Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 9ef025d..a55d308 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -22,15 +22,15 @@ jobs: steps: - name: Check Env PATH variable - shell: pwsh + shell: powershell run: echo $env:PATH - name: Check VSCode installation - shell: pwsh + shell: powershell run: code --version - name: Clone kai-ci repo - shell: pwsh + shell: powershell run: | mkdir ./kai-ci-temp cd ./kai-ci-temp @@ -38,12 +38,12 @@ jobs: cd kai-ci - name: Install npm dependencies - shell: pwsh + shell: powershell run: | npm install . - name: Run tests - shell: pwsh + shell: powershell run: | npx playwright test From 70af6f412c4d57139cd5d0b1f601c9a9e2b23dbc Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:10:41 +0200 Subject: [PATCH 017/157] don't remove the vm [temp, will be removed manually, to test vscode installation directory] Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index a55d308..45b804d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -47,14 +47,14 @@ jobs: run: | npx playwright test - remove-ec2-runner: - needs: [ run-provisioner-workflow,run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file +# remove-ec2-runner: +# needs: [ run-provisioner-workflow,run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file From d913f7795e6852298caf0e9fb285783c9c969950 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:11:09 +0200 Subject: [PATCH 018/157] Revert "don't remove the vm [temp, will be removed manually, to test vscode installation directory]" This reverts commit 70af6f412c4d57139cd5d0b1f601c9a9e2b23dbc. --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 45b804d..a55d308 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -47,14 +47,14 @@ jobs: run: | npx playwright test -# remove-ec2-runner: -# needs: [ run-provisioner-workflow,run-tests ] -# if: always() -# uses: ./.github/workflows/remove-runner.yml -# with: -# ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} -# ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} -# secrets: -# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file + remove-ec2-runner: + needs: [ run-provisioner-workflow,run-tests ] + if: always() + uses: ./.github/workflows/remove-runner.yml + with: + ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} + ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} + secrets: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file From c7c4e452c6989210c5e374a3d79993f4216ea67a Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:11:23 +0200 Subject: [PATCH 019/157] don't remove the vm [temp, will be removed manually, to test vscode installation directory] Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index a55d308..45b804d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -47,14 +47,14 @@ jobs: run: | npx playwright test - remove-ec2-runner: - needs: [ run-provisioner-workflow,run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file +# remove-ec2-runner: +# needs: [ run-provisioner-workflow,run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file From c45068adcf08b470f7995882c4e2db67c3e96b56 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:44:30 +0200 Subject: [PATCH 020/157] stop instance after use, do initial installation Signed-off-by: midays --- .github/workflows/provision-runner.yml | 23 ++++++++++++++++- .github/workflows/windows-nightly-ci.yml | 33 ++++++++++++++---------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 70a51d4..7a1b83d 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,4 +78,25 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" + + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Verify Installations + run: | + code --version + node --version + shell: powershell \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 45b804d..85f94ff 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -3,7 +3,7 @@ name: Provision Windows VM using reusable workflow on: [push] jobs: - run-provisioner-workflow: + start-ec2-instance: uses: ./.github/workflows/provision-runner.yml with: ec2-image-id: ami-0b7d4973163feb944 @@ -17,10 +17,15 @@ jobs: github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} run-tests: - needs: run-provisioner-workflow - runs-on: ${{ needs.run-provisioner-workflow.outputs.instance_label }} + needs: start-ec2-instance + runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: + - name: Add VSCode to PATH + run: | + $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" + shell: powershell + - name: Check Env PATH variable shell: powershell run: echo $env:PATH @@ -47,14 +52,14 @@ jobs: run: | npx playwright test -# remove-ec2-runner: -# needs: [ run-provisioner-workflow,run-tests ] -# if: always() -# uses: ./.github/workflows/remove-runner.yml -# with: -# ec2-instance-id: ${{ needs.run-provisioner-workflow.outputs.ec2-instance-id }} -# ec2-runner-label: ${{ needs.run-provisioner-workflow.outputs.instance_label }} -# secrets: -# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file + stop-ec2-instance: + needs: [ start-ec2-instance,run-tests ] + if: always() + uses: ./.github/workflows/remove-runner.yml + with: + ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} + ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} + secrets: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file From c889e5b19f26c24e9df88dc3499f2d722f243bff Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:54:13 +0200 Subject: [PATCH 021/157] move installation Signed-off-by: midays --- .github/workflows/provision-runner.yml | 23 +--------------------- .github/workflows/windows-nightly-ci.yml | 25 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 7a1b83d..70a51d4 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,25 +78,4 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" - - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Verify Installations - run: | - code --version - node --version - shell: powershell \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 85f94ff..6fac0e5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,11 +21,32 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Add VSCode to PATH + - name: Install Chocolatey run: | - $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) shell: powershell + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Verify Installations + run: | + code --version + node --version + shell: powershell + +# - name: Add VSCode to PATH +# run: | +# $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" +# shell: powershell + - name: Check Env PATH variable shell: powershell run: echo $env:PATH From a0e3ade6cd8586b431502e8be16b3d00c15ef150 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:54:44 +0200 Subject: [PATCH 022/157] Revert "move installation" This reverts commit c889e5b19f26c24e9df88dc3499f2d722f243bff. --- .github/workflows/provision-runner.yml | 23 +++++++++++++++++++++- .github/workflows/windows-nightly-ci.yml | 25 ++---------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 70a51d4..7a1b83d 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,4 +78,25 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" + + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Verify Installations + run: | + code --version + node --version + shell: powershell \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 6fac0e5..85f94ff 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,32 +21,11 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey + - name: Add VSCode to PATH run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" shell: powershell - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Verify Installations - run: | - code --version - node --version - shell: powershell - -# - name: Add VSCode to PATH -# run: | -# $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" -# shell: powershell - - name: Check Env PATH variable shell: powershell run: echo $env:PATH From a54902921c62fac19b278134d6b022e43636c176 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 02:56:39 +0200 Subject: [PATCH 023/157] move installation Signed-off-by: midays --- .github/workflows/provision-runner.yml | 23 +--------------------- .github/workflows/windows-nightly-ci.yml | 25 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 7a1b83d..70a51d4 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,25 +78,4 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" - - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Verify Installations - run: | - code --version - node --version - shell: powershell \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 85f94ff..6fac0e5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,11 +21,32 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Add VSCode to PATH + - name: Install Chocolatey run: | - $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) shell: powershell + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Verify Installations + run: | + code --version + node --version + shell: powershell + +# - name: Add VSCode to PATH +# run: | +# $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" +# shell: powershell + - name: Check Env PATH variable shell: powershell run: echo $env:PATH From a2e23c138544461d647ac3dc9da30fe1210361d5 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 03:08:22 +0200 Subject: [PATCH 024/157] verify env path Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 6fac0e5..f6beb46 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,26 +21,26 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Verify Installations - run: | - code --version - node --version - shell: powershell +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Verify Installations +# run: | +# code --version +# node --version +# shell: powershell # - name: Add VSCode to PATH # run: | From fe8dac1cf37ce57c536acbedc52e9d8f7846ee8c Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 03:18:09 +0200 Subject: [PATCH 025/157] Add VSCode to PATH Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index f6beb46..1ed6bc5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -42,10 +42,10 @@ jobs: # node --version # shell: powershell -# - name: Add VSCode to PATH -# run: | -# $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" -# shell: powershell + - name: Add VSCode to PATH + run: | + $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" + shell: powershell - name: Check Env PATH variable shell: powershell From e42b759077d2bff4ca2e327bc8e64f291c111bec Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 04:47:45 +0200 Subject: [PATCH 026/157] check if installing vscode has affects Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 40 +++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 1ed6bc5..7d3039a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,26 +21,20 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Verify Installations -# run: | -# code --version -# node --version -# shell: powershell + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell - name: Add VSCode to PATH run: | @@ -51,9 +45,11 @@ jobs: shell: powershell run: echo $env:PATH - - name: Check VSCode installation + - name: Verify Installation + run: | + code --version + node --version shell: powershell - run: code --version - name: Clone kai-ci repo shell: powershell From 83178fcf8f6d8fcbd7d56e84ee67938cdd8f6f90 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 13:28:09 +0200 Subject: [PATCH 027/157] refresh environment Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 7d3039a..22fc72a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,9 +36,8 @@ jobs: run: choco install nodejs -y shell: powershell - - name: Add VSCode to PATH - run: | - $env:PATH = "C:\Program Files\Microsoft VS Code;$env:PATH" + - name: Refresh Environment Variables + run: refreshenv shell: powershell - name: Check Env PATH variable From 4a412b6d8ed00e2ee69f82d509da61c9de3c44b6 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 24 Nov 2024 13:54:52 +0200 Subject: [PATCH 028/157] remove installation, directly check vscode and nodeJS Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 32 +++++++++++------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 22fc72a..65edf78 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,24 +21,20 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Refresh Environment Variables - run: refreshenv - shell: powershell +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell - name: Check Env PATH variable shell: powershell From 37db59666fa727667149f42988cbc2f1d32fe6ad Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 13:10:28 +0200 Subject: [PATCH 029/157] check if the full path of the VSCODE works Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 65edf78..1c16e80 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,13 +36,18 @@ jobs: # run: choco install nodejs -y # shell: powershell +# - name: Update PATH for VSCode +# shell: powershell +# run: | +# $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" + - name: Check Env PATH variable shell: powershell run: echo $env:PATH - name: Verify Installation run: | - code --version + & "C:\Program Files\Microsoft VS Code\bin\code" --version node --version shell: powershell From 565572641775b67698c753c564e46a694c70bc0a Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 14:03:59 +0200 Subject: [PATCH 030/157] install vscode and check full path Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 1c16e80..9e6208f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,25 +21,25 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell -# - name: Update PATH for VSCode -# shell: powershell -# run: | -# $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Update PATH for VSCode + shell: powershell + run: | + $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" - name: Check Env PATH variable shell: powershell From 3f07c80ca6d615973389ab826dbcdb984894dd19 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 14:58:42 +0200 Subject: [PATCH 031/157] install node and check full path Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 9e6208f..d88a3ad 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -41,6 +41,10 @@ jobs: run: | $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" +# - name: Refresh PATH after Node.js Installation +# run: refreshenv +# shell: powershell + - name: Check Env PATH variable shell: powershell run: echo $env:PATH @@ -48,7 +52,7 @@ jobs: - name: Verify Installation run: | & "C:\Program Files\Microsoft VS Code\bin\code" --version - node --version + & "C:\Program Files\nodejs\node.exe" --version shell: powershell - name: Clone kai-ci repo From bd6a6bfd43065c6d61a81620b08a70f59f97eec9 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 15:14:27 +0200 Subject: [PATCH 032/157] check without installation Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d88a3ad..4bc69b5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,25 +21,25 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Update PATH for VSCode - shell: powershell - run: | - $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Update PATH for VSCode +# shell: powershell +# run: | +# $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" # - name: Refresh PATH after Node.js Installation # run: refreshenv From 923d52754b5cae44ad899c5953af1e3d83391f76 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 15:46:55 +0200 Subject: [PATCH 033/157] refresh env PATH var Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4bc69b5..3931cb2 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,29 +21,29 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Update PATH for VSCode -# shell: powershell -# run: | -# $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell -# - name: Refresh PATH after Node.js Installation -# run: refreshenv -# shell: powershell + - name: Update PATH for VSCode + shell: powershell + run: | + $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" + + - name: Refresh PATH after Node.js Installation + run: refreshenv + shell: powershell - name: Check Env PATH variable shell: powershell From 6c91e751f71dc0dd5379234a84d1a71e41c8a03c Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 16:15:23 +0200 Subject: [PATCH 034/157] Add Node.js and VSCode to PATH manually in GitHub Actions workflow - Manually add Node.js (`C:\Program Files\nodejs`) and VSCode (`C:\Program Files\Microsoft VS Code\bin`) to the PATH environment variable after installation. - Ensures both tools are available during subsequent steps in the GitHub Actions workflow. - Handles the absence of automatic PATH update in non-interactive environments like CI. Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 38 +++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 3931cb2..dc379f7 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,24 +36,42 @@ jobs: run: choco install nodejs -y shell: powershell - - name: Update PATH for VSCode + - name: Add VSCode and Node.js Manually to PATH shell: powershell run: | - $env:PATH += ";C:\Program Files\Microsoft VS Code\bin" - - - name: Refresh PATH after Node.js Installation - run: refreshenv - shell: powershell + $nodePath = 'C:\Program Files\nodejs' + if (-Not (Test-Path $nodePath)) { + Write-Error "Node.js installation path not found at: $nodePath" + exit 1 + } + $env:PATH += ";$nodePath" + + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + if (-Not (Test-Path $vscodePath)) { + Write-Error "VSCode installation path not found at: $vscodePath" + exit 1 + } + $env:PATH += ";$vscodePath" + + # Set the updated PATH variable at Machine level + [System.Environment]::SetEnvironmentVariable('PATH', $env:PATH, [System.EnvironmentVariableTarget]::Machine) + echo $env:PATH - name: Check Env PATH variable shell: powershell run: echo $env:PATH - - name: Verify Installation - run: | - & "C:\Program Files\Microsoft VS Code\bin\code" --version - & "C:\Program Files\nodejs\node.exe" --version +# - name: Verify Installation +# run: | +# & "C:\Program Files\Microsoft VS Code\bin\code" --version +# & "C:\Program Files\nodejs\node.exe" --version +# shell: powershell + + - name: Verify VSCode and Node.js Installation shell: powershell + run: | + code --version + node --version - name: Clone kai-ci repo shell: powershell From 7761d20866ea98a702432e98c1eccdb541f89669 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 16:30:29 +0200 Subject: [PATCH 035/157] refresh environment by importing module first Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index dc379f7..d541317 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,26 +36,11 @@ jobs: run: choco install nodejs -y shell: powershell - - name: Add VSCode and Node.js Manually to PATH + - name: Import Chocolatey Profile and Refresh Environment shell: powershell run: | - $nodePath = 'C:\Program Files\nodejs' - if (-Not (Test-Path $nodePath)) { - Write-Error "Node.js installation path not found at: $nodePath" - exit 1 - } - $env:PATH += ";$nodePath" - - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - if (-Not (Test-Path $vscodePath)) { - Write-Error "VSCode installation path not found at: $vscodePath" - exit 1 - } - $env:PATH += ";$vscodePath" - - # Set the updated PATH variable at Machine level - [System.Environment]::SetEnvironmentVariable('PATH', $env:PATH, [System.EnvironmentVariableTarget]::Machine) - echo $env:PATH + Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" + refreshenv - name: Check Env PATH variable shell: powershell From 841047438381eeb3be6e25063705805b817b30a7 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 17:37:35 +0200 Subject: [PATCH 036/157] static paths for vscode, nodejs, and npm Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 45 ++++++++++++++++-------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d541317..63a28b6 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,27 +36,44 @@ jobs: run: choco install nodejs -y shell: powershell - - name: Import Chocolatey Profile and Refresh Environment + - name: Define and Export Node.js and VSCode Paths shell: powershell run: | - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - refreshenv + # Define local variables for paths + $nodePath = 'C:\Program Files\nodejs' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + + # Check Node.js Path + if (-Not (Test-Path $nodePath)) { + Write-Error "Node.js installation path not found at: $nodePath" + exit 1 + } + # Check VSCode Path + if (-Not (Test-Path $vscodePath)) { + Write-Error "VSCode installation path not found at: $vscodePath" + exit 1 + } + + # Export the paths so they can be used in subsequent steps + "NODE_PATH=$nodePath" | Out-File -FilePath $env:GITHUB_ENV -Append + "VSCODE_PATH=$vscodePath" | Out-File -FilePath $env:GITHUB_ENV -Append - - name: Check Env PATH variable - shell: powershell - run: echo $env:PATH - -# - name: Verify Installation -# run: | -# & "C:\Program Files\Microsoft VS Code\bin\code" --version -# & "C:\Program Files\nodejs\node.exe" --version +# - name: Check Env PATH variable # shell: powershell +# run: echo $env:PATH + + - name: Verify Installation + run: | + & "C:\Program Files\Microsoft VS Code\bin\code" --version + & "C:\Program Files\nodejs\node.exe" --version + shell: powershell - name: Verify VSCode and Node.js Installation shell: powershell run: | - code --version - node --version + # Use the exported paths + & "$env:VSCODE_PATH\code.exe" --version + & "$env:NODE_PATH\node.exe" --version - name: Clone kai-ci repo shell: powershell @@ -69,7 +86,7 @@ jobs: - name: Install npm dependencies shell: powershell run: | - npm install . + & "$env:NODE_PATH\npm.cmd" install . - name: Run tests shell: powershell From 40d2257f29ad766a07585d5d5cdccd29271a6c88 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 17:44:59 +0200 Subject: [PATCH 037/157] set ENV PATH VAR Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 63a28b6..223bdfc 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -57,23 +57,29 @@ jobs: # Export the paths so they can be used in subsequent steps "NODE_PATH=$nodePath" | Out-File -FilePath $env:GITHUB_ENV -Append "VSCODE_PATH=$vscodePath" | Out-File -FilePath $env:GITHUB_ENV -Append + + # Also update PATH so that Node.js, npm, npx, and VSCode can be called directly + $newPath = "$env:PATH;$nodePath;$vscodePath" + [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + # Persist the updated PATH to make it available for subsequent steps + "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append # - name: Check Env PATH variable # shell: powershell # run: echo $env:PATH - - name: Verify Installation - run: | - & "C:\Program Files\Microsoft VS Code\bin\code" --version - & "C:\Program Files\nodejs\node.exe" --version - shell: powershell +# - name: Verify VSCode and Node.js Installation +# shell: powershell +# run: | +# # Use the exported paths +# & "$env:VSCODE_PATH\code.exe" --version +# & "$env:NODE_PATH\node.exe" --version - name: Verify VSCode and Node.js Installation shell: powershell run: | - # Use the exported paths - & "$env:VSCODE_PATH\code.exe" --version - & "$env:NODE_PATH\node.exe" --version + code --version + node --version - name: Clone kai-ci repo shell: powershell From 51df9352024cc41686786e1924c3078399cf61c8 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 17:56:39 +0200 Subject: [PATCH 038/157] remove unwanted code Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 35 ++++-------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 223bdfc..096e559 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,45 +36,20 @@ jobs: run: choco install nodejs -y shell: powershell - - name: Define and Export Node.js and VSCode Paths + - name: Define Node.js and VSCode Paths shell: powershell run: | - # Define local variables for paths + $nodePath = 'C:\Program Files\nodejs' $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - # Check Node.js Path - if (-Not (Test-Path $nodePath)) { - Write-Error "Node.js installation path not found at: $nodePath" - exit 1 - } - # Check VSCode Path - if (-Not (Test-Path $vscodePath)) { - Write-Error "VSCode installation path not found at: $vscodePath" - exit 1 - } - - # Export the paths so they can be used in subsequent steps - "NODE_PATH=$nodePath" | Out-File -FilePath $env:GITHUB_ENV -Append - "VSCODE_PATH=$vscodePath" | Out-File -FilePath $env:GITHUB_ENV -Append - - # Also update PATH so that Node.js, npm, npx, and VSCode can be called directly + # Update PATH so that Node.js, npm, npx, and VSCode can be called directly $newPath = "$env:PATH;$nodePath;$vscodePath" [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + # Persist the updated PATH to make it available for subsequent steps "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append -# - name: Check Env PATH variable -# shell: powershell -# run: echo $env:PATH - -# - name: Verify VSCode and Node.js Installation -# shell: powershell -# run: | -# # Use the exported paths -# & "$env:VSCODE_PATH\code.exe" --version -# & "$env:NODE_PATH\node.exe" --version - - name: Verify VSCode and Node.js Installation shell: powershell run: | @@ -92,7 +67,7 @@ jobs: - name: Install npm dependencies shell: powershell run: | - & "$env:NODE_PATH\npm.cmd" install . + npm install . - name: Run tests shell: powershell From ce65b911d7ed315b6647dc753f7da22b857f561e Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 18:21:02 +0200 Subject: [PATCH 039/157] add "./" before directory name` Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 096e559..4f05c44 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -62,7 +62,7 @@ jobs: mkdir ./kai-ci-temp cd ./kai-ci-temp git clone https://github.com/konveyor/kai-ci.git - cd kai-ci + cd ./kai-ci - name: Install npm dependencies shell: powershell From 82516634600271c5a9b32f42388da682a3c1d1b0 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 18:37:25 +0200 Subject: [PATCH 040/157] add working directory, and copy upload code from linux-nightly-ci Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4f05c44..5d1f438 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -62,17 +62,35 @@ jobs: mkdir ./kai-ci-temp cd ./kai-ci-temp git clone https://github.com/konveyor/kai-ci.git - cd ./kai-ci - name: Install npm dependencies shell: powershell + working-directory: ./kai-ci-temp/kai-ci run: | npm install . - name: Run tests shell: powershell + working-directory: ./kai-ci-temp/kai-ci run: | - npx playwright test + npx playwright test || true + + - name: Upload screenshots + uses: actions/upload-artifact@v4 + with: + name: vscode-screenshots + path: | + vscode-initialized-screenshot.png + kai-installed-screenshot.png + if: always() + + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 + stop-ec2-instance: needs: [ start-ec2-instance,run-tests ] From f44601dc117482b24fdba9ef670066a8118e6751 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 18:51:23 +0200 Subject: [PATCH 041/157] continue running workflow even if tests fail Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 5d1f438..b7b60b5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -73,7 +73,11 @@ jobs: shell: powershell working-directory: ./kai-ci-temp/kai-ci run: | - npx playwright test || true + try { + npx playwright test + } catch { + Write-Host "Playwright tests failed, but continuing workflow." # to continue running even if the tests run fail + } - name: Upload screenshots uses: actions/upload-artifact@v4 From 6c75f68f0dbbe1c1471dfbe6e8e62751cfdc85c9 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 19:07:25 +0200 Subject: [PATCH 042/157] close all vscode running instances Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index b7b60b5..70d3c1b 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -55,6 +55,11 @@ jobs: run: | code --version node --version + - name: Close All VSCode Instances + shell: powershell + run: | + # Close all running instances of VSCode + Get-Process -Name "Code" -ErrorAction SilentlyContinue | ForEach-Object { $_.CloseMainWindow() } | Out-Null - name: Clone kai-ci repo shell: powershell From a23ebf9cf37440c3b0138bb76074fa3633ab1335 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 21:44:53 +0200 Subject: [PATCH 043/157] change `npm install` to `npm ci`, and copy the .env.example to .env Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 70d3c1b..f2ec652 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -72,7 +72,11 @@ jobs: shell: powershell working-directory: ./kai-ci-temp/kai-ci run: | - npm install . + npm ci + + - name: Copy .env.example to .env + shell: powershell + run: Copy-Item -Path .env.example -Destination .env - name: Run tests shell: powershell From 7458a80089ee4a4f8a58fe901dd5de3db315afd4 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 21:56:40 +0200 Subject: [PATCH 044/157] re-added npm install before npm ci Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index f2ec652..0e0c337 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -72,6 +72,7 @@ jobs: shell: powershell working-directory: ./kai-ci-temp/kai-ci run: | + npm install . npm ci - name: Copy .env.example to .env From c1ecf2a75b33cfd6a17f69a7e5a910ebf9d1df29 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 22:09:06 +0200 Subject: [PATCH 045/157] Add working directory before copying .env.example Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0e0c337..63f9df8 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -77,6 +77,7 @@ jobs: - name: Copy .env.example to .env shell: powershell + working-directory: ./kai-ci-temp/kai-ci run: Copy-Item -Path .env.example -Destination .env - name: Run tests From 3135458f51bb236b1204b2ab50d91c26e1fb2b60 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 22:42:58 +0200 Subject: [PATCH 046/157] update executable path to match for windows Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 63f9df8..e6f7332 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -75,10 +75,12 @@ jobs: npm install . npm ci - - name: Copy .env.example to .env + - name: Copy .env.example to .env and update executable path shell: powershell working-directory: ./kai-ci-temp/kai-ci - run: Copy-Item -Path .env.example -Destination .env + run: | + Copy-Item -Path .env.example -Destination .env + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Users/$env:USERNAME/AppData/Local/Programs/Microsoft VS Code/Code.exe'" | Set-Content .env - name: Run tests shell: powershell From 7e9076ff537c340c9f91bebecd1390ba6ae75cfd Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 25 Nov 2024 23:03:39 +0200 Subject: [PATCH 047/157] Change executable path for vscode to match `Version 1.19.2` changes Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index e6f7332..6d25392 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -55,6 +55,7 @@ jobs: run: | code --version node --version + - name: Close All VSCode Instances shell: powershell run: | @@ -80,7 +81,7 @@ jobs: working-directory: ./kai-ci-temp/kai-ci run: | Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Users/$env:USERNAME/AppData/Local/Programs/Microsoft VS Code/Code.exe'" | Set-Content .env + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/bin/Code.exe'" | Set-Content .env - name: Run tests shell: powershell From b4d082cc68c589d5259a8948212d113a80460e83 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 00:25:12 +0200 Subject: [PATCH 048/157] remove `/bin` from executable directory Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 6d25392..cd571ec 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -81,7 +81,7 @@ jobs: working-directory: ./kai-ci-temp/kai-ci run: | Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/bin/Code.exe'" | Set-Content .env + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | Set-Content .env - name: Run tests shell: powershell @@ -109,6 +109,11 @@ jobs: path: playwright-report/ retention-days: 30 + - name: Clean Up Temporary Directory + shell: powershell + run: | + Remove-Item -Recurse -Force ./kai-ci-temp + stop-ec2-instance: needs: [ start-ec2-instance,run-tests ] From fb2abf2d2bca91a2a819d37e05cbad03ee76af33 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 00:40:19 +0200 Subject: [PATCH 049/157] updated the cleanup repo to work for windows Signed-off-by: midays --- e2e/utilities/utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/e2e/utilities/utils.ts b/e2e/utilities/utils.ts index 5a0b940..7b5e579 100644 --- a/e2e/utilities/utils.ts +++ b/e2e/utilities/utils.ts @@ -32,7 +32,13 @@ export function getKAIPluginName(): string { export async function cleanupRepo() { if (fs.existsSync(repoDir)) { try { - await execPromise(`rm -rf "${repoDir}"`); + if (getOSInfo() == 'windows') { + await execPromise( + `powershell.exe Remove-Item -Recurse -Force "${repoDir}"` + ); + } else { + await execPromise(`rm -rf "${repoDir}"`); + } } catch (error) { console.error('Error while cleaning up cloned repository:', error); } From 3c6254cb3b38d4ded0426846b4557fa18ab85b3a Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 00:59:56 +0200 Subject: [PATCH 050/157] remove change Signed-off-by: midays --- e2e/utilities/utils.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/e2e/utilities/utils.ts b/e2e/utilities/utils.ts index 7b5e579..5a0b940 100644 --- a/e2e/utilities/utils.ts +++ b/e2e/utilities/utils.ts @@ -32,13 +32,7 @@ export function getKAIPluginName(): string { export async function cleanupRepo() { if (fs.existsSync(repoDir)) { try { - if (getOSInfo() == 'windows') { - await execPromise( - `powershell.exe Remove-Item -Recurse -Force "${repoDir}"` - ); - } else { - await execPromise(`rm -rf "${repoDir}"`); - } + await execPromise(`rm -rf "${repoDir}"`); } catch (error) { console.error('Error while cleaning up cloned repository:', error); } From 87cd4f229bbc22a5617a15e744759fdc6d187f17 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 03:17:20 +0200 Subject: [PATCH 051/157] added if: always() Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index cd571ec..217f6de 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -113,6 +113,7 @@ jobs: shell: powershell run: | Remove-Item -Recurse -Force ./kai-ci-temp + if: always() stop-ec2-instance: From 5b45f7a7c2da06996a5e418a60bd7eee09e89e62 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 06:23:24 +0200 Subject: [PATCH 052/157] Change step name Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 217f6de..202a7c6 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -109,7 +109,7 @@ jobs: path: playwright-report/ retention-days: 30 - - name: Clean Up Temporary Directory + - name: Clean Up Kai Temp Directory shell: powershell run: | Remove-Item -Recurse -Force ./kai-ci-temp From 8ee121fc13a841c665ab0d15c48496a9020c3619 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 07:20:59 +0200 Subject: [PATCH 053/157] use ami-01fa2492704e48175, and comment installation blocks Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 202a7c6..62d011b 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -6,7 +6,7 @@ jobs: start-ec2-instance: uses: ./.github/workflows/provision-runner.yml with: - ec2-image-id: ami-0b7d4973163feb944 + ec2-image-id: ami-01fa2492704e48175 ec2-instance-type: t2.micro security-group-id: sg-0a3e6b53e86d0e69d subnet-id: subnet-06113672589e7e836 @@ -21,34 +21,34 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Define Node.js and VSCode Paths - shell: powershell - run: | - - $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - - # Update PATH so that Node.js, npm, npx, and VSCode can be called directly - $newPath = "$env:PATH;$nodePath;$vscodePath" - [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - - # Persist the updated PATH to make it available for subsequent steps - "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Define Node.js and VSCode Paths +# shell: powershell +# run: | +# +# $nodePath = 'C:\Program Files\nodejs' +# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' +# +# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly +# $newPath = "$env:PATH;$nodePath;$vscodePath" +# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) +# +# # Persist the updated PATH to make it available for subsequent steps +# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Verify VSCode and Node.js Installation shell: powershell From fe708311946c9ca48c6b95c5bdb2fc136a0c8d2f Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 12:53:02 +0200 Subject: [PATCH 054/157] un-comment the installation code blocks Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 62d011b..ac92b6c 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,34 +21,34 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Define Node.js and VSCode Paths -# shell: powershell -# run: | -# -# $nodePath = 'C:\Program Files\nodejs' -# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' -# -# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly -# $newPath = "$env:PATH;$nodePath;$vscodePath" -# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) -# -# # Persist the updated PATH to make it available for subsequent steps -# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Define Node.js and VSCode Paths + shell: powershell + run: | + + $nodePath = 'C:\Program Files\nodejs' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + + # Update PATH so that Node.js, npm, npx, and VSCode can be called directly + $newPath = "$env:PATH;$nodePath;$vscodePath" + [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + + # Persist the updated PATH to make it available for subsequent steps + "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Verify VSCode and Node.js Installation shell: powershell From 00673cb037a553609b431299772380e65d9c6895 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:09:02 +0200 Subject: [PATCH 055/157] try to run script as non-admin user without the installation steps Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 64 ++++++++++++++---------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index ac92b6c..e72bca6 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -11,6 +11,13 @@ jobs: security-group-id: sg-0a3e6b53e86d0e69d subnet-id: subnet-06113672589e7e836 ec2-os-type: windows + user-data: | + + # Enable nonadmin user, set it as the default login, and set its password + net user nonadmin /active:yes + net user nonadmin ${{ secrets.NONADMIN_PASSWORD }} + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force + secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -21,34 +28,39 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Define Node.js and VSCode Paths +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Define Node.js and VSCode Paths +# shell: powershell +# run: | +# +# $nodePath = 'C:\Program Files\nodejs' +# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' +# +# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly +# $newPath = "$env:PATH;$nodePath;$vscodePath" +# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) +# +# # Persist the updated PATH to make it available for subsequent steps +# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Print PATH Environment Variable shell: powershell run: | - - $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - - # Update PATH so that Node.js, npm, npx, and VSCode can be called directly - $newPath = "$env:PATH;$nodePath;$vscodePath" - [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - - # Persist the updated PATH to make it available for subsequent steps - "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + Write-Output "Updated PATH: $env:PATH" - name: Verify VSCode and Node.js Installation shell: powershell From f93f38e986dd5ed116754cef3afa737e288ed90b Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:26:07 +0200 Subject: [PATCH 056/157] try with static password Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index e72bca6..273246f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -15,7 +15,7 @@ jobs: # Enable nonadmin user, set it as the default login, and set its password net user nonadmin /active:yes - net user nonadmin ${{ secrets.NONADMIN_PASSWORD }} + net user nonadmin Dog8code New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force secrets: From 3899d0f702b5f008367c6b7dcc231d596bef1b07 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:28:31 +0200 Subject: [PATCH 057/157] try with configure-instance block Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 273246f..2c3907e 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -11,17 +11,27 @@ jobs: security-group-id: sg-0a3e6b53e86d0e69d subnet-id: subnet-06113672589e7e836 ec2-os-type: windows - user-data: | - - # Enable nonadmin user, set it as the default login, and set its password - net user nonadmin /active:yes - net user nonadmin Dog8code - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force - secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + configure-instance: + needs: start-ec2-instance + runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} + env: + NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} + steps: + - name: Set nonadmin user password and configure auto-login + shell: powershell + run: | + # Enable nonadmin user and set password + net user nonadmin /active:yes + net user nonadmin $env:NONADMIN_PASSWORD + + # Set nonadmin as default login and enable auto login + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force + run-tests: needs: start-ec2-instance From 9209982583d9acae8a07d56b50d17646ebf9c9a0 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:28:43 +0200 Subject: [PATCH 058/157] Revert "try with configure-instance block" This reverts commit 3899d0f702b5f008367c6b7dcc231d596bef1b07. --- .github/workflows/windows-nightly-ci.yml | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2c3907e..273246f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -11,27 +11,17 @@ jobs: security-group-id: sg-0a3e6b53e86d0e69d subnet-id: subnet-06113672589e7e836 ec2-os-type: windows + user-data: | + + # Enable nonadmin user, set it as the default login, and set its password + net user nonadmin /active:yes + net user nonadmin Dog8code + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force + secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} - configure-instance: - needs: start-ec2-instance - runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} - env: - NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} - steps: - - name: Set nonadmin user password and configure auto-login - shell: powershell - run: | - # Enable nonadmin user and set password - net user nonadmin /active:yes - net user nonadmin $env:NONADMIN_PASSWORD - - # Set nonadmin as default login and enable auto login - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force - run-tests: needs: start-ec2-instance From 6322a75711a0ef403ddce46862efb4e9f1891ab5 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:29:21 +0200 Subject: [PATCH 059/157] try with configure-instance block Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 273246f..2c3907e 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -11,17 +11,27 @@ jobs: security-group-id: sg-0a3e6b53e86d0e69d subnet-id: subnet-06113672589e7e836 ec2-os-type: windows - user-data: | - - # Enable nonadmin user, set it as the default login, and set its password - net user nonadmin /active:yes - net user nonadmin Dog8code - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force - secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + configure-instance: + needs: start-ec2-instance + runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} + env: + NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} + steps: + - name: Set nonadmin user password and configure auto-login + shell: powershell + run: | + # Enable nonadmin user and set password + net user nonadmin /active:yes + net user nonadmin $env:NONADMIN_PASSWORD + + # Set nonadmin as default login and enable auto login + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force + run-tests: needs: start-ec2-instance From ded55b215bdafaf05ce4268aa3e31c00b73815e7 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:37:59 +0200 Subject: [PATCH 060/157] make the run-tests block require configure-instance to complete Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2c3907e..7e9e843 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -15,6 +15,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + configure-instance: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} @@ -34,7 +35,7 @@ jobs: run-tests: - needs: start-ec2-instance + needs: configure-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: From b984ad15e30332c748be1d7cda8d0cd276172e44 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 15:50:21 +0200 Subject: [PATCH 061/157] change needs Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 7e9e843..9bd118b 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -35,7 +35,7 @@ jobs: run-tests: - needs: configure-instance + needs: [start-ec2-instance, configure-instance] runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: From fdec814ee3cd0fc9c605b272a062642818ceef96 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 16:00:09 +0200 Subject: [PATCH 062/157] Update the workflow to include a step that explicitly switches the session to nonadmin before proceeding with other steps Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 42 ++++++++++++++++-------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 9bd118b..c5de000 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -16,28 +16,42 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} - configure-instance: +# configure-instance: +# needs: start-ec2-instance +# runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} +# env: +# NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} +# steps: +# - name: Set nonadmin user password and configure auto-login +# shell: powershell +# run: | +# # Enable nonadmin user and set password +# net user nonadmin /active:yes +# net user nonadmin $env:NONADMIN_PASSWORD +# +# # Set nonadmin as default login and enable auto login +# New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force +# New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force + + + run-tests: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} env: NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} steps: - - name: Set nonadmin user password and configure auto-login + + - name: Set nonadmin Password shell: powershell run: | - # Enable nonadmin user and set password - net user nonadmin /active:yes - net user nonadmin $env:NONADMIN_PASSWORD + net user nonadmin $env:NONADMIN_PASSWORD - # Set nonadmin as default login and enable auto login - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force - - - run-tests: - needs: [start-ec2-instance, configure-instance] - runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} - steps: + - name: Switch to nonadmin User + shell: powershell + run: | + $password = ConvertTo-SecureString -String $env:NONADMIN_PASSWORD -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential('nonadmin', $password) + Start-Process -FilePath "powershell.exe" -ArgumentList "-NoExit" -Credential $credential # - name: Install Chocolatey # run: | From d915c0cfc741d69654197680d73363ed31279110 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 26 Nov 2024 16:11:35 +0200 Subject: [PATCH 063/157] revert Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 74 ++++++++++++------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index c5de000..17b7cbf 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -37,50 +37,50 @@ jobs: run-tests: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} - env: - NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} +# env: +# NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} steps: - - name: Set nonadmin Password - shell: powershell +# - name: Set nonadmin Password +# shell: powershell +# run: | +# net user nonadmin $env:NONADMIN_PASSWORD +# +# - name: Switch to nonadmin User +# shell: powershell +# run: | +# $password = ConvertTo-SecureString -String $env:NONADMIN_PASSWORD -AsPlainText -Force +# $credential = New-Object System.Management.Automation.PSCredential('nonadmin', $password) +# Start-Process powershell -ArgumentList "-NoExit -Command `"Set-ExecutionPolicy Bypass -Scope Process; Invoke-Expression -Command .\test_script.ps1`"" -Credential $credential + + - name: Install Chocolatey run: | - net user nonadmin $env:NONADMIN_PASSWORD + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell - - name: Switch to nonadmin User + - name: Define Node.js and VSCode Paths shell: powershell run: | - $password = ConvertTo-SecureString -String $env:NONADMIN_PASSWORD -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential('nonadmin', $password) - Start-Process -FilePath "powershell.exe" -ArgumentList "-NoExit" -Credential $credential -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Define Node.js and VSCode Paths -# shell: powershell -# run: | -# -# $nodePath = 'C:\Program Files\nodejs' -# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' -# -# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly -# $newPath = "$env:PATH;$nodePath;$vscodePath" -# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) -# -# # Persist the updated PATH to make it available for subsequent steps -# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + $nodePath = 'C:\Program Files\nodejs' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + + # Update PATH so that Node.js, npm, npx, and VSCode can be called directly + $newPath = "$env:PATH;$nodePath;$vscodePath" + [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + + # Persist the updated PATH to make it available for subsequent steps + "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Print PATH Environment Variable shell: powershell From 8bf6d534174f2075e6a320a0994c406a64a64e88 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 08:42:29 +0200 Subject: [PATCH 064/157] configure the runner to default to non-admin user when executing in the VM Signed-off-by: midays --- .github/workflows/provision-runner.yml | 33 +++++++++- .github/workflows/windows-nightly-ci.yml | 80 +++++++----------------- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 70a51d4..e4e4f31 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -78,4 +78,35 @@ jobs: - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" - echo "Label : ${{ steps.ec2.outputs.label }}" \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" + + configure-ec2: + needs: provision-ec2 + runs-on: ${{ needs.provision-ec2.outputs.label }} + steps: + - name: Set Default Login to Non-Admin User (Windows Specific) + if: ${{ inputs.ec2-os-type == 'windows' }} + shell: powershell + run: | + # Enable nonadmin user and set as default login + net user nonadmin /active:yes + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f + + - name: Configure GitHub Runner Service to Run as Non-Admin User + if: ${{ inputs.ec2-os-type == 'windows' }} + shell: powershell + env: + NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} + run: | + # Stop the GitHub Actions Runner service + Stop-Service actions.runner.* + + # Update the service to use the nonadmin user credentials + $serviceName = Get-Service | Where-Object { $_.Name -like 'actions.runner.*' } | Select-Object -ExpandProperty Name + $username = "nonadmin" + $password = $env:NONADMIN_PASSWORD + sc.exe config $serviceName obj= ".\$username" password= "$password" + + # Start the GitHub Actions Runner service again + Start-Service $serviceName \ No newline at end of file diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 17b7cbf..d456fa1 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -16,71 +16,39 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} -# configure-instance: -# needs: start-ec2-instance -# runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} -# env: -# NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} -# steps: -# - name: Set nonadmin user password and configure auto-login -# shell: powershell -# run: | -# # Enable nonadmin user and set password -# net user nonadmin /active:yes -# net user nonadmin $env:NONADMIN_PASSWORD -# -# # Set nonadmin as default login and enable auto login -# New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "nonadmin" -Force -# New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -Force - - run-tests: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} -# env: -# NONADMIN_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }} steps: -# - name: Set nonadmin Password -# shell: powershell +# - name: Install Chocolatey # run: | -# net user nonadmin $env:NONADMIN_PASSWORD +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell # -# - name: Switch to nonadmin User +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Define Node.js and VSCode Paths # shell: powershell # run: | -# $password = ConvertTo-SecureString -String $env:NONADMIN_PASSWORD -AsPlainText -Force -# $credential = New-Object System.Management.Automation.PSCredential('nonadmin', $password) -# Start-Process powershell -ArgumentList "-NoExit -Command `"Set-ExecutionPolicy Bypass -Scope Process; Invoke-Expression -Command .\test_script.ps1`"" -Credential $credential - - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Define Node.js and VSCode Paths - shell: powershell - run: | - - $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - - # Update PATH so that Node.js, npm, npx, and VSCode can be called directly - $newPath = "$env:PATH;$nodePath;$vscodePath" - [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - - # Persist the updated PATH to make it available for subsequent steps - "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append +# +# $nodePath = 'C:\Program Files\nodejs' +# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' +# +# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly +# $newPath = "$env:PATH;$nodePath;$vscodePath" +# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) +# +# # Persist the updated PATH to make it available for subsequent steps +# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Print PATH Environment Variable shell: powershell From caf18e560d70d53e889a486bcaf62e921f74dec0 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 08:56:38 +0200 Subject: [PATCH 065/157] change approach Signed-off-by: midays --- .github/workflows/provision-runner.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index e4e4f31..bdea2e5 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -100,13 +100,20 @@ jobs: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | # Stop the GitHub Actions Runner service - Stop-Service actions.runner.* + $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found." + exit 1 + } + + # Stop the GitHub Actions Runner service + Stop-Service -Name $serviceName -Force # Update the service to use the nonadmin user credentials - $serviceName = Get-Service | Where-Object { $_.Name -like 'actions.runner.*' } | Select-Object -ExpandProperty Name $username = "nonadmin" $password = $env:NONADMIN_PASSWORD sc.exe config $serviceName obj= ".\$username" password= "$password" # Start the GitHub Actions Runner service again - Start-Service $serviceName \ No newline at end of file + Start-Service -Name $serviceName From 2143757ca7fa30827939d6c3302fa050e0885b0f Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 09:17:13 +0200 Subject: [PATCH 066/157] remove non-admin runner configuration for now Signed-off-by: midays --- .github/workflows/provision-runner.yml | 74 +++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index bdea2e5..973819e 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -80,40 +80,40 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" - configure-ec2: - needs: provision-ec2 - runs-on: ${{ needs.provision-ec2.outputs.label }} - steps: - - name: Set Default Login to Non-Admin User (Windows Specific) - if: ${{ inputs.ec2-os-type == 'windows' }} - shell: powershell - run: | - # Enable nonadmin user and set as default login - net user nonadmin /active:yes - reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f - reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f - - - name: Configure GitHub Runner Service to Run as Non-Admin User - if: ${{ inputs.ec2-os-type == 'windows' }} - shell: powershell - env: - NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} - run: | - # Stop the GitHub Actions Runner service - $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found." - exit 1 - } - - # Stop the GitHub Actions Runner service - Stop-Service -Name $serviceName -Force - - # Update the service to use the nonadmin user credentials - $username = "nonadmin" - $password = $env:NONADMIN_PASSWORD - sc.exe config $serviceName obj= ".\$username" password= "$password" - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName +# configure-ec2: +# needs: provision-ec2 +# runs-on: ${{ needs.provision-ec2.outputs.label }} +# steps: +# - name: Set Default Login to Non-Admin User (Windows Specific) +# if: ${{ inputs.ec2-os-type == 'windows' }} +# shell: powershell +# run: | +# # Enable nonadmin user and set as default login +# net user nonadmin /active:yes +# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f +# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f +# +# - name: Configure GitHub Runner Service to Run as Non-Admin User +# if: ${{ inputs.ec2-os-type == 'windows' }} +# shell: powershell +# env: +# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} +# run: | +# # Stop the GitHub Actions Runner service +# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name +# +# if (-not $serviceName) { +# Write-Error "GitHub Actions runner service not found." +# exit 1 +# } +# +# # Stop the GitHub Actions Runner service +# Stop-Service -Name $serviceName -Force +# +# # Update the service to use the nonadmin user credentials +# $username = "nonadmin" +# $password = $env:NONADMIN_PASSWORD +# sc.exe config $serviceName obj= ".\$username" password= "$password" +# +# # Start the GitHub Actions Runner service again +# Start-Service -Name $serviceName From 1629e05da51a72099ec98526abf07247a4d76765 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 09:35:17 +0200 Subject: [PATCH 067/157] re add installations Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d456fa1..22d33b3 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,34 +21,34 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell -# -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Define Node.js and VSCode Paths -# shell: powershell -# run: | -# -# $nodePath = 'C:\Program Files\nodejs' -# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' -# -# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly -# $newPath = "$env:PATH;$nodePath;$vscodePath" -# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) -# -# # Persist the updated PATH to make it available for subsequent steps -# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell + + - name: Define Node.js and VSCode Paths + shell: powershell + run: | + + $nodePath = 'C:\Program Files\nodejs' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + + # Update PATH so that Node.js, npm, npx, and VSCode can be called directly + $newPath = "$env:PATH;$nodePath;$vscodePath" + [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + + # Persist the updated PATH to make it available for subsequent steps + "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Print PATH Environment Variable shell: powershell From 7cfe6043d2343e73aaa0df846e473e376c672168 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 10:54:23 +0200 Subject: [PATCH 068/157] Change working directory to avoid permission error Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 22d33b3..e90b36f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -67,30 +67,35 @@ jobs: # Close all running instances of VSCode Get-Process -Name "Code" -ErrorAction SilentlyContinue | ForEach-Object { $_.CloseMainWindow() } | Out-Null + - name: Create Temporary Work Directory + shell: powershell + run: | + # Creating a directory outside System32 for better permissions + New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force + - name: Clone kai-ci repo shell: powershell run: | - mkdir ./kai-ci-temp - cd ./kai-ci-temp + cd C:\actions-runner\work git clone https://github.com/konveyor/kai-ci.git - name: Install npm dependencies shell: powershell - working-directory: ./kai-ci-temp/kai-ci + working-directory: C:\actions-runner\work\kai-ci run: | npm install . npm ci - name: Copy .env.example to .env and update executable path shell: powershell - working-directory: ./kai-ci-temp/kai-ci + working-directory: C:\actions-runner\work\kai-ci run: | Copy-Item -Path .env.example -Destination .env (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | Set-Content .env - name: Run tests shell: powershell - working-directory: ./kai-ci-temp/kai-ci + working-directory: C:\actions-runner\work\kai-ci run: | try { npx playwright test @@ -117,7 +122,7 @@ jobs: - name: Clean Up Kai Temp Directory shell: powershell run: | - Remove-Item -Recurse -Force ./kai-ci-temp + Remove-Item -Recurse -Force C:\actions-runner\work\kai-ci if: always() @@ -131,4 +136,4 @@ jobs: secrets: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From a26aa59320ace7053a74c0a4b5bb8238d8b38c9d Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 13:40:27 +0200 Subject: [PATCH 069/157] try to update test results Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index e90b36f..aa13b13 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -115,8 +115,8 @@ jobs: - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: - name: playwright-report - path: playwright-report/ + name: test-results + path: test-results/ retention-days: 30 - name: Clean Up Kai Temp Directory From bd45bbdd84f93e0ba79a90aa9de8849bbaeec126 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 15:09:14 +0200 Subject: [PATCH 070/157] don't remove instance after starting the job Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index aa13b13..398548a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -126,14 +126,14 @@ jobs: if: always() - stop-ec2-instance: - needs: [ start-ec2-instance,run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} +# stop-ec2-instance: +# needs: [ start-ec2-instance,run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From bb9069b1191e5ffb5a54fb7b880a71b17879732b Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 16:14:04 +0200 Subject: [PATCH 071/157] run again with new password secret Signed-off-by: midays --- .github/workflows/provision-runner.yml | 74 +++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 973819e..ac711c9 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -80,40 +80,40 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" -# configure-ec2: -# needs: provision-ec2 -# runs-on: ${{ needs.provision-ec2.outputs.label }} -# steps: -# - name: Set Default Login to Non-Admin User (Windows Specific) -# if: ${{ inputs.ec2-os-type == 'windows' }} -# shell: powershell -# run: | -# # Enable nonadmin user and set as default login -# net user nonadmin /active:yes -# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f -# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f -# -# - name: Configure GitHub Runner Service to Run as Non-Admin User -# if: ${{ inputs.ec2-os-type == 'windows' }} -# shell: powershell -# env: -# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} -# run: | -# # Stop the GitHub Actions Runner service -# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -# -# if (-not $serviceName) { -# Write-Error "GitHub Actions runner service not found." -# exit 1 -# } -# -# # Stop the GitHub Actions Runner service -# Stop-Service -Name $serviceName -Force -# -# # Update the service to use the nonadmin user credentials -# $username = "nonadmin" -# $password = $env:NONADMIN_PASSWORD -# sc.exe config $serviceName obj= ".\$username" password= "$password" -# -# # Start the GitHub Actions Runner service again -# Start-Service -Name $serviceName + configure-ec2: + needs: provision-ec2 + runs-on: ${{ needs.provision-ec2.outputs.label }} + steps: + - name: Set Default Login to Non-Admin User (Windows Specific) + if: ${{ inputs.ec2-os-type == 'windows' }} + shell: powershell + run: | + # Enable nonadmin user and set as default login + net user nonadmin /active:yes + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f + + - name: Configure GitHub Runner Service to Run as Non-Admin User + if: ${{ inputs.ec2-os-type == 'windows' }} + shell: powershell + env: + NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} + run: | + # Stop the GitHub Actions Runner service + $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found." + exit 1 + } + + # Stop the GitHub Actions Runner service + Stop-Service -Name $serviceName -Force + + # Update the service to use the nonadmin user credentials + $username = "nonadmin" + $password = $env:NONADMIN_PASSWORD + sc.exe config $serviceName obj= ".\$username" password= "$password" + + # Start the GitHub Actions Runner service again + Start-Service -Name $serviceName From e1cc52dfb10b7ab909175ad0de4cbb348c8fe3ba Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 16:15:04 +0200 Subject: [PATCH 072/157] no installation Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 398548a..9b15243 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,34 +21,34 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install VSCode - run: choco install vscode -y - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y - shell: powershell - - - name: Define Node.js and VSCode Paths - shell: powershell - run: | - - $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - - # Update PATH so that Node.js, npm, npx, and VSCode can be called directly - $newPath = "$env:PATH;$nodePath;$vscodePath" - [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - - # Persist the updated PATH to make it available for subsequent steps - "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append +# - name: Install Chocolatey +# run: | +# Set-ExecutionPolicy Bypass -Scope Process -Force; +# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# shell: powershell +# +# - name: Install VSCode +# run: choco install vscode -y +# shell: powershell +# +# - name: Install Node.js +# run: choco install nodejs -y +# shell: powershell +# +# - name: Define Node.js and VSCode Paths +# shell: powershell +# run: | +# +# $nodePath = 'C:\Program Files\nodejs' +# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' +# +# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly +# $newPath = "$env:PATH;$nodePath;$vscodePath" +# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) +# +# # Persist the updated PATH to make it available for subsequent steps +# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Print PATH Environment Variable shell: powershell From 48f56f3ac1d7d96013fe1a42e0038ca5befe8310 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 16:53:49 +0200 Subject: [PATCH 073/157] remove setting default admin, print the current user, check if vscode, nodejs installed Signed-off-by: midays --- .github/workflows/provision-runner.yml | 74 ++++++++++++------------ .github/workflows/windows-nightly-ci.yml | 37 ++++++++++++ 2 files changed, 74 insertions(+), 37 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index ac711c9..973819e 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -80,40 +80,40 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" - configure-ec2: - needs: provision-ec2 - runs-on: ${{ needs.provision-ec2.outputs.label }} - steps: - - name: Set Default Login to Non-Admin User (Windows Specific) - if: ${{ inputs.ec2-os-type == 'windows' }} - shell: powershell - run: | - # Enable nonadmin user and set as default login - net user nonadmin /active:yes - reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f - reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f - - - name: Configure GitHub Runner Service to Run as Non-Admin User - if: ${{ inputs.ec2-os-type == 'windows' }} - shell: powershell - env: - NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} - run: | - # Stop the GitHub Actions Runner service - $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found." - exit 1 - } - - # Stop the GitHub Actions Runner service - Stop-Service -Name $serviceName -Force - - # Update the service to use the nonadmin user credentials - $username = "nonadmin" - $password = $env:NONADMIN_PASSWORD - sc.exe config $serviceName obj= ".\$username" password= "$password" - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName +# configure-ec2: +# needs: provision-ec2 +# runs-on: ${{ needs.provision-ec2.outputs.label }} +# steps: +# - name: Set Default Login to Non-Admin User (Windows Specific) +# if: ${{ inputs.ec2-os-type == 'windows' }} +# shell: powershell +# run: | +# # Enable nonadmin user and set as default login +# net user nonadmin /active:yes +# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f +# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f +# +# - name: Configure GitHub Runner Service to Run as Non-Admin User +# if: ${{ inputs.ec2-os-type == 'windows' }} +# shell: powershell +# env: +# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} +# run: | +# # Stop the GitHub Actions Runner service +# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name +# +# if (-not $serviceName) { +# Write-Error "GitHub Actions runner service not found." +# exit 1 +# } +# +# # Stop the GitHub Actions Runner service +# Stop-Service -Name $serviceName -Force +# +# # Update the service to use the nonadmin user credentials +# $username = "nonadmin" +# $password = $env:NONADMIN_PASSWORD +# sc.exe config $serviceName obj= ".\$username" password= "$password" +# +# # Start the GitHub Actions Runner service again +# Start-Service -Name $serviceName diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 9b15243..bf86c8a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -50,6 +50,43 @@ jobs: # # Persist the updated PATH to make it available for subsequent steps # "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + - name: Check Visual Studio Code and Node.js Installation Paths + shell: powershell + run: | + # Check if Visual Studio Code is installed and print the installation path + $vscodePaths = @( + 'C:\Program Files\Microsoft VS Code\Code.exe', + 'C:\Users\*\AppData\Local\Programs\Microsoft VS Code\Code.exe' + ) + + $vscodeInstalled = $false + foreach ($path in $vscodePaths) { + $resolvedPaths = Get-ChildItem -Path $path -ErrorAction SilentlyContinue + foreach ($resolvedPath in $resolvedPaths) { + Write-Output "VSCode is installed at: $($resolvedPath.FullName)" + $vscodeInstalled = $true + } + } + + if (-not $vscodeInstalled) { + Write-Output "VSCode is not installed." + } + + # Check if Node.js is installed and print the installation path + try { + $nodejsPath = (& where.exe node) + Write-Output "Node.js is installed at: $nodejsPath" + } catch { + Write-Output "Node.js is not installed." + } + + - name: Print Current Logged-In User + shell: powershell + run: | + # Print the current logged-in user + Write-Output "Current User: $(whoami)" + Write-Output "Environment User: $env:USERNAME" + - name: Print PATH Environment Variable shell: powershell run: | From 0495c54cfea2a90333ebe0bfd79f3a771dcb5bf4 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 18:22:21 +0200 Subject: [PATCH 074/157] use existing VSCode.exe Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 99 ++++++++++++------------ 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index bf86c8a..d9f230d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,64 +21,65 @@ jobs: runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: -# - name: Install Chocolatey -# run: | -# Set-ExecutionPolicy Bypass -Scope Process -Force; -# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; -# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# shell: powershell -# + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + shell: powershell + # - name: Install VSCode # run: choco install vscode -y # shell: powershell + + - name: Install Node.js + run: choco install nodejs -y + shell: powershell # -# - name: Install Node.js -# run: choco install nodejs -y -# shell: powershell -# -# - name: Define Node.js and VSCode Paths + - name: Define Node.js and VSCode Paths + shell: powershell + run: | + + $nodePath = 'C:\Program Files\nodejs' + $vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe' + + # Update PATH so that Node.js, npm, npx, and VSCode can be called directly + $newPath = "$env:PATH;$nodePath;$vscodePath" + [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) + + # Persist the updated PATH to make it available for subsequent steps + "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append + +# - name: Check Visual Studio Code and Node.js Installation Paths # shell: powershell # run: | +# # Check if Visual Studio Code is installed and print the installation path +# $vscodePaths = @( +# 'C:\Program Files\Microsoft VS Code\Code.exe', +# 'C:\Users\*\AppData\Local\Programs\Microsoft VS Code\Code.exe' +# ) # -# $nodePath = 'C:\Program Files\nodejs' -# $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' +# $vscodeInstalled = $false # -# # Update PATH so that Node.js, npm, npx, and VSCode can be called directly -# $newPath = "$env:PATH;$nodePath;$vscodePath" -# [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) +# foreach ($path in $vscodePaths) { +# $resolvedPaths = Get-ChildItem -Path $path -ErrorAction SilentlyContinue +# foreach ($resolvedPath in $resolvedPaths) { +# Write-Output "VSCode is installed at: $($resolvedPath.FullName)" +# $vscodeInstalled = $true +# } +# } # -# # Persist the updated PATH to make it available for subsequent steps -# "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Check Visual Studio Code and Node.js Installation Paths - shell: powershell - run: | - # Check if Visual Studio Code is installed and print the installation path - $vscodePaths = @( - 'C:\Program Files\Microsoft VS Code\Code.exe', - 'C:\Users\*\AppData\Local\Programs\Microsoft VS Code\Code.exe' - ) - - $vscodeInstalled = $false - foreach ($path in $vscodePaths) { - $resolvedPaths = Get-ChildItem -Path $path -ErrorAction SilentlyContinue - foreach ($resolvedPath in $resolvedPaths) { - Write-Output "VSCode is installed at: $($resolvedPath.FullName)" - $vscodeInstalled = $true - } - } - - if (-not $vscodeInstalled) { - Write-Output "VSCode is not installed." - } - - # Check if Node.js is installed and print the installation path - try { - $nodejsPath = (& where.exe node) - Write-Output "Node.js is installed at: $nodejsPath" - } catch { - Write-Output "Node.js is not installed." - } +# if (-not $vscodeInstalled) { +# Write-Output "VSCode is not installed." +# } +# +# # Check if Node.js is installed and print the installation path +# try { +# $nodejsPath = (& where.exe node) +# Write-Output "Node.js is installed at: $nodejsPath" +# } catch { +# Write-Output "Node.js is not installed." +# } - name: Print Current Logged-In User shell: powershell From b0d4dd0d339f3d67a0c2f16a9eb6a04472744286 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 19:00:59 +0200 Subject: [PATCH 075/157] try to switch to non-admin Signed-off-by: midays --- .github/workflows/provision-runner.yml | 73 ++++++++++++------------ .github/workflows/windows-nightly-ci.yml | 6 +- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 973819e..62caa60 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -80,40 +80,39 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" -# configure-ec2: -# needs: provision-ec2 -# runs-on: ${{ needs.provision-ec2.outputs.label }} -# steps: -# - name: Set Default Login to Non-Admin User (Windows Specific) -# if: ${{ inputs.ec2-os-type == 'windows' }} -# shell: powershell -# run: | -# # Enable nonadmin user and set as default login -# net user nonadmin /active:yes -# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d nonadmin /f -# reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f -# -# - name: Configure GitHub Runner Service to Run as Non-Admin User -# if: ${{ inputs.ec2-os-type == 'windows' }} -# shell: powershell -# env: -# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} -# run: | -# # Stop the GitHub Actions Runner service -# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -# -# if (-not $serviceName) { -# Write-Error "GitHub Actions runner service not found." -# exit 1 -# } -# -# # Stop the GitHub Actions Runner service -# Stop-Service -Name $serviceName -Force -# -# # Update the service to use the nonadmin user credentials -# $username = "nonadmin" -# $password = $env:NONADMIN_PASSWORD -# sc.exe config $serviceName obj= ".\$username" password= "$password" -# -# # Start the GitHub Actions Runner service again -# Start-Service -Name $serviceName + configure-ec2: + needs: provision-ec2 + runs-on: ${{ needs.provision-ec2.outputs.label }} + steps: + - name: Reconfigure Runner Service to Use Non-Admin User + shell: powershell + env: + NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} + run: | + try { + # Stop the GitHub Actions Runner service + Write-Output "Stopping GitHub Actions Runner service..." + $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found." + exit 1 + } + + Stop-Service -Name $serviceName -Force + Write-Output "Service stopped: $serviceName" + + # Update the service to use the nonadmin user credentials + Write-Output "Reconfiguring the service to use nonadmin user..." + sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" + Write-Output "Service reconfiguration command executed." + + # Start the GitHub Actions Runner service again + Start-Service -Name $serviceName + Write-Output "Service restarted successfully." + + # Verify service configuration + $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName + Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + } catch { + Write-Host "Failed to configure the runner service: $_.Exception.Message" + } diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d9f230d..2ed25a5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -81,12 +81,10 @@ jobs: # Write-Output "Node.js is not installed." # } - - name: Print Current Logged-In User + - name: Verify Current User shell: powershell run: | - # Print the current logged-in user - Write-Output "Current User: $(whoami)" - Write-Output "Environment User: $env:USERNAME" + whoami - name: Print PATH Environment Variable shell: powershell From 0b6bb8836470f170679c7f5e56c8dc38a6f4ea08 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 19:14:01 +0200 Subject: [PATCH 076/157] try to debug why user is not being switched Signed-off-by: midays --- .github/workflows/provision-runner.yml | 12 +++++++++--- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 62caa60..11dad6f 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -90,14 +90,20 @@ jobs: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Stop the GitHub Actions Runner service - Write-Output "Stopping GitHub Actions Runner service..." - $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + # List all services to debug what services are running + Write-Output "Listing all available services to find the GitHub Actions Runner service..." + Get-Service | Select-Object Name, DisplayName, Status, StartName + + # Attempt to find the GitHub Actions Runner service more reliably + $serviceName = Get-Service | Where-Object { $_.Name -like '*actions.runner*' } | Select-Object -ExpandProperty Name + if (-not $serviceName) { Write-Error "GitHub Actions runner service not found." exit 1 } + # Stop the GitHub Actions Runner service + Write-Output "Stopping GitHub Actions Runner service: $serviceName" Stop-Service -Name $serviceName -Force Write-Output "Service stopped: $serviceName" diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2ed25a5..73c1829 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -162,14 +162,14 @@ jobs: if: always() -# stop-ec2-instance: -# needs: [ start-ec2-instance,run-tests ] -# if: always() -# uses: ./.github/workflows/remove-runner.yml -# with: -# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} -# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} -# secrets: -# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + stop-ec2-instance: + needs: [ start-ec2-instance,run-tests ] + if: always() + uses: ./.github/workflows/remove-runner.yml + with: + ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} + ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} + secrets: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From 384b6c6e060af579b901809b3b1664e410e4c288 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 19:28:04 +0200 Subject: [PATCH 077/157] debug the runner Signed-off-by: midays --- .github/workflows/provision-runner.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 11dad6f..87d4de0 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -90,13 +90,16 @@ jobs: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # List all services to debug what services are running - Write-Output "Listing all available services to find the GitHub Actions Runner service..." + # List all services with detailed information to identify the runner service + Write-Output "Listing all available services to identify the GitHub Actions Runner service..." Get-Service | Select-Object Name, DisplayName, Status, StartName - # Attempt to find the GitHub Actions Runner service more reliably - $serviceName = Get-Service | Where-Object { $_.Name -like '*actions.runner*' } | Select-Object -ExpandProperty Name - + # Attempt to find the GitHub Actions Runner service with a more generalized matching + Write-Output "Attempting to find the GitHub Actions Runner service..." + $serviceName = Get-Service | Where-Object { + $_.DisplayName -like '*GitHub*Runner*' -or $_.Name -like '*actions.runner*' + } | Select-Object -ExpandProperty Name -First 1 + if (-not $serviceName) { Write-Error "GitHub Actions runner service not found." exit 1 From 978de1845a55a8e289e96210660a0d87ace1e444 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 19:44:26 +0200 Subject: [PATCH 078/157] change service debug Signed-off-by: midays --- .github/workflows/provision-runner.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 87d4de0..946c250 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -94,14 +94,14 @@ jobs: Write-Output "Listing all available services to identify the GitHub Actions Runner service..." Get-Service | Select-Object Name, DisplayName, Status, StartName - # Attempt to find the GitHub Actions Runner service with a more generalized matching + # Attempt to find the GitHub Actions Runner service with a broader match Write-Output "Attempting to find the GitHub Actions Runner service..." $serviceName = Get-Service | Where-Object { - $_.DisplayName -like '*GitHub*Runner*' -or $_.Name -like '*actions.runner*' + ($_.DisplayName -like '*GitHub*Runner*') -or ($_.Name -like '*actions.runner*') -or ($_.DisplayName -like '*actions*') -or ($_.Name -like '*runner*') } | Select-Object -ExpandProperty Name -First 1 if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found." + Write-Error "GitHub Actions runner service not found. Please verify the runner service name." exit 1 } From 2dab96082c86e991062baafe18115e6adf8e6b1f Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 27 Nov 2024 19:51:48 +0200 Subject: [PATCH 079/157] fix vscode installation path Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 73c1829..44d1e12 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -41,7 +41,7 @@ jobs: run: | $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe' + $vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/' # Update PATH so that Node.js, npm, npx, and VSCode can be called directly $newPath = "$env:PATH;$nodePath;$vscodePath" From efb2dfa78488b9029a978b78b686402b36f7487f Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 07:40:33 +0200 Subject: [PATCH 080/157] ignore non-admin user, test execution Signed-off-by: midays --- .github/workflows/provision-runner.yml | 99 ++++++++++++------------ .github/workflows/windows-nightly-ci.yml | 35 +++++---- 2 files changed, 69 insertions(+), 65 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 946c250..fa6760f 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -38,11 +38,14 @@ on: github-token: description: 'Personal Access Token For GH' required: true + nonadmin-password: + description: 'Password for the nonadmin user' + required: true outputs: - instance_label: + instance_label: description: "The label of the VM that was created." value: ${{ jobs.provision-ec2.outputs.label }} - ec2-instance-id: + ec2-instance-id: description: "Instance id of the VM that was created." value: ${{ jobs.provision-ec2.outputs.instance_id }} @@ -70,58 +73,58 @@ jobs: mode: start github-token: ${{ secrets.github-token }} ec2-os: ${{ inputs.ec2-os-type }} - ec2-instance-type: ${{ inputs.ec2-instance-type }} + ec2-instance-type: ${{ inputs.ec2-instance-type }} ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} +# user-data: | +# +# net user nonadmin ${{ secrets.nonadmin-password }} /add +# net localgroup Users nonadmin /add +# +# # Install GitHub Actions runner as non-admin user (if needed) +# $userCredential = New-Object System.Management.Automation.PSCredential("nonadmin", (ConvertTo-SecureString "${{ secrets.nonadmin-password }}" -AsPlainText -Force)) +# Start-Process -FilePath "powershell.exe" -ArgumentList "-command " -Credential $userCredential +# - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" - configure-ec2: - needs: provision-ec2 - runs-on: ${{ needs.provision-ec2.outputs.label }} - steps: - - name: Reconfigure Runner Service to Use Non-Admin User - shell: powershell - env: - NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} - run: | - try { - # List all services with detailed information to identify the runner service - Write-Output "Listing all available services to identify the GitHub Actions Runner service..." - Get-Service | Select-Object Name, DisplayName, Status, StartName - - # Attempt to find the GitHub Actions Runner service with a broader match - Write-Output "Attempting to find the GitHub Actions Runner service..." - $serviceName = Get-Service | Where-Object { - ($_.DisplayName -like '*GitHub*Runner*') -or ($_.Name -like '*actions.runner*') -or ($_.DisplayName -like '*actions*') -or ($_.Name -like '*runner*') - } | Select-Object -ExpandProperty Name -First 1 - - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Please verify the runner service name." - exit 1 - } - - # Stop the GitHub Actions Runner service - Write-Output "Stopping GitHub Actions Runner service: $serviceName" - Stop-Service -Name $serviceName -Force - Write-Output "Service stopped: $serviceName" - - # Update the service to use the nonadmin user credentials - Write-Output "Reconfiguring the service to use nonadmin user..." - sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" - Write-Output "Service reconfiguration command executed." - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName - Write-Output "Service restarted successfully." - - # Verify service configuration - $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName - Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - } catch { - Write-Host "Failed to configure the runner service: $_.Exception.Message" - } +# configure-ec2: +# needs: provision-ec2 +# runs-on: ${{ needs.provision-ec2.outputs.label }} +# steps: +# - name: Reconfigure Runner Service to Use Non-Admin User +# shell: powershell +# env: +# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} +# run: | +# try { +# # Stop the GitHub Actions Runner service +# Write-Output "Stopping GitHub Actions Runner service..." +# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name +# if (-not $serviceName) { +# Write-Error "GitHub Actions runner service not found." +# exit 1 +# } +# +# Stop-Service -Name $serviceName -Force +# Write-Output "Service stopped: $serviceName" +# +# # Update the service to use the nonadmin user credentials +# Write-Output "Reconfiguring the service to use nonadmin user..." +# sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" +# Write-Output "Service reconfiguration command executed." +# +# # Start the GitHub Actions Runner service again +# Start-Service -Name $serviceName +# Write-Output "Service restarted successfully." +# +# # Verify service configuration +# $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName +# Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" +# } catch { +# Write-Host "Failed to configure the runner service: $_.Exception.Message" +# } diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 44d1e12..b5c78a3 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -15,6 +15,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + nonadmin-password: ${{ secrets.NONADMIN_PASSWORD }} run-tests: needs: start-ec2-instance @@ -28,20 +29,20 @@ jobs: iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) shell: powershell -# - name: Install VSCode -# run: choco install vscode -y -# shell: powershell - - name: Install Node.js run: choco install nodejs -y shell: powershell -# + + - name: Install VSCode + run: choco install vscode -y + shell: powershell + - name: Define Node.js and VSCode Paths shell: powershell run: | $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' # Update PATH so that Node.js, npm, npx, and VSCode can be called directly $newPath = "$env:PATH;$nodePath;$vscodePath" @@ -162,14 +163,14 @@ jobs: if: always() - stop-ec2-instance: - needs: [ start-ec2-instance,run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} +# stop-ec2-instance: +# needs: [ start-ec2-instance,run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From a007ce1402a2fec0bd9000ea2fcdc7fdfd577251 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 08:10:11 +0200 Subject: [PATCH 081/157] replace default extension download URL with the windows default Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index b5c78a3..7753a1b 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -128,7 +128,9 @@ jobs: working-directory: C:\actions-runner\work\kai-ci run: | Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | Set-Content .env + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | + ForEach-Object { $_ -replace "DEFAULT_VSIX_DOWNLOAD_URL=.*", "DEFAULT_VSIX_DOWNLOAD_URL='https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-windows-0.0.1.vsix'" } | + Set-Content .env - name: Run tests shell: powershell From 58d7ed19e662384be7631396dd47ceef5ad26f6d Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 09:38:19 +0200 Subject: [PATCH 082/157] set full path for uploading screenshots and report Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 7753a1b..0ce0ec5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -82,10 +82,10 @@ jobs: # Write-Output "Node.js is not installed." # } - - name: Verify Current User - shell: powershell - run: | - whoami +# - name: Verify Current User +# shell: powershell +# run: | +# whoami - name: Print PATH Environment Variable shell: powershell @@ -147,22 +147,22 @@ jobs: with: name: vscode-screenshots path: | - vscode-initialized-screenshot.png - kai-installed-screenshot.png + C:\actions-runner\work\kai-ci\vscode-initialized-screenshot.png + C:\actions-runner\work\kai-ci\kai-installed-screenshot.png if: always() - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: - name: test-results - path: test-results/ + name: playwright-report + path: C:\actions-runner\work\kai-ci\playwright-report\ retention-days: 30 - - name: Clean Up Kai Temp Directory - shell: powershell - run: | - Remove-Item -Recurse -Force C:\actions-runner\work\kai-ci - if: always() +# - name: Clean Up Kai Temp Directory +# shell: powershell +# run: | +# Remove-Item -Recurse -Force C:\actions-runner +# if: always() # stop-ec2-instance: From a33742b7b4d45e58e2e1cb3447b693da6b603879 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 10:15:16 +0200 Subject: [PATCH 083/157] remove try{} clause Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0ce0ec5..9a94d3d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -136,11 +136,7 @@ jobs: shell: powershell working-directory: C:\actions-runner\work\kai-ci run: | - try { - npx playwright test - } catch { - Write-Host "Playwright tests failed, but continuing workflow." # to continue running even if the tests run fail - } + npx playwright test - name: Upload screenshots uses: actions/upload-artifact@v4 From 1edb90a6755239b18f91dc50e34dd0a45da07aa1 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 10:47:29 +0200 Subject: [PATCH 084/157] checkout windows-vm branch Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 9a94d3d..eb91810 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -115,6 +115,7 @@ jobs: run: | cd C:\actions-runner\work git clone https://github.com/konveyor/kai-ci.git + git checkout windows-vm - name: Install npm dependencies shell: powershell From 4c6ba36ece249a94348dbdb678b8d2a648b14e36 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 11:30:22 +0200 Subject: [PATCH 085/157] cd kai-ci before switching branch Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index eb91810..4606883 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -115,6 +115,7 @@ jobs: run: | cd C:\actions-runner\work git clone https://github.com/konveyor/kai-ci.git + cd ./kai-ci git checkout windows-vm - name: Install npm dependencies From f66d5b8ce42cd46e34a45e5dcf8488e470ea5aa7 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 13:31:58 +0200 Subject: [PATCH 086/157] continue on error Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 37 ++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4606883..e35d481 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -136,6 +136,7 @@ jobs: - name: Run tests shell: powershell + continue-on-error: true # Allow this step to continue even if some tests fail working-directory: C:\actions-runner\work\kai-ci run: | npx playwright test @@ -156,21 +157,21 @@ jobs: path: C:\actions-runner\work\kai-ci\playwright-report\ retention-days: 30 -# - name: Clean Up Kai Temp Directory -# shell: powershell -# run: | -# Remove-Item -Recurse -Force C:\actions-runner -# if: always() - - -# stop-ec2-instance: -# needs: [ start-ec2-instance,run-tests ] -# if: always() -# uses: ./.github/workflows/remove-runner.yml -# with: -# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} -# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} -# secrets: -# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + - name: Clean Up Kai Temp Directory + shell: powershell + run: | + Remove-Item -Recurse -Force C:\actions-runner + if: always() + + + stop-ec2-instance: + needs: [ start-ec2-instance,run-tests ] + if: always() + uses: ./.github/workflows/remove-runner.yml + with: + ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} + ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} + secrets: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From 7945af274c41bebb7c99fffc6efa47a308eeda53 Mon Sep 17 00:00:00 2001 From: midays Date: Thu, 28 Nov 2024 14:52:06 +0200 Subject: [PATCH 087/157] chang title, remove comments Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index e35d481..1cf5e81 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -1,4 +1,4 @@ -name: Provision Windows VM using reusable workflow +name: Windows Nightly Run on: [push] @@ -82,10 +82,6 @@ jobs: # Write-Output "Node.js is not installed." # } -# - name: Verify Current User -# shell: powershell -# run: | -# whoami - name: Print PATH Environment Variable shell: powershell From 0c06baa2dd8aa3d758313054694c4583da21f8b0 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 12:42:06 +0200 Subject: [PATCH 088/157] change vscode execution path to nonadmin Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 1cf5e81..c4c247f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -42,7 +42,7 @@ jobs: run: | $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' + $vscodePath = 'C:\Users\nonadmin\AppData\Local\Programs\Microsoft VS Code\' # Update PATH so that Node.js, npm, npx, and VSCode can be called directly $newPath = "$env:PATH;$nodePath;$vscodePath" @@ -126,7 +126,7 @@ jobs: working-directory: C:\actions-runner\work\kai-ci run: | Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe'" | ForEach-Object { $_ -replace "DEFAULT_VSIX_DOWNLOAD_URL=.*", "DEFAULT_VSIX_DOWNLOAD_URL='https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-windows-0.0.1.vsix'" } | Set-Content .env From 1967fc150e4c5e696776476400cf2c1527073af0 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 13:22:32 +0200 Subject: [PATCH 089/157] revert execution path Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index c4c247f..1cf5e81 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -42,7 +42,7 @@ jobs: run: | $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Users\nonadmin\AppData\Local\Programs\Microsoft VS Code\' + $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' # Update PATH so that Node.js, npm, npx, and VSCode can be called directly $newPath = "$env:PATH;$nodePath;$vscodePath" @@ -126,7 +126,7 @@ jobs: working-directory: C:\actions-runner\work\kai-ci run: | Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe'" | + (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | ForEach-Object { $_ -replace "DEFAULT_VSIX_DOWNLOAD_URL=.*", "DEFAULT_VSIX_DOWNLOAD_URL='https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-windows-0.0.1.vsix'" } | Set-Content .env From 656bf17d90453ba6cc17f5a32cddaafe426d72a6 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 13:39:44 +0200 Subject: [PATCH 090/157] try to login as non-admin Signed-off-by: midays --- .github/workflows/provision-runner.yml | 90 +++++++++++++------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index fa6760f..1c45039 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -77,54 +77,54 @@ jobs: ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} -# user-data: | -# -# net user nonadmin ${{ secrets.nonadmin-password }} /add -# net localgroup Users nonadmin /add -# -# # Install GitHub Actions runner as non-admin user (if needed) -# $userCredential = New-Object System.Management.Automation.PSCredential("nonadmin", (ConvertTo-SecureString "${{ secrets.nonadmin-password }}" -AsPlainText -Force)) -# Start-Process -FilePath "powershell.exe" -ArgumentList "-command " -Credential $userCredential -# + user-data: | + + net user nonadmin ${{ secrets.nonadmin-password }} /add + net localgroup Users nonadmin /add + + # Install GitHub Actions runner as non-admin user (if needed) + $userCredential = New-Object System.Management.Automation.PSCredential("nonadmin", (ConvertTo-SecureString "${{ secrets.nonadmin-password }}" -AsPlainText -Force)) + Start-Process -FilePath "powershell.exe" -ArgumentList "-command " -Credential $userCredential + - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" -# configure-ec2: -# needs: provision-ec2 -# runs-on: ${{ needs.provision-ec2.outputs.label }} -# steps: -# - name: Reconfigure Runner Service to Use Non-Admin User -# shell: powershell -# env: -# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} -# run: | -# try { -# # Stop the GitHub Actions Runner service -# Write-Output "Stopping GitHub Actions Runner service..." -# $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -# if (-not $serviceName) { -# Write-Error "GitHub Actions runner service not found." -# exit 1 -# } -# -# Stop-Service -Name $serviceName -Force -# Write-Output "Service stopped: $serviceName" -# -# # Update the service to use the nonadmin user credentials -# Write-Output "Reconfiguring the service to use nonadmin user..." -# sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" -# Write-Output "Service reconfiguration command executed." -# -# # Start the GitHub Actions Runner service again -# Start-Service -Name $serviceName -# Write-Output "Service restarted successfully." -# -# # Verify service configuration -# $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName -# Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" -# } catch { -# Write-Host "Failed to configure the runner service: $_.Exception.Message" -# } + configure-ec2: + needs: provision-ec2 + runs-on: ${{ needs.provision-ec2.outputs.label }} + steps: + - name: Reconfigure Runner Service to Use Non-Admin User + shell: powershell + env: + NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} + run: | + try { + # Stop the GitHub Actions Runner service + Write-Output "Stopping GitHub Actions Runner service..." + $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found." + exit 1 + } + + Stop-Service -Name $serviceName -Force + Write-Output "Service stopped: $serviceName" + + # Update the service to use the nonadmin user credentials + Write-Output "Reconfiguring the service to use nonadmin user..." + sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" + Write-Output "Service reconfiguration command executed." + + # Start the GitHub Actions Runner service again + Start-Service -Name $serviceName + Write-Output "Service restarted successfully." + + # Verify service configuration + $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName + Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + } catch { + Write-Host "Failed to configure the runner service: $_.Exception.Message" + } From 4f6092887a8cdadea67f0b44e9e814c331161436 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 13:54:14 +0200 Subject: [PATCH 091/157] remove user creation as user already exists, add timeout before trying to switch to non-admin Signed-off-by: midays --- .github/workflows/provision-runner.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 1c45039..907c2d0 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -77,15 +77,6 @@ jobs: ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} - user-data: | - - net user nonadmin ${{ secrets.nonadmin-password }} /add - net localgroup Users nonadmin /add - - # Install GitHub Actions runner as non-admin user (if needed) - $userCredential = New-Object System.Management.Automation.PSCredential("nonadmin", (ConvertTo-SecureString "${{ secrets.nonadmin-password }}" -AsPlainText -Force)) - Start-Process -FilePath "powershell.exe" -ArgumentList "-command " -Credential $userCredential - - name: Output EC2 Instance ID run: | @@ -96,6 +87,11 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: + - name: Wait for Runner Initialization + run: | + echo "Waiting for GitHub Actions Runner to initialize..." + sleep 120 + - name: Reconfigure Runner Service to Use Non-Admin User shell: powershell env: @@ -109,19 +105,19 @@ jobs: Write-Error "GitHub Actions runner service not found." exit 1 } - + Stop-Service -Name $serviceName -Force Write-Output "Service stopped: $serviceName" - + # Update the service to use the nonadmin user credentials Write-Output "Reconfiguring the service to use nonadmin user..." sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" Write-Output "Service reconfiguration command executed." - + # Start the GitHub Actions Runner service again Start-Service -Name $serviceName Write-Output "Service restarted successfully." - + # Verify service configuration $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" From 679dab0605ad5da79a4d95b715b3767397c8d0f5 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 14:01:54 +0200 Subject: [PATCH 092/157] different approach Signed-off-by: midays --- .github/workflows/provision-runner.yml | 70 ++++++++++++++++---------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 907c2d0..395b1a0 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -87,40 +87,58 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: - - name: Wait for Runner Initialization - run: | - echo "Waiting for GitHub Actions Runner to initialize..." - sleep 120 - - name: Reconfigure Runner Service to Use Non-Admin User shell: powershell env: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Stop the GitHub Actions Runner service Write-Output "Stopping GitHub Actions Runner service..." - $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found." - exit 1 + $retryCount = 0 + $maxRetries = 5 + $success = $false + + while (-not $success -and $retryCount -lt $maxRetries) { + try { + $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found. Retrying in 10 seconds..." + Start-Sleep -Seconds 10 + $retryCount++ + continue + } + + Stop-Service -Name $serviceName -Force + Write-Output "Service stopped: $serviceName" + + Write-Output "Reconfiguring the service to use nonadmin user..." + sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" + Write-Output "Service reconfiguration command executed." + + Start-Service -Name $serviceName + Write-Output "Service restarted successfully." + + $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName + Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + + if ($updatedService.StartName -eq ".\\nonadmin") { + $success = $true + } else { + Write-Output "Service is not running as nonadmin, retrying..." + $retryCount++ + Start-Sleep -Seconds 10 + } + } catch { + Write-Output "An error occurred: $_.Exception.Message. Retrying in 10 seconds..." + Start-Sleep -Seconds 10 + $retryCount++ + } + } + + if (-not $success) { + throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." } - - Stop-Service -Name $serviceName -Force - Write-Output "Service stopped: $serviceName" - - # Update the service to use the nonadmin user credentials - Write-Output "Reconfiguring the service to use nonadmin user..." - sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" - Write-Output "Service reconfiguration command executed." - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName - Write-Output "Service restarted successfully." - - # Verify service configuration - $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName - Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" } catch { Write-Host "Failed to configure the runner service: $_.Exception.Message" + exit 1 } From bfbec5ca8b48439deb94aa1362ccb1dec56cf8e7 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 14:08:40 +0200 Subject: [PATCH 093/157] add more delay to give the service more time to initialize properly Signed-off-by: midays --- .github/workflows/provision-runner.yml | 33 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 395b1a0..8845f43 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -93,52 +93,71 @@ jobs: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { + # Initial delay to allow the GitHub Actions Runner service to start + Write-Output "Waiting for GitHub Actions Runner service to initialize..." + Start-Sleep -Seconds 30 + + # Inform about stopping the GitHub Actions Runner service Write-Output "Stopping GitHub Actions Runner service..." + + # Initialize retry count and max retry values for attempts to stop and reconfigure the service $retryCount = 0 $maxRetries = 5 $success = $false + # Loop until the service is successfully reconfigured or maximum retries are reached while (-not $success -and $retryCount -lt $maxRetries) { try { + # Get the GitHub Actions Runner service name $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + + # If the service is not found, retry after a delay if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Retrying in 10 seconds..." - Start-Sleep -Seconds 10 + Write-Error "GitHub Actions runner service not found. Retrying in 20 seconds..." + Start-Sleep -Seconds 20 $retryCount++ continue } + # Stop the runner service forcefully Stop-Service -Name $serviceName -Force Write-Output "Service stopped: $serviceName" + # Reconfigure the service to use the non-admin user credentials Write-Output "Reconfiguring the service to use nonadmin user..." sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" Write-Output "Service reconfiguration command executed." + # Start the GitHub Actions Runner service again Start-Service -Name $serviceName Write-Output "Service restarted successfully." + # Verify that the service is running under the non-admin user $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - if ($updatedService.StartName -eq ".\\nonadmin") { + # Set success flag if the service is running as non-admin + if ($updatedService.StartName -eq ".\nonadmin") { $success = $true } else { Write-Output "Service is not running as nonadmin, retrying..." $retryCount++ - Start-Sleep -Seconds 10 + Start-Sleep -Seconds 20 } } catch { - Write-Output "An error occurred: $_.Exception.Message. Retrying in 10 seconds..." - Start-Sleep -Seconds 10 + # Handle errors during reconfiguration and retry + Write-Output "An error occurred: $_.Exception.Message. Retrying in 20 seconds..." + Start-Sleep -Seconds 20 $retryCount++ } } + # Throw an error if reconfiguration fails after all retries if (-not $success) { throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." } } catch { + # Handle the case where reconfiguration fails completely Write-Host "Failed to configure the runner service: $_.Exception.Message" exit 1 - } + } \ No newline at end of file From 9b06affadd5a102cac0b3d0ee7f10085875e9026 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 14:22:38 +0200 Subject: [PATCH 094/157] Added a step to print all available services when the runner service is not found. Extended the initial wait time to 90 seconds. Added extra logs to provide more detailed insight into what's happening. Signed-off-by: midays --- .github/workflows/provision-runner.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 8845f43..17736a4 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -95,7 +95,7 @@ jobs: try { # Initial delay to allow the GitHub Actions Runner service to start Write-Output "Waiting for GitHub Actions Runner service to initialize..." - Start-Sleep -Seconds 30 + Start-Sleep -Seconds 90 # Inform about stopping the GitHub Actions Runner service Write-Output "Stopping GitHub Actions Runner service..." @@ -108,13 +108,15 @@ jobs: # Loop until the service is successfully reconfigured or maximum retries are reached while (-not $success -and $retryCount -lt $maxRetries) { try { - # Get the GitHub Actions Runner service name - $serviceName = Get-Service -Name 'actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + # Get the GitHub Actions Runner service name dynamically using wildcard + $serviceName = Get-Service -Name '*actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - # If the service is not found, retry after a delay + # If the service is not found, print available services and retry after a delay if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Retrying in 20 seconds..." - Start-Sleep -Seconds 20 + Write-Error "GitHub Actions runner service not found. Printing available services..." + Get-Service | Select-Object -Property Name, Status + Write-Error "Retrying in 30 seconds..." + Start-Sleep -Seconds 30 $retryCount++ continue } @@ -142,12 +144,12 @@ jobs: } else { Write-Output "Service is not running as nonadmin, retrying..." $retryCount++ - Start-Sleep -Seconds 20 + Start-Sleep -Seconds 30 } } catch { # Handle errors during reconfiguration and retry - Write-Output "An error occurred: $_.Exception.Message. Retrying in 20 seconds..." - Start-Sleep -Seconds 20 + Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." + Start-Sleep -Seconds 30 $retryCount++ } } @@ -160,4 +162,4 @@ jobs: # Handle the case where reconfiguration fails completely Write-Host "Failed to configure the runner service: $_.Exception.Message" exit 1 - } \ No newline at end of file + } From 567f83b87c879d72515f7d2e75a714954f5e9207 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 14:42:48 +0200 Subject: [PATCH 095/157] try looking into temp directory Signed-off-by: midays --- .github/workflows/provision-runner.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 17736a4..303ae51 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -97,6 +97,22 @@ jobs: Write-Output "Waiting for GitHub Actions Runner service to initialize..." Start-Sleep -Seconds 90 + # Print the current user context + Write-Output "Current User Context:" + whoami + + # Print all available services after initial wait + Write-Output "Listing all services after initial wait:" + Get-Service | Select-Object -Property Name, Status + + # Print the GitHub Actions runner installation directory + Write-Output "Checking runner installation directory..." + Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name + + # Print all running processes to check for runner process + Write-Output "Listing all running processes to identify runner..." + Get-Process | Select-Object -Property Id, ProcessName + # Inform about stopping the GitHub Actions Runner service Write-Output "Stopping GitHub Actions Runner service..." @@ -108,8 +124,8 @@ jobs: # Loop until the service is successfully reconfigured or maximum retries are reached while (-not $success -and $retryCount -lt $maxRetries) { try { - # Get the GitHub Actions Runner service name dynamically using wildcard - $serviceName = Get-Service -Name '*actions.runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + # Get the GitHub Actions Runner service name dynamically using broader wildcard + $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name # If the service is not found, print available services and retry after a delay if (-not $serviceName) { From 2c1583752d36e8fb50d45eeac0c82a62771cbf72 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 14:57:49 +0200 Subject: [PATCH 096/157] try looking into temp directory Signed-off-by: midays --- .github/workflows/provision-runner.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 303ae51..0a311a6 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -107,11 +107,19 @@ jobs: # Print the GitHub Actions runner installation directory Write-Output "Checking runner installation directory..." - Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name + if (Test-Path -Path "C:\actions-runner") { + Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name + } else { + Write-Error "Runner installation directory not found at expected path: C:\actions-runner" + } + + # Print all running processes to check for runner process by keyword + Write-Output "Searching for running processes related to runner..." + Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName - # Print all running processes to check for runner process - Write-Output "Listing all running processes to identify runner..." - Get-Process | Select-Object -Property Id, ProcessName + # Print environment variables to diagnose context issues + Write-Output "Listing environment variables:" + Get-ChildItem Env: # Inform about stopping the GitHub Actions Runner service Write-Output "Stopping GitHub Actions Runner service..." From dd32833e6f88ff555693751c4760ee51dd518a5c Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 15:08:58 +0200 Subject: [PATCH 097/157] try looking into temp directory Signed-off-by: midays --- .github/workflows/provision-runner.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 0a311a6..800c96b 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -108,9 +108,22 @@ jobs: # Print the GitHub Actions runner installation directory Write-Output "Checking runner installation directory..." if (Test-Path -Path "C:\actions-runner") { + Write-Output "Runner directory found, listing contents..." Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name } else { Write-Error "Runner installation directory not found at expected path: C:\actions-runner" + Write-Output "Attempting to reinstall GitHub Actions runner..." + + # Attempt to download and install the GitHub Actions runner manually + New-Item -ItemType Directory -Force -Path "C:\actions-runner" + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" + Write-Output "Extracting runner package..." + Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" + Remove-Item "C:\actions-runner\actions-runner.zip" + + Write-Output "Running GitHub Actions runner configuration script..." + Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait + Write-Output "Runner configuration completed." } # Print all running processes to check for runner process by keyword From 0fd7da7a22955370bccecf2100f0e5a25c73e144 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 1 Dec 2024 15:26:15 +0200 Subject: [PATCH 098/157] comment code Signed-off-by: midays --- .github/workflows/provision-runner.yml | 234 ++++++++++++------------- 1 file changed, 117 insertions(+), 117 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 800c96b..39b4fae 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -83,120 +83,120 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" - configure-ec2: - needs: provision-ec2 - runs-on: ${{ needs.provision-ec2.outputs.label }} - steps: - - name: Reconfigure Runner Service to Use Non-Admin User - shell: powershell - env: - NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} - run: | - try { - # Initial delay to allow the GitHub Actions Runner service to start - Write-Output "Waiting for GitHub Actions Runner service to initialize..." - Start-Sleep -Seconds 90 - - # Print the current user context - Write-Output "Current User Context:" - whoami - - # Print all available services after initial wait - Write-Output "Listing all services after initial wait:" - Get-Service | Select-Object -Property Name, Status - - # Print the GitHub Actions runner installation directory - Write-Output "Checking runner installation directory..." - if (Test-Path -Path "C:\actions-runner") { - Write-Output "Runner directory found, listing contents..." - Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name - } else { - Write-Error "Runner installation directory not found at expected path: C:\actions-runner" - Write-Output "Attempting to reinstall GitHub Actions runner..." - - # Attempt to download and install the GitHub Actions runner manually - New-Item -ItemType Directory -Force -Path "C:\actions-runner" - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" - Write-Output "Extracting runner package..." - Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" - Remove-Item "C:\actions-runner\actions-runner.zip" - - Write-Output "Running GitHub Actions runner configuration script..." - Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait - Write-Output "Runner configuration completed." - } - - # Print all running processes to check for runner process by keyword - Write-Output "Searching for running processes related to runner..." - Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName - - # Print environment variables to diagnose context issues - Write-Output "Listing environment variables:" - Get-ChildItem Env: - - # Inform about stopping the GitHub Actions Runner service - Write-Output "Stopping GitHub Actions Runner service..." - - # Initialize retry count and max retry values for attempts to stop and reconfigure the service - $retryCount = 0 - $maxRetries = 5 - $success = $false - - # Loop until the service is successfully reconfigured or maximum retries are reached - while (-not $success -and $retryCount -lt $maxRetries) { - try { - # Get the GitHub Actions Runner service name dynamically using broader wildcard - $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - - # If the service is not found, print available services and retry after a delay - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Printing available services..." - Get-Service | Select-Object -Property Name, Status - Write-Error "Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ - continue - } - - # Stop the runner service forcefully - Stop-Service -Name $serviceName -Force - Write-Output "Service stopped: $serviceName" - - # Reconfigure the service to use the non-admin user credentials - Write-Output "Reconfiguring the service to use nonadmin user..." - sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" - Write-Output "Service reconfiguration command executed." - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName - Write-Output "Service restarted successfully." - - # Verify that the service is running under the non-admin user - $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName - Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - - # Set success flag if the service is running as non-admin - if ($updatedService.StartName -eq ".\nonadmin") { - $success = $true - } else { - Write-Output "Service is not running as nonadmin, retrying..." - $retryCount++ - Start-Sleep -Seconds 30 - } - } catch { - # Handle errors during reconfiguration and retry - Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ - } - } - - # Throw an error if reconfiguration fails after all retries - if (-not $success) { - throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." - } - } catch { - # Handle the case where reconfiguration fails completely - Write-Host "Failed to configure the runner service: $_.Exception.Message" - exit 1 - } +# configure-ec2: +# needs: provision-ec2 +# runs-on: ${{ needs.provision-ec2.outputs.label }} +# steps: +# - name: Reconfigure Runner Service to Use Non-Admin User +# shell: powershell +# env: +# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} +# run: | +# try { +# # Initial delay to allow the GitHub Actions Runner service to start +# Write-Output "Waiting for GitHub Actions Runner service to initialize..." +# Start-Sleep -Seconds 90 +# +# # Print the current user context +# Write-Output "Current User Context:" +# whoami +# +# # Print all available services after initial wait +# Write-Output "Listing all services after initial wait:" +# Get-Service | Select-Object -Property Name, Status +# +# # Print the GitHub Actions runner installation directory +# Write-Output "Checking runner installation directory..." +# if (Test-Path -Path "C:\actions-runner") { +# Write-Output "Runner directory found, listing contents..." +# Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name +# } else { +# Write-Error "Runner installation directory not found at expected path: C:\actions-runner" +# Write-Output "Attempting to reinstall GitHub Actions runner..." +# +# # Attempt to download and install the GitHub Actions runner manually +# New-Item -ItemType Directory -Force -Path "C:\actions-runner" +# Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" +# Write-Output "Extracting runner package..." +# Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" +# Remove-Item "C:\actions-runner\actions-runner.zip" +# +# Write-Output "Running GitHub Actions runner configuration script..." +# Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait +# Write-Output "Runner configuration completed." +# } +# +# # Print all running processes to check for runner process by keyword +# Write-Output "Searching for running processes related to runner..." +# Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName +# +# # Print environment variables to diagnose context issues +# Write-Output "Listing environment variables:" +# Get-ChildItem Env: +# +# # Inform about stopping the GitHub Actions Runner service +# Write-Output "Stopping GitHub Actions Runner service..." +# +# # Initialize retry count and max retry values for attempts to stop and reconfigure the service +# $retryCount = 0 +# $maxRetries = 5 +# $success = $false +# +# # Loop until the service is successfully reconfigured or maximum retries are reached +# while (-not $success -and $retryCount -lt $maxRetries) { +# try { +# # Get the GitHub Actions Runner service name dynamically using broader wildcard +# $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name +# +# # If the service is not found, print available services and retry after a delay +# if (-not $serviceName) { +# Write-Error "GitHub Actions runner service not found. Printing available services..." +# Get-Service | Select-Object -Property Name, Status +# Write-Error "Retrying in 30 seconds..." +# Start-Sleep -Seconds 30 +# $retryCount++ +# continue +# } +# +# # Stop the runner service forcefully +# Stop-Service -Name $serviceName -Force +# Write-Output "Service stopped: $serviceName" +# +# # Reconfigure the service to use the non-admin user credentials +# Write-Output "Reconfiguring the service to use nonadmin user..." +# sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" +# Write-Output "Service reconfiguration command executed." +# +# # Start the GitHub Actions Runner service again +# Start-Service -Name $serviceName +# Write-Output "Service restarted successfully." +# +# # Verify that the service is running under the non-admin user +# $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName +# Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" +# +# # Set success flag if the service is running as non-admin +# if ($updatedService.StartName -eq ".\nonadmin") { +# $success = $true +# } else { +# Write-Output "Service is not running as nonadmin, retrying..." +# $retryCount++ +# Start-Sleep -Seconds 30 +# } +# } catch { +# # Handle errors during reconfiguration and retry +# Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." +# Start-Sleep -Seconds 30 +# $retryCount++ +# } +# } +# +# # Throw an error if reconfiguration fails after all retries +# if (-not $success) { +# throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." +# } +# } catch { +# # Handle the case where reconfiguration fails completely +# Write-Host "Failed to configure the runner service: $_.Exception.Message" +# exit 1 +# } From f7c395d7e92f0b38441222d869ce979e9d3c4808 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 11:38:02 +0200 Subject: [PATCH 099/157] configure the runner to start as non-admin user forcefully Signed-off-by: midays --- .github/workflows/provision-runner.yml | 266 ++++++++++++++----------- 1 file changed, 149 insertions(+), 117 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 39b4fae..90f58ff 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -83,120 +83,152 @@ jobs: echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" -# configure-ec2: -# needs: provision-ec2 -# runs-on: ${{ needs.provision-ec2.outputs.label }} -# steps: -# - name: Reconfigure Runner Service to Use Non-Admin User -# shell: powershell -# env: -# NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} -# run: | -# try { -# # Initial delay to allow the GitHub Actions Runner service to start -# Write-Output "Waiting for GitHub Actions Runner service to initialize..." -# Start-Sleep -Seconds 90 -# -# # Print the current user context -# Write-Output "Current User Context:" -# whoami -# -# # Print all available services after initial wait -# Write-Output "Listing all services after initial wait:" -# Get-Service | Select-Object -Property Name, Status -# -# # Print the GitHub Actions runner installation directory -# Write-Output "Checking runner installation directory..." -# if (Test-Path -Path "C:\actions-runner") { -# Write-Output "Runner directory found, listing contents..." -# Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name -# } else { -# Write-Error "Runner installation directory not found at expected path: C:\actions-runner" -# Write-Output "Attempting to reinstall GitHub Actions runner..." -# -# # Attempt to download and install the GitHub Actions runner manually -# New-Item -ItemType Directory -Force -Path "C:\actions-runner" -# Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -# Write-Output "Extracting runner package..." -# Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -# Remove-Item "C:\actions-runner\actions-runner.zip" -# -# Write-Output "Running GitHub Actions runner configuration script..." -# Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait -# Write-Output "Runner configuration completed." -# } -# -# # Print all running processes to check for runner process by keyword -# Write-Output "Searching for running processes related to runner..." -# Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName -# -# # Print environment variables to diagnose context issues -# Write-Output "Listing environment variables:" -# Get-ChildItem Env: -# -# # Inform about stopping the GitHub Actions Runner service -# Write-Output "Stopping GitHub Actions Runner service..." -# -# # Initialize retry count and max retry values for attempts to stop and reconfigure the service -# $retryCount = 0 -# $maxRetries = 5 -# $success = $false -# -# # Loop until the service is successfully reconfigured or maximum retries are reached -# while (-not $success -and $retryCount -lt $maxRetries) { -# try { -# # Get the GitHub Actions Runner service name dynamically using broader wildcard -# $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -# -# # If the service is not found, print available services and retry after a delay -# if (-not $serviceName) { -# Write-Error "GitHub Actions runner service not found. Printing available services..." -# Get-Service | Select-Object -Property Name, Status -# Write-Error "Retrying in 30 seconds..." -# Start-Sleep -Seconds 30 -# $retryCount++ -# continue -# } -# -# # Stop the runner service forcefully -# Stop-Service -Name $serviceName -Force -# Write-Output "Service stopped: $serviceName" -# -# # Reconfigure the service to use the non-admin user credentials -# Write-Output "Reconfiguring the service to use nonadmin user..." -# sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" -# Write-Output "Service reconfiguration command executed." -# -# # Start the GitHub Actions Runner service again -# Start-Service -Name $serviceName -# Write-Output "Service restarted successfully." -# -# # Verify that the service is running under the non-admin user -# $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName -# Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" -# -# # Set success flag if the service is running as non-admin -# if ($updatedService.StartName -eq ".\nonadmin") { -# $success = $true -# } else { -# Write-Output "Service is not running as nonadmin, retrying..." -# $retryCount++ -# Start-Sleep -Seconds 30 -# } -# } catch { -# # Handle errors during reconfiguration and retry -# Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." -# Start-Sleep -Seconds 30 -# $retryCount++ -# } -# } -# -# # Throw an error if reconfiguration fails after all retries -# if (-not $success) { -# throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." -# } -# } catch { -# # Handle the case where reconfiguration fails completely -# Write-Host "Failed to configure the runner service: $_.Exception.Message" -# exit 1 -# } + configure-ec2: + needs: provision-ec2 + runs-on: ${{ needs.provision-ec2.outputs.label }} + steps: + - name: Reconfigure Runner Service to Use Non-Admin User + shell: powershell + env: + NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} + run: | + try { + # Initial delay to allow the GitHub Actions Runner service to start + Write-Output "Waiting for GitHub Actions Runner service to initialize..." + Start-Sleep -Seconds 90 + + # Print the current user context + Write-Output "Current User Context:" + whoami + + # Print all available services after initial wait + Write-Output "Listing all services after initial wait:" + Get-Service | Select-Object -Property Name, Status + + # Print the GitHub Actions runner installation directory + Write-Output "Checking runner installation directory..." + if (Test-Path -Path "C:\actions-runner") { + Write-Output "Runner directory found, listing contents..." + Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name + } else { + Write-Error "Runner installation directory not found at expected path: C:\actions-runner" + Write-Output "Attempting to reinstall GitHub Actions runner..." + + # Attempt to create the directory for GitHub Actions runner installation + Write-Output "Creating runner installation directory..." + try { + New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose + Write-Output "Directory created successfully." + } catch { + Write-Error "Failed to create directory: $_.Exception.Message" + exit 1 + } + + # Attempt to download and install the GitHub Actions runner manually + try { + Write-Output "Downloading GitHub Actions runner package..." + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose -ErrorAction Stop + Write-Output "Download completed successfully." + } catch { + Write-Error "Failed to download runner package: $_.Exception.Message" + exit 1 + } + + # Attempt to extract the runner package + try { + Write-Output "Extracting runner package..." + Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose -ErrorAction Stop + Remove-Item "C:\actions-runner\actions-runner.zip" + Write-Output "Extraction completed successfully." + } catch { + Write-Error "Failed to extract runner package: $_.Exception.Message" + exit 1 + } + + # Attempt to run the GitHub Actions runner configuration script as non-admin + try { + Write-Output "Running GitHub Actions runner configuration script as non-admin user..." + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) + Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait + Write-Output "Runner configuration completed." + } catch { + Write-Error "Failed to configure the runner as non-admin: $_.Exception.Message" + exit 1 + } + } + + # Print all running processes to check for runner process by keyword + Write-Output "Searching for running processes related to runner..." + Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName + + # Print environment variables to diagnose context issues + Write-Output "Listing environment variables:" + Get-ChildItem Env: + + # Inform about stopping the GitHub Actions Runner service + Write-Output "Stopping GitHub Actions Runner service..." + + # Initialize retry count and max retry values for attempts to stop and reconfigure the service + $retryCount = 0 + $maxRetries = 5 + $success = $false + + # Loop until the service is successfully reconfigured or maximum retries are reached + while (-not $success -and $retryCount -lt $maxRetries) { + try { + # Get the GitHub Actions Runner service name dynamically using broader wildcard + $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + + # If the service is not found, print available services and retry after a delay + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found. Printing available services..." + Get-Service | Select-Object -Property Name, Status + Write-Error "Retrying in 30 seconds..." + Start-Sleep -Seconds 30 + $retryCount++ + continue + } + + # Stop the runner service forcefully + Stop-Service -Name $serviceName -Force + Write-Output "Service stopped: $serviceName" + + # Reconfigure the service to use the non-admin user credentials + Write-Output "Reconfiguring the service to use nonadmin user..." + sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" + Write-Output "Service reconfiguration command executed." + + # Start the GitHub Actions Runner service again + Start-Service -Name $serviceName + Write-Output "Service restarted successfully." + + # Verify that the service is running under the non-admin user + $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName + Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + + # Set success flag if the service is running as non-admin + if ($updatedService.StartName -eq ".\nonadmin") { + $success = $true + } else { + Write-Output "Service is not running as nonadmin, retrying..." + $retryCount++ + Start-Sleep -Seconds 30 + } + } catch { + # Handle errors during reconfiguration and retry + Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." + Start-Sleep -Seconds 30 + $retryCount++ + } + } + + # Throw an error if reconfiguration fails after all retries + if (-not $success) { + throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." + } + } catch { + # Handle the case where reconfiguration fails completely + Write-Host "Failed to configure the runner service: $_.Exception.Message" + exit 1 + } From c678da57f85e5d5c4e5c814b8dd647907d2d4ff5 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 11:51:57 +0200 Subject: [PATCH 100/157] execute the entire installation and configuration process under the non-admin Signed-off-by: midays --- .github/workflows/provision-runner.yml | 67 +++++++++++--------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 90f58ff..ae8f3b1 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -105,57 +105,48 @@ jobs: Write-Output "Listing all services after initial wait:" Get-Service | Select-Object -Property Name, Status - # Print the GitHub Actions runner installation directory - Write-Output "Checking runner installation directory..." - if (Test-Path -Path "C:\actions-runner") { - Write-Output "Runner directory found, listing contents..." - Get-ChildItem -Path "C:\actions-runner" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName, Name - } else { - Write-Error "Runner installation directory not found at expected path: C:\actions-runner" - Write-Output "Attempting to reinstall GitHub Actions runner..." - - # Attempt to create the directory for GitHub Actions runner installation - Write-Output "Creating runner installation directory..." + Write-Output "Checking if runner directory exists..." + if (-not (Test-Path -Path "C:\actions-runner")) { + Write-Output "Runner directory not found, creating directory..." try { New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose - Write-Output "Directory created successfully." + Write-Output "Runner directory created successfully." } catch { - Write-Error "Failed to create directory: $_.Exception.Message" + Write-Error "Failed to create runner directory: $_.Exception.Message" exit 1 } + } else { + Write-Output "Runner directory already exists." + } - # Attempt to download and install the GitHub Actions runner manually - try { + # Download and install the GitHub Actions runner manually as non-admin user + try { + Write-Output "Running GitHub Actions runner installation as non-admin user..." + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) + + # Download runner + Start-Process -FilePath "powershell.exe" -ArgumentList { Write-Output "Downloading GitHub Actions runner package..." - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose -ErrorAction Stop + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose Write-Output "Download completed successfully." - } catch { - Write-Error "Failed to download runner package: $_.Exception.Message" - exit 1 - } + } -Credential $credential -NoNewWindow -Wait - # Attempt to extract the runner package - try { + # Extract runner + Start-Process -FilePath "powershell.exe" -ArgumentList { Write-Output "Extracting runner package..." - Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose -ErrorAction Stop + Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose Remove-Item "C:\actions-runner\actions-runner.zip" Write-Output "Extraction completed successfully." - } catch { - Write-Error "Failed to extract runner package: $_.Exception.Message" - exit 1 - } + } -Credential $credential -NoNewWindow -Wait - # Attempt to run the GitHub Actions runner configuration script as non-admin - try { - Write-Output "Running GitHub Actions runner configuration script as non-admin user..." - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait - Write-Output "Runner configuration completed." - } catch { - Write-Error "Failed to configure the runner as non-admin: $_.Exception.Message" - exit 1 - } + # Configure runner + Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait + Write-Output "Runner configuration completed as non-admin user." + + } catch { + Write-Error "Failed to install or configure the runner: $_.Exception.Message" + exit 1 } # Print all running processes to check for runner process by keyword From bcd81164f7952abcce29d64b93d5b249b671bb32 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 12:10:35 +0200 Subject: [PATCH 101/157] Run the Entire Configuration Process as a Non-Admin User. Improved Logging and Capture Output. Add Detailed Error Handling for Each Step. Signed-off-by: midays --- .github/workflows/provision-runner.yml | 139 ++++++++++--------------- 1 file changed, 53 insertions(+), 86 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index ae8f3b1..5769787 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -97,91 +97,62 @@ jobs: Write-Output "Waiting for GitHub Actions Runner service to initialize..." Start-Sleep -Seconds 90 - # Print the current user context - Write-Output "Current User Context:" - whoami - - # Print all available services after initial wait - Write-Output "Listing all services after initial wait:" - Get-Service | Select-Object -Property Name, Status - - Write-Output "Checking if runner directory exists..." - if (-not (Test-Path -Path "C:\actions-runner")) { - Write-Output "Runner directory not found, creating directory..." - try { - New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose - Write-Output "Runner directory created successfully." - } catch { - Write-Error "Failed to create runner directory: $_.Exception.Message" - exit 1 + # Run everything from here under the non-admin context + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) + + # Creating a new PowerShell session under the non-admin user to execute all commands + Write-Output "Switching to non-admin context for further operations..." + $session = New-PSSession -Credential $credential + + # Script block to run as non-admin + $scriptBlock = { + # Print the current user context + Write-Output "Current User Context:" + whoami + + # Create runner installation directory if it doesn't exist + Write-Output "Checking if runner directory exists..." + if (-not (Test-Path -Path "C:\actions-runner")) { + Write-Output "Runner directory not found, creating directory..." + try { + New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose + Write-Output "Runner directory created successfully." + } catch { + Write-Error "Failed to create runner directory: $_.Exception.Message" + exit 1 + } + } else { + Write-Output "Runner directory already exists." } - } else { - Write-Output "Runner directory already exists." - } - # Download and install the GitHub Actions runner manually as non-admin user - try { - Write-Output "Running GitHub Actions runner installation as non-admin user..." - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - - # Download runner - Start-Process -FilePath "powershell.exe" -ArgumentList { + # Download and install the GitHub Actions runner manually + try { Write-Output "Downloading GitHub Actions runner package..." Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose Write-Output "Download completed successfully." - } -Credential $credential -NoNewWindow -Wait - # Extract runner - Start-Process -FilePath "powershell.exe" -ArgumentList { + # Extract runner Write-Output "Extracting runner package..." Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose Remove-Item "C:\actions-runner\actions-runner.zip" Write-Output "Extraction completed successfully." - } -Credential $credential -NoNewWindow -Wait - - # Configure runner - Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait - Write-Output "Runner configuration completed as non-admin user." - - } catch { - Write-Error "Failed to install or configure the runner: $_.Exception.Message" - exit 1 - } - # Print all running processes to check for runner process by keyword - Write-Output "Searching for running processes related to runner..." - Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName + # Configure runner + Write-Output "Running GitHub Actions runner configuration script..." + Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait -RedirectStandardOutput "C:\actions-runner\config-output.log" -RedirectStandardError "C:\actions-runner\config-error.log" + Write-Output "Runner configuration completed." - # Print environment variables to diagnose context issues - Write-Output "Listing environment variables:" - Get-ChildItem Env: - - # Inform about stopping the GitHub Actions Runner service - Write-Output "Stopping GitHub Actions Runner service..." + } catch { + Write-Error "Failed to install or configure the runner: $_.Exception.Message" + exit 1 + } - # Initialize retry count and max retry values for attempts to stop and reconfigure the service - $retryCount = 0 - $maxRetries = 5 - $success = $false - - # Loop until the service is successfully reconfigured or maximum retries are reached - while (-not $success -and $retryCount -lt $maxRetries) { - try { - # Get the GitHub Actions Runner service name dynamically using broader wildcard - $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + # Stopping and reconfiguring the runner service to run as non-admin + Write-Output "Stopping GitHub Actions Runner service..." + $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - # If the service is not found, print available services and retry after a delay - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Printing available services..." - Get-Service | Select-Object -Property Name, Status - Write-Error "Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ - continue - } - - # Stop the runner service forcefully + if ($serviceName) { Stop-Service -Name $serviceName -Force Write-Output "Service stopped: $serviceName" @@ -198,26 +169,22 @@ jobs: $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - # Set success flag if the service is running as non-admin - if ($updatedService.StartName -eq ".\nonadmin") { - $success = $true + if ($updatedService.StartName -eq ".\\nonadmin") { + Write-Output "Service successfully running as non-admin user." } else { - Write-Output "Service is not running as nonadmin, retrying..." - $retryCount++ - Start-Sleep -Seconds 30 + Write-Output "Service is not running as nonadmin, please verify manually." } - } catch { - # Handle errors during reconfiguration and retry - Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ + } else { + Write-Error "GitHub Actions runner service not found." } } - # Throw an error if reconfiguration fails after all retries - if (-not $success) { - throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." - } + # Invoke the script block as the non-admin user + Invoke-Command -Session $session -ScriptBlock $scriptBlock + + # Remove the PowerShell session + Remove-PSSession -Session $session + } catch { # Handle the case where reconfiguration fails completely Write-Host "Failed to configure the runner service: $_.Exception.Message" From 2ddce5b02065f755be327ac5bb865aa15edefc33 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 13:31:01 +0200 Subject: [PATCH 102/157] removing the use of remote PowerShell sessions (New-PSSession). Instead, commands that need non-admin credentials are run using Start-Process with appropriate arguments Signed-off-by: midays --- .github/workflows/provision-runner.yml | 140 +++++++++++++++---------- 1 file changed, 87 insertions(+), 53 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 5769787..aa9e2bc 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -97,62 +97,92 @@ jobs: Write-Output "Waiting for GitHub Actions Runner service to initialize..." Start-Sleep -Seconds 90 - # Run everything from here under the non-admin context - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - - # Creating a new PowerShell session under the non-admin user to execute all commands - Write-Output "Switching to non-admin context for further operations..." - $session = New-PSSession -Credential $credential - - # Script block to run as non-admin - $scriptBlock = { - # Print the current user context - Write-Output "Current User Context:" - whoami - - # Create runner installation directory if it doesn't exist - Write-Output "Checking if runner directory exists..." - if (-not (Test-Path -Path "C:\actions-runner")) { - Write-Output "Runner directory not found, creating directory..." - try { - New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose - Write-Output "Runner directory created successfully." - } catch { - Write-Error "Failed to create runner directory: $_.Exception.Message" - exit 1 - } - } else { - Write-Output "Runner directory already exists." + # Print the current user context + Write-Output "Current User Context:" + whoami + + # Print all available services after initial wait + Write-Output "Listing all services after initial wait:" + Get-Service | Select-Object -Property Name, Status + + # Create runner installation directory if it doesn't exist + Write-Output "Checking if runner directory exists..." + if (-not (Test-Path -Path "C:\actions-runner")) { + Write-Output "Runner directory not found, creating directory..." + try { + New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose + Write-Output "Runner directory created successfully." + } catch { + Write-Error "Failed to create runner directory: $_.Exception.Message" + exit 1 } + } else { + Write-Output "Runner directory already exists." + } - # Download and install the GitHub Actions runner manually - try { + # Download and install the GitHub Actions runner manually as non-admin user + try { + Write-Output "Running GitHub Actions runner installation as non-admin user..." + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) + + # Download runner + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { Write-Output "Downloading GitHub Actions runner package..." Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose Write-Output "Download completed successfully." + } -Credential $credential -NoNewWindow -Wait - # Extract runner + # Extract runner + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { Write-Output "Extracting runner package..." Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose Remove-Item "C:\actions-runner\actions-runner.zip" Write-Output "Extraction completed successfully." + } -Credential $credential -NoNewWindow -Wait - # Configure runner - Write-Output "Running GitHub Actions runner configuration script..." - Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Wait -RedirectStandardOutput "C:\actions-runner\config-output.log" -RedirectStandardError "C:\actions-runner\config-error.log" - Write-Output "Runner configuration completed." + # Configure runner + Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait + Write-Output "Runner configuration completed as non-admin user." - } catch { - Write-Error "Failed to install or configure the runner: $_.Exception.Message" - exit 1 - } + } catch { + Write-Error "Failed to install or configure the runner: $_.Exception.Message" + exit 1 + } + + # Print all running processes to check for runner process by keyword + Write-Output "Searching for running processes related to runner..." + Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName + + # Print environment variables to diagnose context issues + Write-Output "Listing environment variables:" + Get-ChildItem Env: + + # Inform about stopping the GitHub Actions Runner service + Write-Output "Stopping GitHub Actions Runner service..." - # Stopping and reconfiguring the runner service to run as non-admin - Write-Output "Stopping GitHub Actions Runner service..." - $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + # Initialize retry count and max retry values for attempts to stop and reconfigure the service + $retryCount = 0 + $maxRetries = 5 + $success = $false + + # Loop until the service is successfully reconfigured or maximum retries are reached + while (-not $success -and $retryCount -lt $maxRetries) { + try { + # Get the GitHub Actions Runner service name dynamically using broader wildcard + $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - if ($serviceName) { + # If the service is not found, print available services and retry after a delay + if (-not $serviceName) { + Write-Error "GitHub Actions runner service not found. Printing available services..." + Get-Service | Select-Object -Property Name, Status + Write-Error "Retrying in 30 seconds..." + Start-Sleep -Seconds 30 + $retryCount++ + continue + } + + # Stop the runner service forcefully Stop-Service -Name $serviceName -Force Write-Output "Service stopped: $serviceName" @@ -169,22 +199,26 @@ jobs: $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - if ($updatedService.StartName -eq ".\\nonadmin") { - Write-Output "Service successfully running as non-admin user." + # Set success flag if the service is running as non-admin + if ($updatedService.StartName -eq ".\nonadmin") { + $success = $true } else { - Write-Output "Service is not running as nonadmin, please verify manually." + Write-Output "Service is not running as nonadmin, retrying..." + $retryCount++ + Start-Sleep -Seconds 30 } - } else { - Write-Error "GitHub Actions runner service not found." + } catch { + # Handle errors during reconfiguration and retry + Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." + Start-Sleep -Seconds 30 + $retryCount++ } } - # Invoke the script block as the non-admin user - Invoke-Command -Session $session -ScriptBlock $scriptBlock - - # Remove the PowerShell session - Remove-PSSession -Session $session - + # Throw an error if reconfiguration fails after all retries + if (-not $success) { + throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." + } } catch { # Handle the case where reconfiguration fails completely Write-Host "Failed to configure the runner service: $_.Exception.Message" From 914a33853946df6e5a8bb1a2e30003076e1a317e Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 14:31:01 +0200 Subject: [PATCH 103/157] This new approach aims to be straightforward and reduce the need for switching contexts, as switching between admin and non-admin contexts dynamically seems to be leading to the bulk of our issues. Signed-off-by: midays --- .github/workflows/provision-runner.yml | 152 +++++++------------------ 1 file changed, 42 insertions(+), 110 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index aa9e2bc..44516fd 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -87,140 +87,72 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: - - name: Reconfigure Runner Service to Use Non-Admin User + - name: Set up and Configure GitHub Actions Runner as Non-Admin shell: powershell env: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Initial delay to allow the GitHub Actions Runner service to start - Write-Output "Waiting for GitHub Actions Runner service to initialize..." + # Initial delay to allow EC2 instance to fully initialize + Write-Output "Waiting for EC2 instance services to initialize..." Start-Sleep -Seconds 90 - # Print the current user context + # STEP 1: Verify Current User Context Write-Output "Current User Context:" whoami - # Print all available services after initial wait - Write-Output "Listing all services after initial wait:" - Get-Service | Select-Object -Property Name, Status - - # Create runner installation directory if it doesn't exist + # STEP 2: Create actions-runner directory Write-Output "Checking if runner directory exists..." if (-not (Test-Path -Path "C:\actions-runner")) { - Write-Output "Runner directory not found, creating directory..." - try { - New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose - Write-Output "Runner directory created successfully." - } catch { - Write-Error "Failed to create runner directory: $_.Exception.Message" - exit 1 - } + Write-Output "Creating runner directory..." + New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose } else { Write-Output "Runner directory already exists." } - # Download and install the GitHub Actions runner manually as non-admin user - try { - Write-Output "Running GitHub Actions runner installation as non-admin user..." - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - - # Download runner - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { - Write-Output "Downloading GitHub Actions runner package..." - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose - Write-Output "Download completed successfully." - } -Credential $credential -NoNewWindow -Wait - - # Extract runner - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { - Write-Output "Extracting runner package..." - Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose - Remove-Item "C:\actions-runner\actions-runner.zip" - Write-Output "Extraction completed successfully." - } -Credential $credential -NoNewWindow -Wait - - # Configure runner - Start-Process -FilePath "C:\actions-runner\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO", "--token YOUR_TOKEN" -Credential $credential -NoNewWindow -Wait - Write-Output "Runner configuration completed as non-admin user." + # STEP 3: Download GitHub Actions Runner + Write-Output "Downloading GitHub Actions runner..." + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose - } catch { - Write-Error "Failed to install or configure the runner: $_.Exception.Message" - exit 1 - } + # STEP 4: Extract the Runner Package + Write-Output "Extracting runner package..." + Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose + Remove-Item "C:\actions-runner\actions-runner.zip" -Verbose - # Print all running processes to check for runner process by keyword - Write-Output "Searching for running processes related to runner..." - Get-Process | Where-Object { $_.ProcessName -like '*runner*' -or $_.ProcessName -like '*actions*' } | Select-Object -Property Id, ProcessName + # STEP 5: Configure Runner - Run as Administrator Initially + Write-Output "Configuring GitHub Actions runner..." + & "C:\actions-runner\config.cmd" --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN - # Print environment variables to diagnose context issues - Write-Output "Listing environment variables:" - Get-ChildItem Env: + # STEP 6: List Services to Verify + Write-Output "Listing all services after initial setup:" + Get-Service | Select-Object -Property Name, Status - # Inform about stopping the GitHub Actions Runner service - Write-Output "Stopping GitHub Actions Runner service..." + # STEP 7: Switch to Non-Admin for Service Configuration + Write-Output "Reconfiguring runner service to run as non-admin..." + $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - # Initialize retry count and max retry values for attempts to stop and reconfigure the service - $retryCount = 0 - $maxRetries = 5 - $success = $false - - # Loop until the service is successfully reconfigured or maximum retries are reached - while (-not $success -and $retryCount -lt $maxRetries) { - try { - # Get the GitHub Actions Runner service name dynamically using broader wildcard - $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name + if ($serviceName) { + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" + Write-Output "Service reconfiguration command executed." - # If the service is not found, print available services and retry after a delay - if (-not $serviceName) { - Write-Error "GitHub Actions runner service not found. Printing available services..." - Get-Service | Select-Object -Property Name, Status - Write-Error "Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ - continue - } - - # Stop the runner service forcefully - Stop-Service -Name $serviceName -Force - Write-Output "Service stopped: $serviceName" - - # Reconfigure the service to use the non-admin user credentials - Write-Output "Reconfiguring the service to use nonadmin user..." - sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" - Write-Output "Service reconfiguration command executed." - - # Start the GitHub Actions Runner service again - Start-Service -Name $serviceName - Write-Output "Service restarted successfully." - - # Verify that the service is running under the non-admin user - $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName - Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" - - # Set success flag if the service is running as non-admin - if ($updatedService.StartName -eq ".\nonadmin") { - $success = $true - } else { - Write-Output "Service is not running as nonadmin, retrying..." - $retryCount++ - Start-Sleep -Seconds 30 - } - } catch { - # Handle errors during reconfiguration and retry - Write-Output "An error occurred: $_.Exception.Message. Retrying in 30 seconds..." - Start-Sleep -Seconds 30 - $retryCount++ + # STEP 8: Restart the Runner Service + Start-Service -Name $serviceName + Write-Output "Service restarted successfully." + + # STEP 9: Validate the Service is Running as Non-Admin + $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName + Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + + if ($updatedService.StartName -eq ".\\nonadmin") { + Write-Output "Service is successfully running as non-admin user." + } else { + Write-Error "Service is not running as nonadmin, further investigation needed." } - } - - # Throw an error if reconfiguration fails after all retries - if (-not $success) { - throw "Failed to configure the runner service to run as nonadmin user after $maxRetries retries." + } else { + Write-Error "GitHub Actions runner service was not found." } } catch { - # Handle the case where reconfiguration fails completely - Write-Host "Failed to configure the runner service: $_.Exception.Message" + Write-Host "Failed during runner setup: $_.Exception.Message" exit 1 } From 1e239faee9a4bef755c399c9b15c53bd78efc0de Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 15:33:04 +0200 Subject: [PATCH 104/157] simple approach Signed-off-by: midays --- .github/workflows/provision-runner.yml | 78 ++++++++------------------ 1 file changed, 22 insertions(+), 56 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 44516fd..8ca46ec 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -87,72 +87,38 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: - - name: Set up and Configure GitHub Actions Runner as Non-Admin + - name: Setup GitHub Actions Runner as Non-Admin User shell: powershell env: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Initial delay to allow EC2 instance to fully initialize - Write-Output "Waiting for EC2 instance services to initialize..." - Start-Sleep -Seconds 90 + # Log in as non-admin and set up runner + $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # STEP 1: Verify Current User Context - Write-Output "Current User Context:" - whoami + # Run the complete setup process as the non-admin user + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + Write-Output "Setting up GitHub Actions Runner as non-admin user..." - # STEP 2: Create actions-runner directory - Write-Output "Checking if runner directory exists..." - if (-not (Test-Path -Path "C:\actions-runner")) { - Write-Output "Creating runner directory..." - New-Item -ItemType Directory -Force -Path "C:\actions-runner" -Verbose - } else { - Write-Output "Runner directory already exists." - } - - # STEP 3: Download GitHub Actions Runner - Write-Output "Downloading GitHub Actions runner..." - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose - - # STEP 4: Extract the Runner Package - Write-Output "Extracting runner package..." - Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" -Verbose - Remove-Item "C:\actions-runner\actions-runner.zip" -Verbose - - # STEP 5: Configure Runner - Run as Administrator Initially - Write-Output "Configuring GitHub Actions runner..." - & "C:\actions-runner\config.cmd" --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN + # Step 1: Create actions-runner directory + if (-not (Test-Path -Path "C:\actions-runner")) { + New-Item -ItemType Directory -Force -Path "C:\actions-runner" + } - # STEP 6: List Services to Verify - Write-Output "Listing all services after initial setup:" - Get-Service | Select-Object -Property Name, Status + # Step 2: Download GitHub Actions Runner + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose - # STEP 7: Switch to Non-Admin for Service Configuration - Write-Output "Reconfiguring runner service to run as non-admin..." - $serviceName = Get-Service -Name '*runner*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name - - if ($serviceName) { - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - sc.exe config $serviceName obj= ".\nonadmin" password= "$env:NONADMIN_PASSWORD" - Write-Output "Service reconfiguration command executed." - - # STEP 8: Restart the Runner Service - Start-Service -Name $serviceName - Write-Output "Service restarted successfully." + # Step 3: Extract the Runner Package + Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" + Remove-Item "C:\actions-runner\actions-runner.zip" - # STEP 9: Validate the Service is Running as Non-Admin - $updatedService = Get-Service -Name $serviceName | Select-Object Name, StartName - Write-Output "Service details: $($updatedService.Name) - Running as $($updatedService.StartName)" + # Step 4: Configure the Runner + & "C:\actions-runner\config.cmd" --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN - if ($updatedService.StartName -eq ".\\nonadmin") { - Write-Output "Service is successfully running as non-admin user." - } else { - Write-Error "Service is not running as nonadmin, further investigation needed." - } - } else { - Write-Error "GitHub Actions runner service was not found." - } + Write-Output "Runner setup as non-admin completed successfully." + } -Credential $credential -NoNewWindow -Wait } catch { - Write-Host "Failed during runner setup: $_.Exception.Message" + Write-Error "Failed to setup the runner as non-admin user: $_.Exception.Message" exit 1 - } + } \ No newline at end of file From 03090750951aaecb73bb9282588fc365f305157e Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 15:43:21 +0200 Subject: [PATCH 105/157] make the non-admin takeover the runner Signed-off-by: midays --- .github/workflows/provision-runner.yml | 50 +++++++++++++++++--------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 8ca46ec..d179b1e 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -87,38 +87,56 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: - - name: Setup GitHub Actions Runner as Non-Admin User + - name: Set Up GitHub Actions Runner as Non-Admin User shell: powershell env: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Log in as non-admin and set up runner + # Initial delay to allow the GitHub Actions Runner service to start + Write-Output "Waiting for GitHub Actions Runner service to initialize..." + Start-Sleep -Seconds 90 + + # Log in as non-admin user $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Run the complete setup process as the non-admin user + # Step 1: Create runner directory as non-admin Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { - Write-Output "Setting up GitHub Actions Runner as non-admin user..." - - # Step 1: Create actions-runner directory - if (-not (Test-Path -Path "C:\actions-runner")) { - New-Item -ItemType Directory -Force -Path "C:\actions-runner" + if (-not (Test-Path -Path 'C:\actions-runner')) { + New-Item -ItemType Directory -Force -Path 'C:\actions-runner' + Write-Output "Runner directory created." + } else { + Write-Output "Runner directory already exists." } + } -Credential $credential -NoNewWindow -Wait - # Step 2: Download GitHub Actions Runner - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" -Verbose + # Step 2: Download GitHub Actions runner as non-admin + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + Write-Output "Downloading GitHub Actions runner..." + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" + Write-Output "Download complete." + } -Credential $credential -NoNewWindow -Wait - # Step 3: Extract the Runner Package + # Step 3: Extract runner package as non-admin + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + Write-Output "Extracting GitHub Actions runner package..." Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" Remove-Item "C:\actions-runner\actions-runner.zip" + Write-Output "Extraction complete." + } -Credential $credential -NoNewWindow -Wait - # Step 4: Configure the Runner + # Step 4: Configure GitHub Actions runner as non-admin + Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + Write-Output "Configuring the GitHub Actions runner..." & "C:\actions-runner\config.cmd" --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN - - Write-Output "Runner setup as non-admin completed successfully." + Write-Output "Runner configuration completed." } -Credential $credential -NoNewWindow -Wait + + # Step 5: Run the GitHub Actions runner as non-admin + Start-Process -FilePath "C:\actions-runner\run.cmd" -Credential $credential -NoNewWindow + Write-Output "Runner is now running under non-admin user." } catch { - Write-Error "Failed to setup the runner as non-admin user: $_.Exception.Message" + Write-Error "Failed to set up the runner as non-admin user: $_.Exception.Message" exit 1 - } \ No newline at end of file + } From 9b92713202fcd4f410964e7a8cf3a7ddfd23c26a Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 15:52:10 +0200 Subject: [PATCH 106/157] try to switch to non-admin user in a single session Signed-off-by: midays --- .github/workflows/provision-runner.yml | 52 ++++++++++++-------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index d179b1e..fc83024 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -87,55 +87,49 @@ jobs: needs: provision-ec2 runs-on: ${{ needs.provision-ec2.outputs.label }} steps: - - name: Set Up GitHub Actions Runner as Non-Admin User + - name: Setup GitHub Actions Runner as Non-Admin User shell: powershell env: NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} run: | try { - # Initial delay to allow the GitHub Actions Runner service to start - Write-Output "Waiting for GitHub Actions Runner service to initialize..." - Start-Sleep -Seconds 90 - - # Log in as non-admin user + # Initial delay to allow the EC2 instance to fully initialize + Write-Output "Waiting for EC2 instance services to initialize..." + Start-Sleep -Seconds 60 + + # Step 1: Create runner directory as non-admin $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - - # Step 1: Create runner directory as non-admin - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + Start-Process -FilePath "powershell.exe" -Credential $credential -ArgumentList "-Command", { if (-not (Test-Path -Path 'C:\actions-runner')) { New-Item -ItemType Directory -Force -Path 'C:\actions-runner' Write-Output "Runner directory created." } else { Write-Output "Runner directory already exists." } - } -Credential $credential -NoNewWindow -Wait - - # Step 2: Download GitHub Actions runner as non-admin - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + + # Step 2: Download GitHub Actions Runner Write-Output "Downloading GitHub Actions runner..." Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" - Write-Output "Download complete." - } -Credential $credential -NoNewWindow -Wait - - # Step 3: Extract runner package as non-admin - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + + # Step 3: Extract the Runner Package Write-Output "Extracting GitHub Actions runner package..." Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" Remove-Item "C:\actions-runner\actions-runner.zip" Write-Output "Extraction complete." - } -Credential $credential -NoNewWindow -Wait - - # Step 4: Configure GitHub Actions runner as non-admin - Start-Process -FilePath "powershell.exe" -ArgumentList "-Command", { + + # Step 4: Configure the Runner Write-Output "Configuring the GitHub Actions runner..." - & "C:\actions-runner\config.cmd" --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN - Write-Output "Runner configuration completed." - } -Credential $credential -NoNewWindow -Wait - - # Step 5: Run the GitHub Actions runner as non-admin - Start-Process -FilePath "C:\actions-runner\run.cmd" -Credential $credential -NoNewWindow - Write-Output "Runner is now running under non-admin user." + Set-Location -Path "C:\actions-runner" + Start-Process -FilePath "config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN" -NoNewWindow -Wait + + # Step 5: Run the GitHub Actions Runner + Write-Output "Starting the GitHub Actions runner..." + Start-Process -FilePath "run.cmd" -NoNewWindow + } -NoNewWindow -Wait + + Write-Output "GitHub Actions Runner setup complete as non-admin user." + } catch { Write-Error "Failed to set up the runner as non-admin user: $_.Exception.Message" exit 1 From c67ad625c2605a99dbc5c8a748b128d49438821a Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 16:17:46 +0200 Subject: [PATCH 107/157] diff appr Signed-off-by: midays --- .github/workflows/provision-runner.yml | 79 +++++++++----------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index fc83024..6db79b2 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -39,7 +39,7 @@ on: description: 'Personal Access Token For GH' required: true nonadmin-password: - description: 'Password for the nonadmin user' + description: 'Password for the non-admin user' required: true outputs: instance_label: @@ -77,60 +77,33 @@ jobs: ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} + user-data: | + + # Step 1: Create the test user + net user testuser ${{ secrets.nonadmin-password }} /add + net localgroup "Remote Desktop Users" testuser /add + net localgroup "Users" testuser /add + + # Step 2: Download and set up the GitHub Actions runner as the non-admin user + $runnerPath = "C:\actions-runner" + if (-not (Test-Path -Path $runnerPath)) { + New-Item -ItemType Directory -Force -Path $runnerPath + } + Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "$runnerPath\actions-runner.zip" + Expand-Archive -Path "$runnerPath\actions-runner.zip" -DestinationPath $runnerPath + Remove-Item "$runnerPath\actions-runner.zip" + + # Step 3: Configure the runner with test user credentials + $password = ConvertTo-SecureString -String "${{ secrets.nonadmin-password }}" -AsPlainText -Force + $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "testuser", $password + + Start-Process -FilePath "$runnerPath\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO --token ${{ secrets.github-token }}" -Credential $credential -NoNewWindow -Wait + + # Step 4: Run the GitHub Actions runner as the test user + Start-Process -FilePath "$runnerPath\run.cmd" -Credential $credential -NoNewWindow + - name: Output EC2 Instance ID run: | echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}" echo "Label : ${{ steps.ec2.outputs.label }}" - - configure-ec2: - needs: provision-ec2 - runs-on: ${{ needs.provision-ec2.outputs.label }} - steps: - - name: Setup GitHub Actions Runner as Non-Admin User - shell: powershell - env: - NONADMIN_PASSWORD: ${{ secrets.nonadmin-password }} - run: | - try { - # Initial delay to allow the EC2 instance to fully initialize - Write-Output "Waiting for EC2 instance services to initialize..." - Start-Sleep -Seconds 60 - - # Step 1: Create runner directory as non-admin - $password = ConvertTo-SecureString "$env:NONADMIN_PASSWORD" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - Start-Process -FilePath "powershell.exe" -Credential $credential -ArgumentList "-Command", { - if (-not (Test-Path -Path 'C:\actions-runner')) { - New-Item -ItemType Directory -Force -Path 'C:\actions-runner' - Write-Output "Runner directory created." - } else { - Write-Output "Runner directory already exists." - } - - # Step 2: Download GitHub Actions Runner - Write-Output "Downloading GitHub Actions runner..." - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "C:\actions-runner\actions-runner.zip" - - # Step 3: Extract the Runner Package - Write-Output "Extracting GitHub Actions runner package..." - Expand-Archive -Path "C:\actions-runner\actions-runner.zip" -DestinationPath "C:\actions-runner" - Remove-Item "C:\actions-runner\actions-runner.zip" - Write-Output "Extraction complete." - - # Step 4: Configure the Runner - Write-Output "Configuring the GitHub Actions runner..." - Set-Location -Path "C:\actions-runner" - Start-Process -FilePath "config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_TOKEN" -NoNewWindow -Wait - - # Step 5: Run the GitHub Actions Runner - Write-Output "Starting the GitHub Actions runner..." - Start-Process -FilePath "run.cmd" -NoNewWindow - } -NoNewWindow -Wait - - Write-Output "GitHub Actions Runner setup complete as non-admin user." - - } catch { - Write-Error "Failed to set up the runner as non-admin user: $_.Exception.Message" - exit 1 - } From 5fa1dc2e0565faf1825185dc1b12fa593926e868 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 16:24:38 +0200 Subject: [PATCH 108/157] change user-data to pre-runner-script Signed-off-by: midays --- .github/workflows/provision-runner.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 6db79b2..d97df37 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -38,7 +38,7 @@ on: github-token: description: 'Personal Access Token For GH' required: true - nonadmin-password: + testuser-password: description: 'Password for the non-admin user' required: true outputs: @@ -77,7 +77,7 @@ jobs: ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} - user-data: | + pre-runner-script: | # Step 1: Create the test user net user testuser ${{ secrets.nonadmin-password }} /add From b60ea6b8d4912b56c70feda8942dbc0463f85aa6 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 2 Dec 2024 16:25:43 +0200 Subject: [PATCH 109/157] fix var name Signed-off-by: midays --- .github/workflows/provision-runner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index d97df37..5df5c2b 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -38,7 +38,7 @@ on: github-token: description: 'Personal Access Token For GH' required: true - testuser-password: + nonadmin-password: description: 'Password for the non-admin user' required: true outputs: From 6d71e4b5d0eee422d8e95cb2c08fd3694739dabe Mon Sep 17 00:00:00 2001 From: midays Date: Sat, 7 Dec 2024 19:10:37 +0200 Subject: [PATCH 110/157] comment checking specific branch Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 1cf5e81..59aeb47 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -112,7 +112,7 @@ jobs: cd C:\actions-runner\work git clone https://github.com/konveyor/kai-ci.git cd ./kai-ci - git checkout windows-vm +# git checkout windows-vm - name: Install npm dependencies shell: powershell From a3ea6a15b26cf6f3c65d497b255da4a28818cbb1 Mon Sep 17 00:00:00 2001 From: midays Date: Sat, 7 Dec 2024 19:35:14 +0200 Subject: [PATCH 111/157] try to start a new non-admin session inside the admin session. Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 145 ++++++----------------- 1 file changed, 37 insertions(+), 108 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 59aeb47..ac04aab 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,147 +21,76 @@ jobs: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - - name: Install Chocolatey - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - shell: powershell - - - name: Install Node.js - run: choco install nodejs -y + - name: Write Test Script shell: powershell + run: | + $scriptContent = @" + # Install Chocolatey + # Set-ExecutionPolicy Bypass -Scope Process -Force; + # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + # iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - - name: Install VSCode - run: choco install vscode -y - shell: powershell + # Install Node.js + # choco install nodejs -y - - name: Define Node.js and VSCode Paths - shell: powershell - run: | + # Install VSCode + # choco install vscode -y + # Define Node.js and VSCode Paths + $nodePath = 'C:\Program Files\nodejs' - $vscodePath = 'C:\Program Files\Microsoft VS Code\bin' - - # Update PATH so that Node.js, npm, npx, and VSCode can be called directly + #$vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe' $newPath = "$env:PATH;$nodePath;$vscodePath" [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - - # Persist the updated PATH to make it available for subsequent steps "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append -# - name: Check Visual Studio Code and Node.js Installation Paths -# shell: powershell -# run: | -# # Check if Visual Studio Code is installed and print the installation path -# $vscodePaths = @( -# 'C:\Program Files\Microsoft VS Code\Code.exe', -# 'C:\Users\*\AppData\Local\Programs\Microsoft VS Code\Code.exe' -# ) -# -# $vscodeInstalled = $false -# -# foreach ($path in $vscodePaths) { -# $resolvedPaths = Get-ChildItem -Path $path -ErrorAction SilentlyContinue -# foreach ($resolvedPath in $resolvedPaths) { -# Write-Output "VSCode is installed at: $($resolvedPath.FullName)" -# $vscodeInstalled = $true -# } -# } -# -# if (-not $vscodeInstalled) { -# Write-Output "VSCode is not installed." -# } -# -# # Check if Node.js is installed and print the installation path -# try { -# $nodejsPath = (& where.exe node) -# Write-Output "Node.js is installed at: $nodejsPath" -# } catch { -# Write-Output "Node.js is not installed." -# } - - - - name: Print PATH Environment Variable - shell: powershell - run: | - Write-Output "Updated PATH: $env:PATH" + # Print Current User + Write-Output "Current User: $(whoami)" - - name: Verify VSCode and Node.js Installation - shell: powershell - run: | + # Verify VSCode and Node.js Installation code --version node --version - - name: Close All VSCode Instances - shell: powershell - run: | - # Close all running instances of VSCode + # Close All VSCode Instances Get-Process -Name "Code" -ErrorAction SilentlyContinue | ForEach-Object { $_.CloseMainWindow() } | Out-Null - - name: Create Temporary Work Directory - shell: powershell - run: | - # Creating a directory outside System32 for better permissions + # Create Temporary Work Directory New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force - - name: Clone kai-ci repo - shell: powershell - run: | + # Clone kai-ci repo cd C:\actions-runner\work git clone https://github.com/konveyor/kai-ci.git cd ./kai-ci -# git checkout windows-vm - - name: Install npm dependencies - shell: powershell - working-directory: C:\actions-runner\work\kai-ci - run: | + # Install npm dependencies npm install . npm ci - - name: Copy .env.example to .env and update executable path - shell: powershell - working-directory: C:\actions-runner\work\kai-ci - run: | + # Copy .env.example to .env and update executable path Copy-Item -Path .env.example -Destination .env (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | ForEach-Object { $_ -replace "DEFAULT_VSIX_DOWNLOAD_URL=.*", "DEFAULT_VSIX_DOWNLOAD_URL='https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-windows-0.0.1.vsix'" } | Set-Content .env - - name: Run tests - shell: powershell - continue-on-error: true # Allow this step to continue even if some tests fail - working-directory: C:\actions-runner\work\kai-ci - run: | - npx playwright test - - - name: Upload screenshots - uses: actions/upload-artifact@v4 - with: - name: vscode-screenshots - path: | - C:\actions-runner\work\kai-ci\vscode-initialized-screenshot.png - C:\actions-runner\work\kai-ci\kai-installed-screenshot.png - if: always() - - - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: playwright-report - path: C:\actions-runner\work\kai-ci\playwright-report\ - retention-days: 30 - - - name: Clean Up Kai Temp Directory - shell: powershell - run: | + # Run tests + npx playwright test + + # Clean Up Kai Temp Directory Remove-Item -Recurse -Force C:\actions-runner - if: always() + "@ + + $scriptPath = "C:\actions-runner\work\run-tests.ps1" + $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force + - name: Run Test Script as Non-Admin + shell: powershell + run: | + $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("testuser", $password) + Start-Process -FilePath "powershell.exe" -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" -Credential $credential -NoNewWindow -Wait stop-ec2-instance: - needs: [ start-ec2-instance,run-tests ] + needs: [ start-ec2-instance, run-tests ] if: always() uses: ./.github/workflows/remove-runner.yml with: From 5494be8f88724de4388639d20cb89392f224a5ea Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 13:03:47 +0200 Subject: [PATCH 112/157] Create directory before creating the script Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index ac04aab..12de7b8 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -24,20 +24,15 @@ jobs: - name: Write Test Script shell: powershell run: | + + # Ensure the directory exists + if (-not (Test-Path -Path "C:\actions-runner\work")) { + New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force + } + $scriptContent = @" - # Install Chocolatey - # Set-ExecutionPolicy Bypass -Scope Process -Force; - # [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; - # iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - - # Install Node.js - # choco install nodejs -y - - # Install VSCode - # choco install vscode -y # Define Node.js and VSCode Paths - $nodePath = 'C:\Program Files\nodejs' #$vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe' $newPath = "$env:PATH;$nodePath;$vscodePath" From 8726783dce8bd7a8279169e40cbbaf29faf9dbb4 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 13:15:17 +0200 Subject: [PATCH 113/157] change user from `testuser` to `nonadmin` Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 12de7b8..df56ee3 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -81,7 +81,7 @@ jobs: shell: powershell run: | $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("testuser", $password) + $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) Start-Process -FilePath "powershell.exe" -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" -Credential $credential -NoNewWindow -Wait stop-ec2-instance: From c518bd17ec58783fc1a33e72c2a4efe878576ddf Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 13:38:11 +0200 Subject: [PATCH 114/157] Redirect output to a log file Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index df56ee3..d431262 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -82,7 +82,17 @@ jobs: run: | $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - Start-Process -FilePath "powershell.exe" -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" -Credential $credential -NoNewWindow -Wait + + # Redirect output to log file + $logPath = "C:\actions-runner\work\run-tests.log" + Start-Process -FilePath "powershell.exe" ` + -ArgumentList "-File C:\actions-runner\work\run-tests.ps1 *>&1 | Out-File -FilePath $logPath -Append" ` + -Credential $credential ` + -NoNewWindow ` + -Wait + + # Output log file to GitHub Actions + Get-Content -Path $logPath -Wait stop-ec2-instance: needs: [ start-ec2-instance, run-tests ] From 2f244410acd248523ef88540351597c2c93eed46 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 14:07:07 +0200 Subject: [PATCH 115/157] applied to redirect the script's output and commands to a log file and then display the contents in the GitHub Actions runner logs Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d431262..433ade9 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -86,14 +86,17 @@ jobs: # Redirect output to log file $logPath = "C:\actions-runner\work\run-tests.log" Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-File C:\actions-runner\work\run-tests.ps1 *>&1 | Out-File -FilePath $logPath -Append" ` + -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" ` -Credential $credential ` -NoNewWindow ` + -RedirectStandardOutput $logPath ` + -RedirectStandardError $logPath ` -Wait # Output log file to GitHub Actions Get-Content -Path $logPath -Wait + stop-ec2-instance: needs: [ start-ec2-instance, run-tests ] if: always() From 29a321237d51fe3d0dd0c9aac4233370793844d6 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 14:19:43 +0200 Subject: [PATCH 116/157] updated the script in the canvas to ensure separate log files are used for standard output and error streams Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 433ade9..3887d63 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -83,18 +83,22 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Redirect output to log file - $logPath = "C:\actions-runner\work\run-tests.log" + # Redirect output to separate log files + $logPathOut = "C:\actions-runner\work\run-tests-output.log" + $logPathErr = "C:\actions-runner\work\run-tests-error.log" Start-Process -FilePath "powershell.exe" ` -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" ` -Credential $credential ` -NoNewWindow ` - -RedirectStandardOutput $logPath ` - -RedirectStandardError $logPath ` + -RedirectStandardOutput $logPathOut ` + -RedirectStandardError $logPathErr ` -Wait - # Output log file to GitHub Actions - Get-Content -Path $logPath -Wait + # Output log files to GitHub Actions + Write-Output "--- Standard Output ---" + Get-Content -Path $logPathOut -Wait + Write-Output "--- Standard Error ---" + Get-Content -Path $logPathErr -Wait stop-ec2-instance: From d2b666e42ea2ad6b63c239c654055e6597682ae3 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 15:18:39 +0200 Subject: [PATCH 117/157] updated the script in the canvas to ensure separate log files are used for standard output and error streams Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 3887d63..344f901 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -96,9 +96,9 @@ jobs: # Output log files to GitHub Actions Write-Output "--- Standard Output ---" - Get-Content -Path $logPathOut -Wait + Get-Content -Path $logPathOut Write-Output "--- Standard Error ---" - Get-Content -Path $logPathErr -Wait + Get-Content -Path $logPathErr stop-ec2-instance: From 634e460bdb9614c31d6170e91b74a95ab99269a5 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 16:27:02 +0200 Subject: [PATCH 118/157] change Redirection method for logs Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 344f901..d694fd5 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -83,15 +83,15 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Redirect output to separate log files + # Run the test script and redirect output + $scriptPath = "C:\actions-runner\work\run-tests.ps1" $logPathOut = "C:\actions-runner\work\run-tests-output.log" $logPathErr = "C:\actions-runner\work\run-tests-error.log" + Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-File C:\actions-runner\work\run-tests.ps1" ` + -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath *> $logPathOut 2> $logPathErr" ` -Credential $credential ` -NoNewWindow ` - -RedirectStandardOutput $logPathOut ` - -RedirectStandardError $logPathErr ` -Wait # Output log files to GitHub Actions @@ -101,6 +101,7 @@ jobs: Get-Content -Path $logPathErr + stop-ec2-instance: needs: [ start-ec2-instance, run-tests ] if: always() From 2800ddc7544d4829f86f32f5922527d62554eb4c Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 16:35:18 +0200 Subject: [PATCH 119/157] add checks Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d694fd5..956a241 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -83,22 +83,28 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Run the test script and redirect output + # Execute the script as non-admin user $scriptPath = "C:\actions-runner\work\run-tests.ps1" $logPathOut = "C:\actions-runner\work\run-tests-output.log" $logPathErr = "C:\actions-runner\work\run-tests-error.log" + # Inline redirection within the test script execution Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath *> $logPathOut 2> $logPathErr" ` + -ArgumentList "-Command Start-Transcript -Path $logPathOut; . $scriptPath; Stop-Transcript" ` -Credential $credential ` -NoNewWindow ` -Wait # Output log files to GitHub Actions - Write-Output "--- Standard Output ---" + Write-Output "--- Standard Output and Commands ---" Get-Content -Path $logPathOut + Write-Output "--- Standard Error ---" - Get-Content -Path $logPathErr + if (Test-Path $logPathErr) { + Get-Content -Path $logPathErr + } else { + Write-Output "No errors encountered." + } From e9156a54f4ae9ad797a7cde3217ddee3964d8442 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 17:11:51 +0200 Subject: [PATCH 120/157] switch to PSExec instead of the start-process Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 25 +++++++----------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 956a241..07bc76d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -83,30 +83,19 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Execute the script as non-admin user - $scriptPath = "C:\actions-runner\work\run-tests.ps1" + # Redirect output to separate log files $logPathOut = "C:\actions-runner\work\run-tests-output.log" $logPathErr = "C:\actions-runner\work\run-tests-error.log" - # Inline redirection within the test script execution - Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-Command Start-Transcript -Path $logPathOut; . $scriptPath; Stop-Transcript" ` - -Credential $credential ` - -NoNewWindow ` - -Wait + # Using PSExec for non-admin execution + $psexecPath = "C:\Path\To\PsExec.exe" # Ensure PsExec is available + & $psexecPath -accepteula -u nonadmin -p $password -w "C:\actions-runner\work" powershell.exe -File $scriptPath > $logPathOut 2> $logPathErr # Output log files to GitHub Actions - Write-Output "--- Standard Output and Commands ---" - Get-Content -Path $logPathOut - + Write-Output "--- Standard Output ---" + Get-Content -Path $logPathOut -Wait Write-Output "--- Standard Error ---" - if (Test-Path $logPathErr) { - Get-Content -Path $logPathErr - } else { - Write-Output "No errors encountered." - } - - + Get-Content -Path $logPathErr -Wait stop-ec2-instance: needs: [ start-ec2-instance, run-tests ] From 4b0def09a5bf5e5d522a3b15c55bb2cae9c6f416 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 17:26:44 +0200 Subject: [PATCH 121/157] comment removal of ec2 instance Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 07bc76d..6221e57 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -97,14 +97,14 @@ jobs: Write-Output "--- Standard Error ---" Get-Content -Path $logPathErr -Wait - stop-ec2-instance: - needs: [ start-ec2-instance, run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} +# stop-ec2-instance: +# needs: [ start-ec2-instance, run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From 07d15ed40dc3766712890492de2ae9b70b496de9 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 18:40:17 +0200 Subject: [PATCH 122/157] commands to just print the versions Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 39 ------------------------ 1 file changed, 39 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 6221e57..66f6526 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -31,47 +31,8 @@ jobs: } $scriptContent = @" - - # Define Node.js and VSCode Paths - $nodePath = 'C:\Program Files\nodejs' - #$vscodePath = 'C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe' - $newPath = "$env:PATH;$nodePath;$vscodePath" - [System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Process) - "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Append - - # Print Current User - Write-Output "Current User: $(whoami)" - - # Verify VSCode and Node.js Installation code --version node --version - - # Close All VSCode Instances - Get-Process -Name "Code" -ErrorAction SilentlyContinue | ForEach-Object { $_.CloseMainWindow() } | Out-Null - - # Create Temporary Work Directory - New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force - - # Clone kai-ci repo - cd C:\actions-runner\work - git clone https://github.com/konveyor/kai-ci.git - cd ./kai-ci - - # Install npm dependencies - npm install . - npm ci - - # Copy .env.example to .env and update executable path - Copy-Item -Path .env.example -Destination .env - (Get-Content .env) -replace "VSCODE_EXECUTABLE_PATH=.*", "VSCODE_EXECUTABLE_PATH='C:/Program Files/Microsoft VS Code/Code.exe'" | - ForEach-Object { $_ -replace "DEFAULT_VSIX_DOWNLOAD_URL=.*", "DEFAULT_VSIX_DOWNLOAD_URL='https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-windows-0.0.1.vsix'" } | - Set-Content .env - - # Run tests - npx playwright test - - # Clean Up Kai Temp Directory - Remove-Item -Recurse -Force C:\actions-runner "@ $scriptPath = "C:\actions-runner\work\run-tests.ps1" From 64ddb620fb788f8be041b830189b814415bfb617 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 19:12:26 +0200 Subject: [PATCH 123/157] install nodeJS, and check versions Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 66f6526..2ca92f0 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,6 +21,17 @@ jobs: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: + - name: Install nodeJS + shell: powershell + run: | + if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { + Set-ExecutionPolicy Bypass -Scope Process -Force + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + } + + choco install nodejs -y + - name: Write Test Script shell: powershell run: | From 441dc1744e073a9dcc8b3e441eafbd0088c0edc7 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 19:25:14 +0200 Subject: [PATCH 124/157] use start-process Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2ca92f0..ac2fc8e 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -59,9 +59,14 @@ jobs: $logPathOut = "C:\actions-runner\work\run-tests-output.log" $logPathErr = "C:\actions-runner\work\run-tests-error.log" - # Using PSExec for non-admin execution - $psexecPath = "C:\Path\To\PsExec.exe" # Ensure PsExec is available - & $psexecPath -accepteula -u nonadmin -p $password -w "C:\actions-runner\work" powershell.exe -File $scriptPath > $logPathOut 2> $logPathErr + # Run script using Start-Process for non-admin execution + Start-Process -FilePath "powershell.exe" ` + -ArgumentList "-File $scriptPath" ` + -Credential $credential ` + -NoNewWindow ` + -RedirectStandardOutput $logPathOut ` + -RedirectStandardError $logPathErr ` + -Wait # Output log files to GitHub Actions Write-Output "--- Standard Output ---" From 95f589f26fad5ebff73f480fa71a3a090c9f5feb Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 19:35:22 +0200 Subject: [PATCH 125/157] remove `-wait` flag Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index ac2fc8e..5fc6f43 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -66,13 +66,12 @@ jobs: -NoNewWindow ` -RedirectStandardOutput $logPathOut ` -RedirectStandardError $logPathErr ` - -Wait # Output log files to GitHub Actions Write-Output "--- Standard Output ---" - Get-Content -Path $logPathOut -Wait + Get-Content -Path $logPathOut Write-Output "--- Standard Error ---" - Get-Content -Path $logPathErr -Wait + Get-Content -Path $logPathErr # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] From 666af82203900bc1aac4ce773286cfe8d497c3a7 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 20:07:41 +0200 Subject: [PATCH 126/157] remove `-wait` flag Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 5fc6f43..09e048d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -64,13 +64,13 @@ jobs: -ArgumentList "-File $scriptPath" ` -Credential $credential ` -NoNewWindow ` - -RedirectStandardOutput $logPathOut ` - -RedirectStandardError $logPathErr ` + -RedirectStandardOutput "C:\actions-runner\work\run-tests-output.log" ` + -RedirectStandardError "C:\actions-runner\work\run-tests-error.log" ` # Output log files to GitHub Actions - Write-Output "--- Standard Output ---" + Write-Output "--- Test Run Output ---" Get-Content -Path $logPathOut - Write-Output "--- Standard Error ---" + Write-Output "--- Test Run Error ---" Get-Content -Path $logPathErr # stop-ec2-instance: From a49de46fd5559523b3643b55db62d7e18eea922a Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 20:19:56 +0200 Subject: [PATCH 127/157] use `Transcript` command to redirect all output streams Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 09e048d..4dc327d 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -42,8 +42,13 @@ jobs: } $scriptContent = @" + # Redirect all output streams + Start-Transcript -Path 'C:\actions-runner\work\run-tests-transcript.log' -Append + code --version node --version + + Stop-Transcript "@ $scriptPath = "C:\actions-runner\work\run-tests.ps1" From 1b181f7bab88a8a03822d59be81bc927d740ac8c Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 21:27:39 +0200 Subject: [PATCH 128/157] try to directly print the logs within the script Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4dc327d..b08bae1 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -45,8 +45,8 @@ jobs: # Redirect all output streams Start-Transcript -Path 'C:\actions-runner\work\run-tests-transcript.log' -Append - code --version - node --version + code --version *> C:\actions-runner\work\run-tests-output.log 2> C:\actions-runner\work\run-tests-error.log + node --version *> C:\actions-runner\work\run-tests-output.log 2>> C:\actions-runner\work\run-tests-error.log Stop-Transcript "@ From f746a1527a0ba40bcaedff0cb420cb07dac5c7df Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 21:40:20 +0200 Subject: [PATCH 129/157] more debugging Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 42 ++++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index b08bae1..4fe2748 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -60,23 +60,51 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Redirect output to separate log files + # Paths for script and logs + $scriptPath = "C:\actions-runner\work\run-tests.ps1" $logPathOut = "C:\actions-runner\work\run-tests-output.log" $logPathErr = "C:\actions-runner\work\run-tests-error.log" + # Log debug info before running the script + Write-Output "Checking script path: $scriptPath" + if (-not (Test-Path $scriptPath)) { + Write-Error "Script not found at path: $scriptPath" + exit 1 + } + + Write-Output "Checking output log path: $logPathOut" + if (-not (Test-Path $logPathOut)) { + New-Item -Path $logPathOut -ItemType File -Force | Out-Null + } + + Write-Output "Checking error log path: $logPathErr" + if (-not (Test-Path $logPathErr)) { + New-Item -Path $logPathErr -ItemType File -Force | Out-Null + } + # Run script using Start-Process for non-admin execution Start-Process -FilePath "powershell.exe" ` -ArgumentList "-File $scriptPath" ` -Credential $credential ` -NoNewWindow ` - -RedirectStandardOutput "C:\actions-runner\work\run-tests-output.log" ` - -RedirectStandardError "C:\actions-runner\work\run-tests-error.log" ` + -RedirectStandardOutput $logPathOut ` + -RedirectStandardError $logPathErr ` + -Wait # Output log files to GitHub Actions - Write-Output "--- Test Run Output ---" - Get-Content -Path $logPathOut - Write-Output "--- Test Run Error ---" - Get-Content -Path $logPathErr + if ((Test-Path $logPathOut) -and (Get-Content $logPathOut | Measure-Object -Line).Lines -gt 0) { + Write-Output "--- Standard Output ---" + Get-Content -Path $logPathOut + } else { + Write-Output "No output was written to the standard output log." + } + + if ((Test-Path $logPathErr) -and (Get-Content $logPathErr | Measure-Object -Line).Lines -gt 0) { + Write-Output "--- Standard Error ---" + Get-Content -Path $logPathErr + } else { + Write-Output "No output was written to the standard error log." + } # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] From 34c26860b049742ecfc52bc07f56089547f00a20 Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 21:54:07 +0200 Subject: [PATCH 130/157] more debugging Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 64 ++++++------------------ 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 4fe2748..7017228 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -35,23 +35,18 @@ jobs: - name: Write Test Script shell: powershell run: | - # Ensure the directory exists - if (-not (Test-Path -Path "C:\actions-runner\work")) { - New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force + $runnerDir = "C:\Users\nonadmin\Documents\actions-runner\work" + if (-not (Test-Path -Path $runnerDir)) { + New-Item -Path $runnerDir -ItemType Directory -Force } - - $scriptContent = @" - # Redirect all output streams - Start-Transcript -Path 'C:\actions-runner\work\run-tests-transcript.log' -Append - - code --version *> C:\actions-runner\work\run-tests-output.log 2> C:\actions-runner\work\run-tests-error.log - node --version *> C:\actions-runner\work\run-tests-output.log 2>> C:\actions-runner\work\run-tests-error.log - Stop-Transcript + $scriptContent = @" + code --version + node --version "@ - $scriptPath = "C:\actions-runner\work\run-tests.ps1" + $scriptPath = "$runnerDir\run-tests.ps1" $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force - name: Run Test Script as Non-Admin @@ -60,52 +55,23 @@ jobs: $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - # Paths for script and logs - $scriptPath = "C:\actions-runner\work\run-tests.ps1" - $logPathOut = "C:\actions-runner\work\run-tests-output.log" - $logPathErr = "C:\actions-runner\work\run-tests-error.log" - - # Log debug info before running the script - Write-Output "Checking script path: $scriptPath" - if (-not (Test-Path $scriptPath)) { - Write-Error "Script not found at path: $scriptPath" - exit 1 - } - - Write-Output "Checking output log path: $logPathOut" - if (-not (Test-Path $logPathOut)) { - New-Item -Path $logPathOut -ItemType File -Force | Out-Null - } + # Redirect output to separate log files + $logPathOut = "$runnerDir\run-tests-output.log" + $logPathErr = "$runnerDir\run-tests-error.log" - Write-Output "Checking error log path: $logPathErr" - if (-not (Test-Path $logPathErr)) { - New-Item -Path $logPathErr -ItemType File -Force | Out-Null - } - - # Run script using Start-Process for non-admin execution + # Run script inline Start-Process -FilePath "powershell.exe" ` -ArgumentList "-File $scriptPath" ` -Credential $credential ` -NoNewWindow ` -RedirectStandardOutput $logPathOut ` -RedirectStandardError $logPathErr ` - -Wait # Output log files to GitHub Actions - if ((Test-Path $logPathOut) -and (Get-Content $logPathOut | Measure-Object -Line).Lines -gt 0) { - Write-Output "--- Standard Output ---" - Get-Content -Path $logPathOut - } else { - Write-Output "No output was written to the standard output log." - } - - if ((Test-Path $logPathErr) -and (Get-Content $logPathErr | Measure-Object -Line).Lines -gt 0) { - Write-Output "--- Standard Error ---" - Get-Content -Path $logPathErr - } else { - Write-Output "No output was written to the standard error log." - } - + Write-Output "--- Run Output ---" + Get-Content -Path $logPathOut + Write-Output "--- Run Error ---" + Get-Content -Path $logPathErr # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] # if: always() From ed1cbcbb30dd48289011db80a162f7c7d73e4bcb Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 22:36:10 +0200 Subject: [PATCH 131/157] more debugging Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 7017228..5caa57c 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -56,8 +56,8 @@ jobs: $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) # Redirect output to separate log files - $logPathOut = "$runnerDir\run-tests-output.log" - $logPathErr = "$runnerDir\run-tests-error.log" + $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" + $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run script inline Start-Process -FilePath "powershell.exe" ` From 0ec89eace271e3f95ee7158288ad07bd3c8775df Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 22:44:43 +0200 Subject: [PATCH 132/157] more debugging Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 5caa57c..c507fd2 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -64,8 +64,8 @@ jobs: -ArgumentList "-File $scriptPath" ` -Credential $credential ` -NoNewWindow ` - -RedirectStandardOutput $logPathOut ` - -RedirectStandardError $logPathErr ` + -RedirectStandardOutput "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" ` + -RedirectStandardError "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" ` # Output log files to GitHub Actions Write-Output "--- Run Output ---" From f2d69541cf3968cc8d015612d3c410029b36783f Mon Sep 17 00:00:00 2001 From: midays Date: Sun, 8 Dec 2024 22:56:53 +0200 Subject: [PATCH 133/157] more debugging Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index c507fd2..da49e89 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -61,11 +61,13 @@ jobs: # Run script inline Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-File $scriptPath" ` + -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath" ` -Credential $credential ` + -WorkingDirectory "C:\Users\nonadmin\Documents\actions-runner\work" ` -NoNewWindow ` - -RedirectStandardOutput "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" ` - -RedirectStandardError "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" ` + -RedirectStandardOutput $logPathOut ` + -RedirectStandardError $logPathErr ` + -Wait # Output log files to GitHub Actions Write-Output "--- Run Output ---" From 363f646edd6a0913ccacec85c35c856d31188f3a Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 9 Dec 2024 10:57:01 +0200 Subject: [PATCH 134/157] added `LoadUserProfile` flag Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index da49e89..346c1a7 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,8 +63,7 @@ jobs: Start-Process -FilePath "powershell.exe" ` -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath" ` -Credential $credential ` - -WorkingDirectory "C:\Users\nonadmin\Documents\actions-runner\work" ` - -NoNewWindow ` + -LoadUserProfile ` -RedirectStandardOutput $logPathOut ` -RedirectStandardError $logPathErr ` -Wait From 18f608575f521b6687bbc917e22135c82b90f7ef Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 9 Dec 2024 15:41:18 +0200 Subject: [PATCH 135/157] debug Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 346c1a7..3e30308 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -29,7 +29,6 @@ jobs: [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) } - choco install nodejs -y - name: Write Test Script @@ -59,7 +58,14 @@ jobs: $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - # Run script inline + # Debug: Test if paths are accessible + Write-Output "Testing access to log file paths..." | Out-File $logPathOut -Append + if (-Not (Test-Path -Path $logPathOut)) { + Write-Output "Log path $logPathOut is not accessible!" | Out-File $logPathErr -Append + exit 1 + } + + # Run script inline with LoadUserProfile Start-Process -FilePath "powershell.exe" ` -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath" ` -Credential $credential ` @@ -68,11 +74,18 @@ jobs: -RedirectStandardError $logPathErr ` -Wait + # Verify log file population + if ((Get-Content $logPathOut).Length -eq 0) { + Write-Output "Log file $logPathOut is empty!" | Out-File $logPathErr -Append + exit 1 + } + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut Write-Output "--- Run Error ---" Get-Content -Path $logPathErr + # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] # if: always() From 2eabfe39dc2e14b06de099359f513eb8c01e926b Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 9 Dec 2024 16:01:49 +0200 Subject: [PATCH 136/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 59 +++++++++--------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 3e30308..915ed97 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,15 +21,20 @@ jobs: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install nodeJS + - name: Install PsExec shell: powershell run: | - if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { - Set-ExecutionPolicy Bypass -Scope Process -Force - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + # Install PsExec + $psExecUrl = "https://download.sysinternals.com/files/SysinternalsSuite.zip" + $destination = "C:\tools" + $zipPath = "$destination\SysinternalsSuite.zip" + + if (-not (Test-Path -Path $destination)) { + New-Item -Path $destination -ItemType Directory -Force } - choco install nodejs -y + + Invoke-WebRequest -Uri $psExecUrl -OutFile $zipPath + Expand-Archive -Path $zipPath -DestinationPath $destination -Force - name: Write Test Script shell: powershell @@ -39,53 +44,35 @@ jobs: if (-not (Test-Path -Path $runnerDir)) { New-Item -Path $runnerDir -ItemType Directory -Force } - + + # Create the test script $scriptContent = @" code --version node --version "@ - + $scriptPath = "$runnerDir\run-tests.ps1" $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force - - name: Run Test Script as Non-Admin + - name: Run Test Script with PsExec shell: powershell run: | - $password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) - - # Redirect output to separate log files + $psExecPath = "C:\tools\PsExec64.exe" + $scriptPath = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests.ps1" $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - - # Debug: Test if paths are accessible - Write-Output "Testing access to log file paths..." | Out-File $logPathOut -Append - if (-Not (Test-Path -Path $logPathOut)) { - Write-Output "Log path $logPathOut is not accessible!" | Out-File $logPathErr -Append - exit 1 - } - - # Run script inline with LoadUserProfile - Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-ExecutionPolicy Bypass -File $scriptPath" ` - -Credential $credential ` - -LoadUserProfile ` - -RedirectStandardOutput $logPathOut ` - -RedirectStandardError $logPathErr ` - -Wait - - # Verify log file population - if ((Get-Content $logPathOut).Length -eq 0) { - Write-Output "Log file $logPathOut is empty!" | Out-File $logPathErr -Append - exit 1 - } - + + # Run the test script as the nonadmin user + & $psExecPath -accepteula -u nonadmin -p "${{ secrets.NONADMIN_PASSWORD }}" -d powershell.exe ` + -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut Write-Output "--- Run Error ---" Get-Content -Path $logPathErr + # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] # if: always() From 7d8cc3a3fe404bb6958f04143919999e5e085d18 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 9 Dec 2024 16:09:20 +0200 Subject: [PATCH 137/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 915ed97..11c893f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,9 +63,9 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "${{ secrets.NONADMIN_PASSWORD }}" -d powershell.exe ` - -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr - + & $psExecPath -accepteula -u nonadmin -p "***" powershell.exe ` + -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut From 862173587e1ed1f8a3aa222574f553604d4ed527 Mon Sep 17 00:00:00 2001 From: midays Date: Mon, 9 Dec 2024 18:03:23 +0200 Subject: [PATCH 138/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 11c893f..0c2deaf 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,7 +63,7 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "***" powershell.exe ` + & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe ` -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr # Output log files to GitHub Actions From 7e1adef39da1dffa104b1a34956dbdad846ac0ac Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 17:31:16 +0200 Subject: [PATCH 139/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0c2deaf..6e7fc36 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,7 +63,7 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe ` + & $psExecPath -accepteula -u nonadmin -p "pass123!" -i powershell.exe ` -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr # Output log files to GitHub Actions From de526e980f661f0ee19bd51c4c11ffb4f32c20d9 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 18:52:20 +0200 Subject: [PATCH 140/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 6e7fc36..114d6b3 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,8 +63,7 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "pass123!" -i powershell.exe ` - -ExecutionPolicy Bypass -File $scriptPath > $logPathOut 2> $logPathErr + & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe ` -File $scriptPath > $logPathOut 2> $logPathErr # Output log files to GitHub Actions Write-Output "--- Run Output ---" From 815872120cb3704291a3c8b20bcccbec2df6c415 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 20:46:55 +0200 Subject: [PATCH 141/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 114d6b3..2ddf35a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,7 +63,10 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe ` -File $scriptPath > $logPathOut 2> $logPathErr + $psExecOutput = & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe -File $scriptPath + + # Write PsExec's output to the log file + $psExecOutput | Out-File -FilePath $logPathOut -Append # Output log files to GitHub Actions Write-Output "--- Run Output ---" From a5f20504ca613e5720c2ac6551a39a5eb694c0d2 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 21:51:01 +0200 Subject: [PATCH 142/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2ddf35a..d58d11c 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -47,8 +47,9 @@ jobs: # Create the test script $scriptContent = @" - code --version - node --version + # Redirect output directly in the script + code --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" + node --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" "@ $scriptPath = "$runnerDir\run-tests.ps1" @@ -63,10 +64,7 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - $psExecOutput = & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe -File $scriptPath - - # Write PsExec's output to the log file - $psExecOutput | Out-File -FilePath $logPathOut -Append + & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe -File $scriptPath # Output log files to GitHub Actions Write-Output "--- Run Output ---" From 29217df0a6898607d932790189b24a32b4367778 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 22:18:41 +0200 Subject: [PATCH 143/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index d58d11c..c21650a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -64,12 +64,13 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Run the test script as the nonadmin user - & $psExecPath -accepteula -u nonadmin -p "pass123!" powershell.exe -File $scriptPath + echo "executing: & '$psExecPath' -accepteula -u nonadmin -p 'pass123!' powershell.exe -File '$scriptPath'" + & $psExecPath -accepteula -u nonadmin -p "pass123!" -v powershell.exe -File $scriptPath # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut - Write-Output "--- Run Error ---" + Write-Output "--- Run Error ---"` Get-Content -Path $logPathErr From 4313b6bf91e1bb1001489057568104be531ec4d3 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 22:41:09 +0200 Subject: [PATCH 144/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index c21650a..fe29c03 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -62,15 +62,23 @@ jobs: $scriptPath = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests.ps1" $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" + + # Debug: Print the command + echo "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"& { & '$scriptPath' }\"" - # Run the test script as the nonadmin user - echo "executing: & '$psExecPath' -accepteula -u nonadmin -p 'pass123!' powershell.exe -File '$scriptPath'" - & $psExecPath -accepteula -u nonadmin -p "pass123!" -v powershell.exe -File $scriptPath + # Properly quote the PsExec command + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "& { & '$scriptPath' }" + + # Debug: Check if log files exist + if (-Not (Test-Path -Path $logPathOut)) { + Write-Output "Log file does not exist: $logPathOut" + exit 1 + } # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut - Write-Output "--- Run Error ---"` + Write-Output "--- Run Error ---" Get-Content -Path $logPathErr From f28359e0459ce84f3d5099977fe3cfaf25e8545a Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 22:50:37 +0200 Subject: [PATCH 145/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index fe29c03..a92f66f 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -64,11 +64,11 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Debug: Print the command - echo "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"& { & '$scriptPath' }\"" + echo "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"`& { `& '$scriptPath' }\"" # Properly quote the PsExec command - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "& { & '$scriptPath' }" - + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "`& { `& '$scriptPath' }" + # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { Write-Output "Log file does not exist: $logPathOut" From 5acb371257fef4417effa0ab8c6d0c373be7396b Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 23:12:44 +0200 Subject: [PATCH 146/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index a92f66f..796e971 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,18 +63,19 @@ jobs: $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - # Debug: Print the command - echo "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"`& { `& '$scriptPath' }\"" + # Debug: Print the new command + Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' -w 'C:\Users\nonadmin\Documents\actions-runner\work' powershell.exe -Command \"& { & '$scriptPath' }\"" - # Properly quote the PsExec command - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "`& { `& '$scriptPath' }" + # Run PsExec with corrected options + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" -w "C:\Users\nonadmin\Documents\actions-runner\work" powershell.exe ` + -Command "& { & '$scriptPath' }" - # Debug: Check if log files exist + # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { - Write-Output "Log file does not exist: $logPathOut" + Write-Output "Log file does not exist: $logPathOut" exit 1 } - + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut From 656c775e003c8bb7111a7edbffeaac79ecf7ee27 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 23:22:04 +0200 Subject: [PATCH 147/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 796e971..49c3d16 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -64,21 +64,15 @@ jobs: $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Debug: Print the new command - Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' -w 'C:\Users\nonadmin\Documents\actions-runner\work' powershell.exe -Command \"& { & '$scriptPath' }\"" + Write-Output "& $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -File \"$scriptPath\"" # Run PsExec with corrected options - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" -w "C:\Users\nonadmin\Documents\actions-runner\work" powershell.exe ` - -Command "& { & '$scriptPath' }" - - # Debug: Check if log files exist - if (-Not (Test-Path -Path $logPathOut)) { - Write-Output "Log file does not exist: $logPathOut" - exit 1 - } + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -File "$scriptPath" # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut + Write-Output "--- Run Error ---" Get-Content -Path $logPathErr From 16c2ce6dfb9050397705608dfb322ca0a9269546 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 10 Dec 2024 23:31:39 +0200 Subject: [PATCH 148/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 53 +++++++++++++----------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 49c3d16..2e4c890 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -36,47 +36,52 @@ jobs: Invoke-WebRequest -Uri $psExecUrl -OutFile $zipPath Expand-Archive -Path $zipPath -DestinationPath $destination -Force - - name: Write Test Script - shell: powershell - run: | - # Ensure the directory exists - $runnerDir = "C:\Users\nonadmin\Documents\actions-runner\work" - if (-not (Test-Path -Path $runnerDir)) { - New-Item -Path $runnerDir -ItemType Directory -Force - } - - # Create the test script - $scriptContent = @" - # Redirect output directly in the script - code --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - node --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - "@ - - $scriptPath = "$runnerDir\run-tests.ps1" - $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force +# - name: Write Test Script +# shell: powershell +# run: | +# # Ensure the directory exists +# $runnerDir = "C:\Users\nonadmin\Documents\actions-runner\work" +# if (-not (Test-Path -Path $runnerDir)) { +# New-Item -Path $runnerDir -ItemType Directory -Force +# } +# +# # Create the test script +# $scriptContent = @" +# # Redirect output directly in the script +# code --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" +# node --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" +# "@ +# +# $scriptPath = "$runnerDir\run-tests.ps1" +# $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force - name: Run Test Script with PsExec shell: powershell run: | $psExecPath = "C:\tools\PsExec64.exe" - $scriptPath = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests.ps1" $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" # Debug: Print the new command - Write-Output "& $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -File \"$scriptPath\"" + Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"code --version\"" - # Run PsExec with corrected options - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -File "$scriptPath" - + # Run PsExec to directly execute the command + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "code --version > '$logPathOut' 2> '$logPathErr'" + + # Debug: Check if log files exist + if (-Not (Test-Path -Path $logPathOut)) { + Write-Output "Log file does not exist: $logPathOut" + exit 1 + } + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut - Write-Output "--- Run Error ---" Get-Content -Path $logPathErr + # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] # if: always() From 3bec9428033dec89a1eccc589169f703564d2ce8 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 00:28:22 +0200 Subject: [PATCH 149/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2e4c890..bc56be3 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -62,11 +62,11 @@ jobs: $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - # Debug: Print the new command - Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"code --version\"" + # Debug: Print the PsExec command + Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"code --version > '$logPathOut' 2> '$logPathErr'\"" # Run PsExec to directly execute the command - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "code --version > '$logPathOut' 2> '$logPathErr'" + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "code --version > \"C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log\" 2> \"C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log\"" # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { From 317b76147bb20d1a08d9c4eea3ada2c3efb49ebe Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 00:40:48 +0200 Subject: [PATCH 150/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 46 ++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index bc56be3..0a6c767 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -61,19 +61,28 @@ jobs: $psExecPath = "C:\tools\PsExec64.exe" $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - + $tempOutput = "C:\Users\nonadmin\Documents\actions-runner\work\psexec-output.log" + # Debug: Print the PsExec command - Write-Output "Executing PsExec: & '$psExecPath' -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command \"code --version > '$logPathOut' 2> '$logPathErr'\"" + Write-Output "Executing PsExec with Start-Process using absolute paths..." + + # Prepare the command for Start-Process + $psExecCommand = "$psExecPath -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command `"code --version > 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log' 2> 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log'`"" + + # Run the command using Start-Process + Start-Process -FilePath "powershell.exe" ` + -ArgumentList "-NoProfile -Command $psExecCommand" ` + -RedirectStandardOutput $tempOutput ` + -RedirectStandardError $logPathErr ` + -Wait ` + -NoNewWindow - # Run PsExec to directly execute the command - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "code --version > \"C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log\" 2> \"C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log\"" - # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { Write-Output "Log file does not exist: $logPathOut" - exit 1 + exit 1 } - + # Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut @@ -82,14 +91,15 @@ jobs: -# stop-ec2-instance: -# needs: [ start-ec2-instance, run-tests ] -# if: always() -# uses: ./.github/workflows/remove-runner.yml -# with: -# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} -# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} -# secrets: -# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} + + stop-ec2-instance: + needs: [ start-ec2-instance, run-tests ] + if: always() + uses: ./.github/workflows/remove-runner.yml + with: + ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} + ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} + secrets: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From b8181283906dcfbd6f55ebd0867357ef4c4c8807 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 02:10:29 +0200 Subject: [PATCH 151/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 0a6c767..dae4b4a 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -70,12 +70,7 @@ jobs: $psExecCommand = "$psExecPath -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command `"code --version > 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log' 2> 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log'`"" # Run the command using Start-Process - Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-NoProfile -Command $psExecCommand" ` - -RedirectStandardOutput $tempOutput ` - -RedirectStandardError $logPathErr ` - -Wait ` - -NoNewWindow + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "hostname > '$logPathOut' 2> '$logPathErr'" # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { From d0d2989937e751a3b19511a91b2cfaa1d28895bf Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 02:18:19 +0200 Subject: [PATCH 152/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index dae4b4a..2e45dcc 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -87,14 +87,14 @@ jobs: - stop-ec2-instance: - needs: [ start-ec2-instance, run-tests ] - if: always() - uses: ./.github/workflows/remove-runner.yml - with: - ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} - ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} - secrets: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} +# stop-ec2-instance: +# needs: [ start-ec2-instance, run-tests ] +# if: always() +# uses: ./.github/workflows/remove-runner.yml +# with: +# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} +# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} +# secrets: +# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} From a3fa5d97ff2c70d23b38e219dc36a6a38b57b8ba Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 02:43:06 +0200 Subject: [PATCH 153/157] use start-process Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 2e45dcc..a8f86de 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -58,24 +58,29 @@ jobs: - name: Run Test Script with PsExec shell: powershell run: | - $psExecPath = "C:\tools\PsExec64.exe" - $logPathOut = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" - $logPathErr = "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log" - $tempOutput = "C:\Users\nonadmin\Documents\actions-runner\work\psexec-output.log" + $logDir = "C:\Users\nonadmin\Documents\actions-runner\work" + $logPathOut = "$logDir\run-tests-output.log" + $logPathErr = "$logDir\run-tests-error.log" - # Debug: Print the PsExec command - Write-Output "Executing PsExec with Start-Process using absolute paths..." + # Ensure the directory exists + if (-Not (Test-Path -Path $logDir)) { + New-Item -Path $logDir -ItemType Directory -Force + } - # Prepare the command for Start-Process - $psExecCommand = "$psExecPath -accepteula -nobanner -u nonadmin -p 'pass123!' powershell.exe -Command `"code --version > 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log' 2> 'C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log'`"" + # Debug: Print the Start-Process command + Write-Output "Executing Start-Process as nonadmin with directory creation..." - # Run the command using Start-Process - & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe -Command "hostname > '$logPathOut' 2> '$logPathErr'" + # Run the command + Start-Process -FilePath "powershell.exe" ` + -ArgumentList "-Command code --version > '$logPathOut' 2> '$logPathErr'" ` + -Credential $Credential ` + -NoNewWindow ` + -Wait # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { - Write-Output "Log file does not exist: $logPathOut" - exit 1 + Write-Output "Log file does not exist: $logPathOut" + exit 1 } # Output log files to GitHub Actions From 0b72f8ce5b08d20d6a640649c7d0087d17a682f7 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 02:54:36 +0200 Subject: [PATCH 154/157] use start-process Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index a8f86de..1e866ec 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -21,20 +21,6 @@ jobs: needs: start-ec2-instance runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} steps: - - name: Install PsExec - shell: powershell - run: | - # Install PsExec - $psExecUrl = "https://download.sysinternals.com/files/SysinternalsSuite.zip" - $destination = "C:\tools" - $zipPath = "$destination\SysinternalsSuite.zip" - - if (-not (Test-Path -Path $destination)) { - New-Item -Path $destination -ItemType Directory -Force - } - - Invoke-WebRequest -Uri $psExecUrl -OutFile $zipPath - Expand-Archive -Path $zipPath -DestinationPath $destination -Force # - name: Write Test Script # shell: powershell @@ -74,9 +60,11 @@ jobs: Start-Process -FilePath "powershell.exe" ` -ArgumentList "-Command code --version > '$logPathOut' 2> '$logPathErr'" ` -Credential $Credential ` + -RedirectStandardOutput "C:\Users\nonadmin\Documents\actions-runner\work\process-output.log" ` + -RedirectStandardError "C:\Users\nonadmin\Documents\actions-runner\work\process-error.log" ` -NoNewWindow ` -Wait - + # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { Write-Output "Log file does not exist: $logPathOut" From 191f78a9a75e17e9ffed40ca3e30df88f0375444 Mon Sep 17 00:00:00 2001 From: midays Date: Wed, 11 Dec 2024 14:45:16 +0200 Subject: [PATCH 155/157] use start-process Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index 1e866ec..df981a4 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -63,7 +63,6 @@ jobs: -RedirectStandardOutput "C:\Users\nonadmin\Documents\actions-runner\work\process-output.log" ` -RedirectStandardError "C:\Users\nonadmin\Documents\actions-runner\work\process-error.log" ` -NoNewWindow ` - -Wait # Debug: Check if log files exist if (-Not (Test-Path -Path $logPathOut)) { From 670421a68e4299f337a9d3f015fd93b7f2cbb283 Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 17 Dec 2024 22:48:45 +0200 Subject: [PATCH 156/157] use start-process Signed-off-by: midays --- .github/workflows/provision-runner.yml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 5df5c2b..63d557d 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -77,31 +77,6 @@ jobs: ec2-image-id: ${{ inputs.ec2-image-id }} subnet-id: ${{ inputs.subnet-id }} security-group-id: ${{ inputs.security-group-id }} - pre-runner-script: | - - # Step 1: Create the test user - net user testuser ${{ secrets.nonadmin-password }} /add - net localgroup "Remote Desktop Users" testuser /add - net localgroup "Users" testuser /add - - # Step 2: Download and set up the GitHub Actions runner as the non-admin user - $runnerPath = "C:\actions-runner" - if (-not (Test-Path -Path $runnerPath)) { - New-Item -ItemType Directory -Force -Path $runnerPath - } - Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v2.292.0/actions-runner-win-x64-2.292.0.zip" -OutFile "$runnerPath\actions-runner.zip" - Expand-Archive -Path "$runnerPath\actions-runner.zip" -DestinationPath $runnerPath - Remove-Item "$runnerPath\actions-runner.zip" - - # Step 3: Configure the runner with test user credentials - $password = ConvertTo-SecureString -String "${{ secrets.nonadmin-password }}" -AsPlainText -Force - $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "testuser", $password - - Start-Process -FilePath "$runnerPath\config.cmd" -ArgumentList "--url https://github.com/YOUR_ORG/YOUR_REPO --token ${{ secrets.github-token }}" -Credential $credential -NoNewWindow -Wait - - # Step 4: Run the GitHub Actions runner as the test user - Start-Process -FilePath "$runnerPath\run.cmd" -Credential $credential -NoNewWindow - - name: Output EC2 Instance ID run: | From ea9a4c9307c323ea23139dc3f87d2ab511ec8c4e Mon Sep 17 00:00:00 2001 From: midays Date: Tue, 17 Dec 2024 23:09:26 +0200 Subject: [PATCH 157/157] use PSExec Signed-off-by: midays --- .github/workflows/windows-nightly-ci.yml | 41 ++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml index df981a4..67a1787 100644 --- a/.github/workflows/windows-nightly-ci.yml +++ b/.github/workflows/windows-nightly-ci.yml @@ -44,33 +44,41 @@ jobs: - name: Run Test Script with PsExec shell: powershell run: | + # Define paths + $psExecUrl = "https://download.sysinternals.com/files/PSTools.zip" + $toolsDir = "C:\tools" + $psExecPath = "$toolsDir\PsExec64.exe" $logDir = "C:\Users\nonadmin\Documents\actions-runner\work" $logPathOut = "$logDir\run-tests-output.log" $logPathErr = "$logDir\run-tests-error.log" - # Ensure the directory exists + # Step 1: Install PsExec + Write-Output "Downloading and installing PsExec..." + if (Test-Path -Path $toolsDir) { Remove-Item -Recurse -Force $toolsDir } + New-Item -Path $toolsDir -ItemType Directory -Force + Invoke-WebRequest -Uri $psExecUrl -OutFile "$toolsDir\PSTools.zip" + Expand-Archive -Path "$toolsDir\PSTools.zip" -DestinationPath $toolsDir -Force + Write-Output "PsExec installed successfully." + + # Step 2: Ensure the log directory exists + Write-Output "Ensuring log directory exists: $logDir" if (-Not (Test-Path -Path $logDir)) { - New-Item -Path $logDir -ItemType Directory -Force + New-Item -Path $logDir -ItemType Directory -Force } - # Debug: Print the Start-Process command - Write-Output "Executing Start-Process as nonadmin with directory creation..." + # Step 3: Execute the command using PsExec + Write-Output "Executing PsExec as nonadmin to run 'code --version'..." + & $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe ` + -Command "code --version > '$logPathOut' 2> '$logPathErr'" - # Run the command - Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-Command code --version > '$logPathOut' 2> '$logPathErr'" ` - -Credential $Credential ` - -RedirectStandardOutput "C:\Users\nonadmin\Documents\actions-runner\work\process-output.log" ` - -RedirectStandardError "C:\Users\nonadmin\Documents\actions-runner\work\process-error.log" ` - -NoNewWindow ` - - # Debug: Check if log files exist + # Step 4: Check if output log file exists if (-Not (Test-Path -Path $logPathOut)) { - Write-Output "Log file does not exist: $logPathOut" - exit 1 + Write-Output "Log file does not exist: $logPathOut" + Write-Output "Check $logPathErr for any errors." + exit 1 } - # Output log files to GitHub Actions + # Step 5: Output log files to GitHub Actions Write-Output "--- Run Output ---" Get-Content -Path $logPathOut Write-Output "--- Run Error ---" @@ -78,7 +86,6 @@ jobs: - # stop-ec2-instance: # needs: [ start-ec2-instance, run-tests ] # if: always()