Skip to content

fix(windows-agent): Landscape install: create user when no cloud-init file is provided #3330

fix(windows-agent): Landscape install: create user when no cloud-init file is provided

fix(windows-agent): Landscape install: create user when no cloud-init file is provided #3330

Workflow file for this run

name: QA
on:
pull_request:
paths-ignore:
- docs/**
- msix/**
- '*.md'
push:
branches: [main]
workflow_dispatch:
concurrency:
group: QA-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
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
include:
- subproject: agentapi
needs-flutter: true
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-wsl/.github/actions/setup-git@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check out repository
uses: actions/checkout@v4
- name: Read flutter version
if: matrix.needs-flutter != ''
id: flutter-version
uses: ./.github/actions/read-file
with:
path: tools/flutter-version
- name: Set up flutter
uses: subosito/flutter-action@v2
if: matrix.needs-flutter != ''
with:
channel: 'stable'
flutter-version: ${{ steps.flutter-version.outputs.contents }}
- name: Install Dart protoc plugin
if: matrix.needs-flutter != ''
shell: bash
working-directory: ${{ matrix.subproject }}
run: |
dart pub global activate protoc_plugin
- name: Quality check
uses: canonical/desktop-engineering/gh-actions/go/code-sanity@main
with:
working-directory: ${{ matrix.subproject }}
go-tags: gowslmock
tools-directory: ${{ github.workspace }}/tools
golangci-lint-configfile: ${{ github.workspace }}/.golangci.yaml
- name: Gettext validation
shell: bash
working-directory: ${{ matrix.subproject }}
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: ["p4w_ms_store", "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-wsl/.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 lcov
- 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 == 'ubuntupro'
uses: actions/setup-go@v5
with:
go-version-file: windows-agent/go.mod
- name: Read flutter version
id: flutter-version
uses: ./.github/actions/read-file
with:
path: tools/flutter-version
- name: Flutter QA
id: flutter-qa
uses: ./.github/actions/flutter-qa/
with:
flutter-version: ${{ steps.flutter-version.outputs.contents }}
package-dir: gui/packages/${{ matrix.package }}
run-build-runner: ${{ matrix.package == 'ubuntupro' }}
- name: Report coverage
if: ${{ matrix.os == 'ubuntu' }}
shell: bash
run: |
set -eu
mkdir -p ./coverage/codecov
echo "${{ steps.flutter-qa.outputs.coverage-info }}" >> ./coverage/codecov/flutter-coverage.codecov
- uses: codecov/codecov-action@v4
with:
directory: ./coverage/codecov/
token: ${{ secrets.CODECOV_TOKEN }}
- name: Ensure module files are up to date
uses: canonical/desktop-engineering/gh-actions/common/has-diff@main
with:
working-directory: gui/packages/${{ matrix.package }}
paths-to-ignore: ${{ matrix.package == 'ubuntupro' && 'pubspec.lock' || '' }}
fail-on-diff: true
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-wsl/.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: Read flutter version
id: flutter-version
uses: ./.github/actions/read-file
with:
path: tools/flutter-version
- name: Flutter QA
uses: ./.github/actions/flutter-integration-test/
with:
flutter-version: ${{ steps.flutter-version.outputs.contents }}
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-wsl/.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 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@v5
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@v2
if: matrix.subproject == 'storeapi/go-wrapper/microsoftstore'
- name: Install gettext on Linux
shell: bash
if: matrix.os == 'ubuntu'
working-directory: ${{ matrix.subproject }}
run: |
set -eu
sudo DEBIAN_FRONTEND=noninteractive apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y gettext
- name: Run tests
shell: bash
if: always() && !cancelled()
working-directory: ${{ matrix.subproject }}
run: |
set -eu
cov_dir=$(pwd)/coverage
mkdir -p ${cov_dir}/codecov ${cov_dir}/raw
go test -shuffle=on -coverpkg=./... -coverprofile=${cov_dir}/raw/coverage.out -covermode=count ./... -tags=gowslmock
grep -hv -e "testutils" -e "pb.go:" ${cov_dir}/raw/coverage.out > ${cov_dir}/codecov/coverage.out.codecov
- 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@v4
with:
directory: ${{ matrix.subproject }}/coverage/codecov
token: ${{ secrets.CODECOV_TOKEN }}