Windows Nightly CI #382
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: install-nodejs-as-admin | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install sshpass | |
run: sudo apt-get install -y sshpass | |
- name: Get EC2 Host (Public IP/DNS) | |
id: get-ec2-host | |
run: | | |
EC2_INSTANCE_ID=${{ needs.start-ec2-instance.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: 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: | | |
echo "host : ${{ env.ec2-host }}" | |
sshpass -p ${EC2_PASSWORD} scp -o StrictHostKeyChecking=no clone-repo.bat ${EC2_USER}@${{ env.ec2-host }}:C:\\Users\\nonadmin\\clone-repo.bat | |
sshpass -p ${EC2_PASSWORD} scp -o StrictHostKeyChecking=no execute-tests.bat ${EC2_USER}@${{ env.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}@${{ env.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}@${{ env.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 }} |