Skip to content

Commit

Permalink
Merge pull request #50 from konveyor/github_actions_for_windows_ci
Browse files Browse the repository at this point in the history
[WIP] Windows Nightly CI
  • Loading branch information
sshveta authored Jan 22, 2025
2 parents d732be0 + fdcf197 commit 4e210bc
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
####################
-####################
### EXAMPLE FILE ###
####################

Expand All @@ -7,13 +7,13 @@
# For git password please use your generated git token, not a clear text password

VSCODE_EXECUTABLE_PATH='/usr/share/code/code'
VSIX_FILE_NAME='konveyor-v0.0.4.vsix'
DEFAULT_VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.4/konveyor-v0.0.4.vsix'
VSIX_FILE_NAME='konveyor-v0.0.5.vsix'
DEFAULT_VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.5/konveyor-v0.0.5.vsix'
PLUGIN_URL= 'https://github.com/konveyor/editor-extensions/releases/download/'
PLUGIN_VERSION= 'v0.0.4'
PLUGIN_VERSION= 'v0.0.5'

# For Windows Path needs to be given in below format
# VSCODE_EXECUTABLE_PATH='C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe'
WINDOWS_VSCODE_EXECUTABLE_PATH='C:/Users/nonadmin/AppData/Local/Programs/Microsoft VS Code/Code.exe'

# For Linux
# VSCODE_EXECUTABLE_PATH='/usr/share/code/code'
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/provision-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,27 @@ on:
github-token:
description: 'Personal Access Token For GH'
required: true
nonadmin-password:
description: 'Non admin user password'
required: true
outputs:
instance_label:
description: "The label of the VM that was created."
value: ${{ jobs.provision-ec2.outputs.label }}
ec2-instance-id:
description: "Instance id of the VM that was created."
value: ${{ jobs.provision-ec2.outputs.instance_id }}
ec2-host:
description: "Instance id of the VM that was created."
value: ${{ jobs.provision-ec2.outputs.ec2-host}}

jobs:
provision-ec2:
runs-on: ubuntu-latest
outputs:
instance_id: ${{ steps.ec2.outputs.ec2-instance-id }}
label: ${{ steps.ec2.outputs.label }}
ec2-host: ${{ steps.get-ec2-host.outputs.ec2-host }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -74,8 +81,20 @@ jobs:
ec2-image-id: ${{ inputs.ec2-image-id }}
subnet-id: ${{ inputs.subnet-id }}
security-group-id: ${{ inputs.security-group-id }}

- name: Get EC2 Host (Public IP/DNS)
id: get-ec2-host
run: |
EC2_INSTANCE_ID="${{ steps.ec2.outputs.ec2-instance-id }}"
EC2_INSTANCE_ID=$(echo $EC2_INSTANCE_ID | sed 's/^\[\(.*\)\]$/\1/')
EC2_HOST=$(aws ec2 describe-instances --instance-ids $EC2_INSTANCE_ID --query "Reservations[0].Instances[0].PublicIpAddress" --output text)
echo "EC2 Host: $EC2_HOST"
# Set the EC2 Host as an environment variable to be available to subsequent jobs
echo "ec2-host=$EC2_HOST" >> $GITHUB_ENV
echo "::set-output name=ec2-host::$EC2_HOST"
- name: Output EC2 Instance ID
run: |
echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}"
echo "EC2 Host (Public IP/DNS): ${{ steps.get-ec2-host.outputs.ec2-host }}"
echo "Label : ${{ steps.ec2.outputs.label }}"
81 changes: 81 additions & 0 deletions .github/workflows/windows-nightly-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: (Windows)(nonadmin) Run Playwright tests nightly on main branch

on: [push]

jobs:
start-ec2-instance:
uses: ./.github/workflows/provision-runner.yml
with:
ec2-image-id: ami-0cf05b9bbda99aed3
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 }}

install-nodejs-as-admin:
needs: start-ec2-instance
runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }}
steps:
- name: Install Node.js
run: choco install nodejs -y
shell: powershell

run-test-as-nonadmin:
needs: [ start-ec2-instance, install-nodejs-as-admin]
runs-on: ubuntu-latest

steps:
- name: Install sshpass
run: sudo apt-get install -y sshpass

- name: Create batch file locally to git clone
run: |
echo "set nodePath=C:\Program Files\nodejs" > clone-repo.bat
echo "set PATH=%PATH%;%nodePath%" >> clone-repo.bat
echo "if exist C:\\Users\\nonadmin\\kai-ci rmdir /s /q C:\\Users\\nonadmin\\kai-ci" >> clone-repo.bat
echo "git clone https://github.com/konveyor/kai-ci C:\\Users\\nonadmin\\kai-ci" >> clone-repo.bat
echo "cd C:\\Users\\nonadmin\\kai-ci" >> clone-repo.bat
echo "npm install" >> clone-repo.bat
shell: bash

- name: Create batch file locally to execute tests
run: |
echo "set nodePath=C:\Program Files\nodejs" > execute-tests.bat
echo "set PATH=%PATH%;%nodePath%" >> execute-tests.bat
echo "cd C:\\Users\\nonadmin\\kai-ci" >> execute-tests.bat
echo "copy .env.example .env" >> execute-tests.bat
echo "npx playwright test" >> execute-tests.bat
shell: bash

- name: Copy batch file to Windows EC2 instance
run: |
sshpass -p ${EC2_PASSWORD} scp -o StrictHostKeyChecking=no clone-repo.bat ${EC2_USER}@${{ needs.start-ec2-instance.outputs.ec2-host }}:C:\\Users\\nonadmin\\clone-repo.bat
sshpass -p ${EC2_PASSWORD} scp -o StrictHostKeyChecking=no execute-tests.bat ${EC2_USER}@${{ needs.start-ec2-instance.outputs.ec2-host }}:C:\\Users\\nonadmin\\execute-tests.bat
env:
EC2_USER: nonadmin
EC2_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }}

- name: Execute batch file on EC2 Windows instance
run: |
sshpass -p ${EC2_PASSWORD} ssh -o StrictHostKeyChecking=no ${EC2_USER}@${{ needs.start-ec2-instance.outputs.ec2-host }} 'powershell -Command "Start-Process -FilePath C:\\Users\\nonadmin\\clone-repo.bat -NoNewWindow -Wait"'
sshpass -p ${EC2_PASSWORD} ssh -o StrictHostKeyChecking=no ${EC2_USER}@${{ needs.start-ec2-instance.outputs.ec2-host }} 'powershell -Command "Start-Process -FilePath C:\\Users\\nonadmin\\execute-tests.bat -NoNewWindow -Wait"'
env:
EC2_USER: nonadmin
EC2_PASSWORD: ${{ secrets.NONADMIN_PASSWORD }}

stop-ec2-instance:
needs: [ start-ec2-instance, install-nodejs-as-admin, run-test-as-nonadmin]
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 }}

0 comments on commit 4e210bc

Please sign in to comment.