-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into collector_wip
- Loading branch information
Showing
26 changed files
with
1,494 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.go text eol=lf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: 2 | ||
updates: | ||
# Infrastructure | ||
## GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
# Workflow files stored in the | ||
# default location of `.github/workflows` | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "thursday" | ||
time: "09:00" | ||
groups: | ||
gh-actions: | ||
#applies-to: version-updates | ||
patterns: ["*"] | ||
commit-message: | ||
prefix: "deps(ci)" | ||
|
||
## Go dependencies | ||
- package-ecosystem: "gomod" | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
day: "thursday" | ||
time: "09:00" | ||
groups: | ||
minor-updates: | ||
#applies-to: version-updates | ||
update-types: ["minor", "patch"] | ||
commit-message: | ||
prefix: "deps(go)" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/tools" | ||
schedule: | ||
interval: "weekly" | ||
day: "thursday" | ||
time: "09:00" | ||
groups: | ||
minor-updates: | ||
#applies-to: version-updates | ||
update-types: ["minor", "patch"] | ||
commit-message: | ||
prefix: "deps(go-tools)" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Git Checks | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
block-fixup: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Block Fixup Commit Merge | ||
uses: 13rac1/[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: QA & sanity checks | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*" | ||
pull_request: | ||
|
||
env: | ||
DEBIAN_FRONTEND: noninteractive | ||
GO_TESTS_TIMEOUT: 20m | ||
|
||
jobs: | ||
go-sanity: | ||
name: "Go: Code sanity" | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-24.04, windows-2022, macos-13, macos-14] # Run on Ubuntu, Windows, Mac Intel, Mac ARM | ||
steps: | ||
- name: Install dependencies on Linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt update | ||
sudo apt install -y ${{ env.apt_deps }} | ||
- 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: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: ["coverage", "race"] | ||
os: [ubuntu-24.04, windows-2022, macos-13, macos-14] # Run on Ubuntu, Windows, Mac Intel, Mac ARM | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Install gotestfmt and our wrapper script | ||
uses: canonical/desktop-engineering/gh-actions/go/gotestfmt@main | ||
|
||
- name: Prepare tests artifacts path | ||
run: | | ||
set -euo pipefail | ||
artifacts_dir=$(mktemp -d -t insights-test-artifacts-XXXXXX) | ||
echo INSIGHTS_TEST_ARTIFACTS_PATH="${artifacts_dir}" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Run tests (with coverage collection) | ||
if: matrix.test == 'coverage' | ||
env: | ||
G_DEBUG: "fatal-criticals" | ||
run: | | ||
set -euo pipefail | ||
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 | ||
shell: bash | ||
|
||
- name: Run tests (with race detector) | ||
if: matrix.test == 'race' | ||
env: | ||
GO_TESTS_TIMEOUT: 35m | ||
run: | | ||
set -euo pipefail | ||
go test -json -timeout ${GO_TESTS_TIMEOUT} -race ./... | \ | ||
gotestfmt --logfile "${INSIGHTS_TEST_ARTIFACTS_PATH}/gotestfmt.race.log" | ||
shell: bash | ||
|
||
- name: Upload coverage to Codecov | ||
if: matrix.test == 'coverage' | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
directory: ./coverage/codecov | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Upload test artifacts | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: insights-${{ github.job }}-${{ matrix.test }}-${{ matrix.os }}-artifacts-${{ github.run_attempt }} | ||
path: ${{ env.INSIGHTS_TEST_ARTIFACTS_PATH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# This is for linting. To run it, please use: | ||
# golangci-lint run ${MODULE}/... [--fix] | ||
|
||
linters: | ||
# linters to run in addition to default ones | ||
enable: | ||
- copyloopvar | ||
- dupl | ||
- dupword | ||
- durationcheck | ||
- errname | ||
- errorlint | ||
- forbidigo | ||
- forcetypeassert | ||
- gci | ||
- gocheckcompilerdirectives | ||
- godot | ||
- gofmt | ||
- gosec | ||
- intrange | ||
- misspell | ||
- nakedret | ||
- nolintlint | ||
- revive | ||
- sloglint | ||
- testifylint | ||
- thelper | ||
- tparallel | ||
- unconvert | ||
- unparam | ||
- usestdlibvars | ||
- whitespace | ||
|
||
run: | ||
timeout: 5m | ||
|
||
# Get all linter issues, even if duplicated | ||
issues: | ||
exclude-use-default: false | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
fix: false # we don’t want this in CI | ||
exclude: | ||
# EXC0001 errcheck: most errors are in defer calls, which are safe to ignore and idiomatic Go (would be good to only ignore defer ones though) | ||
- 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv|w\.Stop). is not checked' | ||
# EXC0008 gosec: duplicated of errcheck | ||
- (G104|G307) | ||
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)' | ||
- Potential file inclusion via variable | ||
# We don't wrap errors on purpose | ||
- non-wrapping format verb for fmt.Errorf. Use `%w` to format errors | ||
# We want named parameters even if unused, as they help better document the function | ||
- unused-parameter | ||
# Sometimes it is more readable it do a `if err:=a(); err != nil` tha simpy `return a()` | ||
- if-return | ||
# Outdated warining, it only applies to Go < 1.22 | ||
# G601: Implicit memory aliasing in for loop. | ||
- G601 | ||
|
||
nolintlint: | ||
require-explanation: true | ||
require-specific: true | ||
|
||
linters-settings: | ||
# Forbid the usage of deprecated ioutil and debug prints | ||
forbidigo: | ||
forbid: | ||
- ioutil\. | ||
- ^print.*$ | ||
# Never have naked return ever | ||
nakedret: | ||
max-func-lines: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
// Package daemon is responsible for running the exposed-server in the background. | ||
package daemon |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
// Package main for the exposed-server. | ||
package main | ||
|
||
func main() { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
// Package daemon is responsible for running the ingest-server in the background. | ||
package daemon |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
// Package main for the ingest-server. | ||
package main | ||
|
||
func main() { | ||
|
||
} |
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
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
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
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
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
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
Oops, something went wrong.