Skip to content

fix: install Docker #86

fix: install Docker

fix: install Docker #86

Workflow file for this run

name: E2E Windows (Google Cloud)
on:
push:
branches:
- main
workflow_dispatch:
jobs:
windows-e2e:
runs-on: ubuntu-latest
strategy:
matrix:
fs: ['ReFS']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Setup GCP environment
uses: google-github-actions/setup-gcloud@v1
- name: Generate random instance and disk name
run: |
INSTANCE_UUID=$(uuidgen | cut -d'-' -f1)
INSTANCE_NAME="vm-$INSTANCE_UUID"
DISK_NAME="$INSTANCE_NAME-disk"
echo "INSTANCE_NAME=$INSTANCE_NAME" >> $GITHUB_ENV
echo "DISK_NAME=$DISK_NAME" >> $GITHUB_ENV
- name: Get Repository Name
run: |
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
- name: Generate SSH key pair
run: |
ssh-keygen -t rsa -b 4096 -f ./gcloud -C "${{ secrets.GCP_MAIL }}" -N ""
- name: Set default project
run: |
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
- name: Create GCP VM with Spot provisioning
run: |
gcloud compute instances create $INSTANCE_NAME \
--project=${{ secrets.GCP_PROJECT_ID }} \
--zone=us-east1-b \
--machine-type=e2-medium \
--source-machine-image=windows-rs \
--no-restart-on-failure \
--maintenance-policy=TERMINATE \
--provisioning-model=SPOT \
--instance-termination-action=DELETE \
--metadata sysprep-specialize-script-cmd="googet -noconfirm=true install google-compute-engine-ssh",enable-windows-ssh=TRUE,ssh-keys="${{ secrets.GCP_USER }}:$(cat ./gcloud.pub)"
- name: Wait 1 minute for VM to start
run: |
sleep 60
- name: Copy the repo
run: |
gcloud compute ssh ${{ secrets.GCP_USER }}@$INSTANCE_NAME --zone=us-east1-b --command="powershell -Command \"mkdir D:\\\\code\\\\${{ env.REPO_NAME }}\"" --ssh-key-file=./gcloud
gcloud compute scp --recurse --zone=us-east1-b ../${{ env.REPO_NAME }} ${{ secrets.GCP_USER }}@$INSTANCE_NAME:"D:\code" --ssh-key-file=./gcloud
- name: List files in project directory
run:
gcloud compute ssh ${{ secrets.GCP_USER }}@$INSTANCE_NAME --zone=us-east1-b --command="powershell -Command \"cd D:\\\\code\\\\${{ env.REPO_NAME }}; ls\"" --ssh-key-file=./gcloud
- name: Run tests
run:
gcloud compute ssh ${{ secrets.GCP_USER }}@$INSTANCE_NAME --zone=us-east1-b --command="powershell -Command \"cd D:\\\\code\\\\${{ env.REPO_NAME }}; cargo test\"" --ssh-key-file=./gcloud
# Cleanup
- name: Delete GCP VM if exists
if: always()
run: |
if gcloud compute instances describe $INSTANCE_NAME --zone=us-east1-b > /dev/null 2>&1; then
gcloud compute instances delete $INSTANCE_NAME --zone=us-east1-b --quiet
else
echo "VM does not exist. Skipping deletion."
fi
- name: Delete GCP Disk if exists
if: always()
run: |
if gcloud compute disks describe $DISK_NAME --zone=us-east1-b > /dev/null 2>&1; then
gcloud compute disks delete $DISK_NAME --zone=us-east1-b --quiet
else
echo "Disk does not exist. Skipping deletion."
fi