-
Notifications
You must be signed in to change notification settings - Fork 5
173 lines (148 loc) · 6.09 KB
/
windows-nightly-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Windows Nightly Run
on: [push]
jobs:
start-ec2-instance:
uses: ./.github/workflows/provision-runner.yml
with:
ec2-image-id: ami-01fa2492704e48175
ec2-instance-type: t2.micro
security-group-id: sg-0a3e6b53e86d0e69d
subnet-id: subnet-06113672589e7e836
ec2-os-type: windows
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 }}
nonadmin-password: ${{ secrets.NONADMIN_PASSWORD }}
run-tests:
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
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:\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: 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"
- name: Verify VSCode and Node.js Installation
shell: powershell
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: 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: |
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: |
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-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: |
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 }}