Skip to content

TestDriver v4

TestDriver v4 #32

Workflow file for this run

name: Build and TestDriver.ai Regression Testing - Waveterm
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- main
schedule:
- cron: 0 21 * * *
workflow_dispatch: null
env:
GO_VERSION: "1.22"
NODE_VERSION: "20"
permissions:
contents: read # To allow the action to read repository contents
pull-requests: write # To allow the action to create/update pull request comments
jobs:
build_and_upload:
name: Build and Upload EXE
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# General build dependencies
- uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
cache-dependency-path: |
go.sum
- uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
- name: Install Yarn
run: |
corepack enable
yarn install
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Windows Code Signing Setup
- name: Set up certificate (Windows only)
run: |
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
shell: bash
- name: Set signing variables (Windows only)
id: variables
run: |
echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
echo "SM_CODE_SIGNING_CERT_SHA1_HASH=${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_OUTPUT"
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
echo "C:\Program Files\DigiCert\DigiCert Keylocker Tools" >> $GITHUB_PATH
shell: bash
- name: Setup Keylocker KSP (Windows only)
run: |
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o Keylockertools-windows-x64.msi
msiexec /i Keylockertools-windows-x64.msi /quiet /qn
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
smctl windows certsync
shell: cmd
- name: Build (Windows only)
run: task package
env:
USE_SYSTEM_FPM: true # Ensure that the installed version of FPM is used rather than the bundled one.
CSC_LINK: ${{ steps.variables.outputs.SM_CLIENT_CERT_FILE }}
CSC_KEY_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
shell: powershell # electron-builder's Windows code signing package has some compatibility issues with pwsh, so we need to use Windows Powershell
# Upload .exe as an artifact
- name: Upload .exe artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: windows-exe
path: make/*.exe
- uses: testdriverai/action@main
id: testdriver
with:
key: ${{ secrets.DASHCAM_API }}
prerun: |
$headers = @{
Authorization = "token ${{ secrets.GITHUB_TOKEN }}"
}
$downloadFolder = "./download"
$artifactFileName = "waveterm.exe"
$artifactFilePath = "$downloadFolder/$artifactFileName"
Write-Host "Starting the artifact download process..."
# Create the download directory if it doesn't exist
if (-not (Test-Path -Path $downloadFolder)) {
Write-Host "Creating download folder..."
mkdir $downloadFolder
} else {
Write-Host "Download folder already exists."
}
# Fetch the artifact upload URL
Write-Host "Fetching the artifact upload URL..."
$artifactUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" -Headers $headers).artifacts[0].archive_download_url
if ($artifactUrl) {
Write-Host "Artifact URL successfully fetched: $artifactUrl"
} else {
Write-Error "Failed to fetch the artifact URL."
exit 1
}
# Download the artifact (zipped file)
Write-Host "Starting artifact download..."
$artifactZipPath = "$env:TEMP\artifact.zip"
try {
Invoke-WebRequest -Uri $artifactUrl `
-Headers $headers `
-OutFile $artifactZipPath `
-MaximumRedirection 5
Write-Host "Artifact downloaded successfully to $artifactZipPath"
} catch {
Write-Error "Error downloading artifact: $_"
exit 1
}
# Unzip the artifact
$artifactUnzipPath = "$env:TEMP\artifact"
Write-Host "Unzipping the artifact to $artifactUnzipPath..."
try {
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactUnzipPath -Force
Write-Host "Artifact unzipped successfully to $artifactUnzipPath"
} catch {
Write-Error "Failed to unzip the artifact: $_"
exit 1
}
# Find the executable within the unzipped files (modify if specific path is known)
$artifactFilePath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
if ($artifactFilePath) {
Write-Host "Executable file found: $($artifactFilePath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
# Run the executable and log the result
Write-Host "Running the executable: $($artifactFilePath.FullName)..."
try {
Start-Process -FilePath $artifactFilePath.FullName -Wait
Write-Host "Executable ran successfully."
} catch {
Write-Error "Failed to run the executable: $_"
exit 1
}
prompt: |
1. /run testdriver/theme.yml