Run End-To-End tests in our CI #1707
Workflow file for this run
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: QA | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
concurrency: | |
group: QA-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
flutter-version: 3.13.x | |
jobs: | |
quality-go: | |
name: "Go Quality checks" | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, windows] | |
subproject: [ | |
"agentapi", | |
"contractsapi", | |
"mocks", | |
"storeapi/go-wrapper/microsoftstore", | |
"windows-agent", | |
"wsl-pro-service", | |
"end-to-end", | |
"common", | |
] | |
exclude: | |
- os: windows | |
subproject: wsl-pro-service | |
- os: ubuntu | |
subproject: end-to-end | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Set up git | |
# This step needs to be done before checkout so that the checkout respects clrf | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: ${{ matrix.subproject }}/go.mod | |
- name: Update module files | |
shell: bash | |
if: always() && !cancelled() | |
working-directory: ${{ matrix.subproject }} | |
run: | | |
# Ensuring there is no diff between current and generated go.mod and go.sum files | |
set -eu | |
echo "::group::Download dependencies" | |
go mod tidy | |
echo "::endgroup::" | |
- name: Ensure module files are up to date | |
uses: ./.github/actions/check-diff | |
with: | |
files-to-validate: ${{ matrix.subproject }}/**/go.mod ${{ matrix.subproject }}/**/go.sum | |
- name: Build | |
shell: bash | |
if: always() && !cancelled() | |
working-directory: ${{ matrix.subproject }} | |
run: | | |
go build -tags=gowslmock ./... | |
- name: Linter | |
uses: golangci/golangci-lint-action@v3 | |
if: always() && !cancelled() | |
with: | |
version: v1.54.2 | |
args: --config=${{ github.workspace }}/.golangci.yaml --build-tags=gowslmock | |
working-directory: ${{ matrix.subproject }} | |
- name: Gettext validation | |
shell: bash | |
run: | | |
set -eu | |
tmp=`mktemp` | |
grep -nr --include="*.go" 'i18n.G([^"]' ./* | grep -Pv '_test.go:' > "${tmp}/log" || true | |
[ -z "$(cat "${tmp}/log")" ] && exit 0 | |
echo 'Bad i18n.G calls. Gettext will only detect calls of type G("text"), with double quotes.' | |
cat "${tmp}/log" | |
exit 1 | |
quality-flutter: | |
name: "Flutter Quality checks" | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, windows] | |
package: ["gui/packages/p4w_ms_store", "gui/packages/ubuntupro"] | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Set up git | |
# This step needs to be done before checkout so that the checkout respects clrf | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Ensure dependencies on Ubuntu | |
if: ${{ matrix.os == 'ubuntu' }} | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt update | |
sudo DEBIAN_FRONTEND=noninteractive apt install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev unzip xvfb | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
# We need to set up Go so that the agent can be built for the end-to-end tests | |
if: matrix.package == 'gui/packages/ubuntupro' | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: windows-agent/go.mod | |
- name: Flutter QA | |
uses: ./.github/actions/flutter-qa/ | |
with: | |
flutter-version: ${{ env.flutter-version }} | |
package-dir: '${{ matrix.package }}' | |
run-build-runner: ${{ contains(matrix.package, 'ubuntupro') }} | |
- uses: ./.github/actions/check-diff | |
with: | |
files-to-validate: '${{ matrix.package }}/**/*.dart' | |
flutter-integration: | |
name: "Flutter integration tests" | |
strategy: | |
fail-fast: false | |
# For now we don't have a way to run integration test on ubuntu. | |
# It looks silly to keep this matrix, but we'll be able to run this on Linux eventually and there are gotchas already solved here | |
# such as the dependency on xvfb since ubuntu runners on GH don't have graphical capabilities. | |
matrix: | |
os: [windows] | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Set up git | |
# This step needs to be done before checkout so that the checkout respects clrf | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Ensure dependencies on Ubuntu | |
if: ${{ matrix.os == 'ubuntu' }} | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt update | |
sudo DEBIAN_FRONTEND=noninteractive apt install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev unzip xvfb | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Flutter QA | |
uses: ./.github/actions/flutter-integration-test/ | |
with: | |
flutter-version: ${{ env.flutter-version }} | |
go-version-file: windows-agent/go.mod | |
# Only the app entry point is expected to have integration tests | |
package-dir: 'gui/packages/ubuntupro' | |
quality-cpp: | |
name: "C++ Quality Checks" | |
runs-on: windows-latest | |
steps: | |
- name: Set up git | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: C++ QA | |
uses: ./.github/actions/cpp-qa/ | |
with: | |
subproject-dir: 'storeapi/test' | |
tests-go-with-mocks: | |
name: "Run Go tests with mocks" | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, windows] | |
subproject: ["storeapi/go-wrapper/microsoftstore", "windows-agent", "wsl-pro-service", "common"] | |
exclude: | |
- os: windows | |
subproject: wsl-pro-service | |
# Excluded because common/i18n depends on gettext | |
- os: ubuntu | |
subproject: "common" | |
# Excluded because microsoftstore_test needs msbuild | |
- os: ubuntu | |
subproject: "storeapi/go-wrapper/microsoftstore" | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: ${{ matrix.subproject }}/go.mod | |
- name: Set up git | |
uses: ./.github/actions/setup-git | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# The Windows Store needs to be built. The tests do it automatically, but they need | |
# msbuild in the path. | |
- name: Set up MSBuild | |
uses: microsoft/setup-msbuild@v1 | |
if: matrix.subproject == 'storeapi/go-wrapper/microsoftstore' | |
- name: Run tests | |
shell: bash | |
if: always() && !cancelled() | |
working-directory: ${{ matrix.subproject }} | |
run: | | |
go test -shuffle=on -coverpkg=./... -coverprofile=/tmp/coverage.out -covermode=count ./... -tags=gowslmock | |
- name: Run tests (with race detector) | |
shell: bash | |
# -race not supported on Windows | |
if: matrix.os != 'windows' | |
working-directory: ${{ matrix.subproject }} | |
run: | | |
go test -shuffle=on ./... -race -tags=gowslmock | |
#- name: Upload coverage to Codecov | |
# uses: codecov/codecov-action@v3 | |
# with: | |
# file: /tmp/coverage.out | |
generated-grpc: | |
name: gRPC files are up to date | |
runs-on: ubuntu-latest | |
container: ubuntu:rolling | |
strategy: | |
fail-fast: false | |
matrix: | |
subproject: ["agentapi", "wslserviceapi"] | |
steps: | |
- name: Install git into the container | |
run: | | |
set -eu | |
DEBIAN_FRONTEND=noninteractive apt update | |
DEBIAN_FRONTEND=noninteractive apt install -y git | |
- name: Set up git | |
# This step needs to be done before checkout so that the checkout respects clrf | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- uses: ./.github/actions/go-generate-grpc | |
with: | |
go-version-file: ${{ matrix.subproject }}/**/go.mod | |
tools-directory: tools | |
protos-directory: ${{ matrix.subproject }} | |
enable-dart: ${{ matrix.subproject == 'agentapi' }} | |
- name: Ensure generated gRPC files are up to date | |
uses: ./.github/actions/check-diff | |
with: | |
files-to-validate: '${{ matrix.subproject }}/{.,**}/*.{dart,go}' | |
build-wsl-pro-service: | |
name: Build wsl-pro-service debian package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- 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-windows: | |
name: Build Windows Agent Appx | |
runs-on: windows-latest | |
steps: | |
- name: Set up git | |
uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.work | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
flutter-version: ${{ env.flutter-version }} | |
- name: Setup MSBuild (PATH) | |
uses: microsoft/[email protected] | |
- name: Install certificate | |
shell: powershell | |
run: | | |
New-Item -ItemType directory -Path certificate | |
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.CERTIFICATE }}' | |
certutil -decode certificate\certificate.txt certificate\certificate.pfx | |
$pwd = ConvertTo-SecureString '${{ secrets.CERTIFICATE_PASSWORD }}' -AsPlainText -Force | |
Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:LocalMachine\Trust -FilePath certificate\certificate.pfx | |
Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:CurrentUser\My -FilePath certificate\certificate.pfx | |
- name: Build Bundle | |
run: | | |
msbuild ` | |
.\msix\msix.sln ` | |
-target:Build ` | |
-maxCpuCount ` | |
-nodeReuse:false ` | |
-property:Configuration=Release ` | |
-property:AppxBundle=Always ` | |
-property:AppxBundlePlatforms=x64 ` | |
-property:UapAppxPackageBuildMode=SideloadOnly ` | |
-property:Version=0.0.1+${{ github.sha }} ` | |
-nologo ` | |
-verbosity:normal | |
- name: Upload sideload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: UbuntuProForWindows+${{ github.sha }} | |
path: | | |
msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.cer | |
msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.msixbundle |