-
Notifications
You must be signed in to change notification settings - Fork 6
177 lines (159 loc) · 6.26 KB
/
qa-azure.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build and run end-to-end tests
# Builds the project, and runs end-to-end tests using the generated artifacts.
concurrency: azure-vm
on:
pull_request:
paths-ignore:
- docs/**
- "*.md"
workflow_dispatch:
push:
branches: [main]
env:
az_name: wsl-ci-3
az_resource_group: wsl
jobs:
build-wsl-pro-service:
name: Build wsl-pro-service debian package
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Build debian package
uses: canonical/desktop-engineering/gh-actions/common/build-debian@main
with:
source-dir: wsl-pro-service
token: ${{ secrets.GITHUB_TOKEN }}
docker-image: ubuntu:devel
env:
UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE: "1"
build-ubuntu-pro-for-wsl:
strategy:
matrix:
mode: ["production", "end_to_end_tests"]
name: Build Windows Agent Appx
runs-on: windows-latest
steps:
- name: Check out repository for internal GH action
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Build MSIX app
uses: ./.github/actions/build-msix
with:
mode: ${{ matrix.mode }}
certificate: ${{ secrets.CERTIFICATE }}
certificate_password: ${{ secrets.CERTIFICATE_PASSWORD }}
- name: Upload sideload artifact
uses: actions/upload-artifact@v4
with:
name: UbuntuProForWSL+${{ github.sha }}-${{ matrix.mode }}
path: |
msix/UbuntuProForWSL/AppPackages/UbuntuProForWSL_*/UbuntuProForWSL_*.cer
msix/UbuntuProForWSL/AppPackages/UbuntuProForWSL_*/UbuntuProForWSL_*.msixbundle
vm-setup:
name: Set up Azure VM
runs-on: ubuntu-latest
steps:
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_VM_CREDS }}
- name: Start the Runner
shell: bash
run: |
az vm start --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }}
qa:
name: Run end-to-end tests on the Azure VM
runs-on: [self-hosted, Windows]
needs: [vm-setup, build-wsl-pro-service, build-ubuntu-pro-for-wsl]
steps:
- name: Set up git
uses: canonical/ubuntu-pro-for-wsl/.github/actions/setup-git@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Ubuntu
uses: Ubuntu/WSL/.github/actions/wsl-install@main
with:
distro: "Ubuntu-Preview"
- name: Set up Go
# actions/setup-go is broken
shell: powershell
run: |
winget install GoLang.Go --accept-source-agreements --accept-package-agreements --silent --verbose
# Cannot check for error: there is no way to distinguish the two:
# - Legitimate error
# - Error because no updates found (Golang.Go is already up to date)
#
# We can check that Go works, though.
go version
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# name: is left blank so that all artifacts are downloaded
path: ci-artifacts
- name: Set up artifacts
shell: powershell
working-directory: ci-artifacts
run: |
Write-Output "::group::Set up AppxPackage"
Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuPro" | Remove-AppxPackage -ErrorAction Ignore
New-Item -Name "windows-agent" -ItemType Directory
Move-Item -Path "UbuntuProForWSL+*-end_to_end_tests/UbuntuProForWSL_*/*.msixbundle" -Destination "windows-agent/"
Move-Item -Path "UbuntuProForWSL+*-end_to_end_tests/UbuntuProForWSL_*/*.cer" -Destination "windows-agent/"
Remove-Item -Recurse "UbuntuProForWSL+*/"
$cert = "$(Get-ChildItem windows-agent/UbuntuProForWSL_*.cer)"
Import-Certificate -FilePath "${cert}" -CertStoreLocation Cert:LocalMachine\TrustedPeople
Write-Output "::endgroup::"
Write-Output "::group::Set up WSL Pro Service"
New-Item -Name "wsl-pro-service" -ItemType Directory
Move-Item -Path "wsl-pro-service_*/wsl-pro-service_*.deb" -Destination "wsl-pro-service/"
Remove-Item -Recurse "wsl-pro-service_*/"
Write-Output "::endgroup::"
# Installing a debug version of VCLibs from the SDK is required, otherwise installing the Ubuntu pro debug appx will fail.
- name: Install Debug version of VCLibs
shell: powershell
run: Add-AppxPackage "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Debug\x64\Microsoft.VCLibs.x64.Debug.14.00.Desktop.appx"
- name: Test
shell: powershell
env:
GIT_TERMINAL_PROMPT: "0"
UP4W_TEST_OVERRIDE_DESTRUCTIVE_CHECKS: "1"
UP4W_TEST_BUILD_PATH: "../ci-artifacts"
UP4W_TEST_PRO_TOKEN: "${{ secrets.UBUNTU_PRO_TOKEN }}"
run: |
go env -w "GOPRIVATE=github.com/${{ github.repository }}"
go test .\end-to-end -shuffle=on -timeout 20m
if ( "$LastExitCode" -ne "0" ) { Exit(1) }
- name: Clean up
if: always()
shell: powershell
run: |
# Clean up artifacts
# Remove .gitconfig so that the github URL overrides do not stack
Remove-Item -Recurse -Path "${HOME}\.gitconfig" -ErrorAction Ignore
# Uninstall Appx
Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuPro" | Remove-AppxPackage -ErrorAction Ignore
# Uninstall certificate
$thumbprint = (Get-PfxCertificate -FilePath "ci-artifacts\windows-agent\UbuntuProForWSL_*.cer").Thumbprint
Remove-Item -Path "Cert:LocalMachine\TrustedPeople\${thumbprint}"
stop-vm:
name: Clean up the Azure VM
runs-on: ubuntu-latest
needs: [vm-setup, qa]
if: always()
steps:
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_VM_CREDS }}
- name: Deallocate the Runner
shell: bash
run: |
az vm deallocate --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }}