Skip to content

daemon: Always close the ready channel on error #624

daemon: Always close the ready channel on error

daemon: Always close the ready channel on error #624

Workflow file for this run

name: QA & sanity checks
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
go-sanity:
name: "Go: Code sanity"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Go code sanity check
uses: canonical/desktop-engineering/gh-actions/go/code-sanity@main
with:
golangci-lint-configfile: ".golangci.yaml"
tools-directory: "tools"
go-tests:
name: "Go: Tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Prepare tests artifacts path
run: |
set -eu
artifacts_dir=$(mktemp -d --tmpdir authd-test-artifacts-XXXXXX)
echo AUTHD_TEST_ARTIFACTS_DIR="${artifacts_dir}" >> $GITHUB_ENV
- name: Install gotestfmt and our wrapper script
uses: canonical/desktop-engineering/gh-actions/go/gotestfmt@main
- name: Run tests (with coverage collection)
run: |
set -eu
# The coverage is not written if the output directory does not exist, so we need to create it.
raw_cov_dir="/tmp/raw_files"
rm -fr "${raw_cov_dir}"
mkdir -p "${raw_cov_dir}"
# Print executed commands to ease debugging
set -x
# Overriding the default coverage directory is not an exported flag of go test (yet), so
# we need to override it using the test.gocoverdir flag instead.
#TODO: Update when https://go-review.googlesource.com/c/go/+/456595 is merged.
go test -json -cover -covermode=set ./... -shuffle=on -args -test.gocoverdir="${raw_cov_dir}" 2>&1 | \
gotestfmt --logfile "${AUTHD_TEST_ARTIFACTS_DIR}/gotestfmt.cover.log"
# Convert the raw coverage data into textfmt so we can merge the Rust one into it
go tool covdata textfmt -i="${raw_cov_dir}" -o="/tmp/coverage.out"
# Filter out the testutils package and the pb.go file
grep -v -e "testutils" "/tmp/coverage.out" >"/tmp/coverage.out.filtered"
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: authd-${{ github.job }}-artifacts-${{ github.run_attempt }}
path: ${{ env.AUTHD_TEST_ARTIFACTS_DIR }}