diff --git a/.github/workflows/provision-runner.yml b/.github/workflows/provision-runner.yml index 70a51d46..29373e85 100644 --- a/.github/workflows/provision-runner.yml +++ b/.github/workflows/provision-runner.yml @@ -39,10 +39,10 @@ on: description: 'Personal Access Token For GH' 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,7 +70,7 @@ 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 }} @@ -78,4 +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 }}" \ No newline at end of file + echo "Label : ${{ steps.ec2.outputs.label }}" diff --git a/.github/workflows/windows-nightly-ci.yml b/.github/workflows/windows-nightly-ci.yml new file mode 100644 index 00000000..052184a7 --- /dev/null +++ b/.github/workflows/windows-nightly-ci.yml @@ -0,0 +1,132 @@ +name: (Windows admin) Run Playwright tests nightly on main branch + +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 }} + + 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: 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 + + - 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'" | + 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 }}