-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🧹 add golangci config * ⭐️ add package build with goreleaser * ⭐️ run go tests in github actions * 🧹 update cnquery dependency * 🧹 temporarily deactivate some tests * 🧹 go format files Signed-off-by: Christoph Hartmann <[email protected]>
- Loading branch information
1 parent
9fc5cd0
commit a7348ef
Showing
12 changed files
with
271 additions
and
62 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,32 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
goreleaser: | ||
runs-on: self-hosted | ||
timeout-minutes: 120 | ||
steps: | ||
- name: Git config | ||
run: git config --global url."https://${{ secrets.GH_API_TOKEN}}@github.com".insteadOf "https://github.com" | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v3 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist --timeout 120m | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,76 @@ | ||
name: Code Test | ||
|
||
## Only trigger tests if source is changing | ||
on: | ||
push: | ||
paths: | ||
- '**.go' | ||
- '**.mod' | ||
- 'go.sum' | ||
|
||
env: | ||
GO_VERSION: 1.19 | ||
GOPRIVATE: "github.com/mondoohq,go.mondoo.com" | ||
|
||
jobs: | ||
# Check if there is any dirty change for go mod tidy | ||
go-mod: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git config | ||
run: git config --global url."https://${{ secrets.GH_API_TOKEN}}@github.com".insteadOf "https://github.com" | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Check go mod | ||
run: | | ||
go mod tidy | ||
git diff --exit-code go.mod | ||
golangci-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git config | ||
run: git config --global url."https://${{ secrets.GH_API_TOKEN}}@github.com".insteadOf "https://github.com" | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Run golangci-lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: latest | ||
|
||
go-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git config | ||
run: git config --global url."https://${{ secrets.GH_API_TOKEN}}@github.com".insteadOf "https://github.com" | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
# https://github.com/actions/cache/blob/main/examples.md#go---modules | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- run: make test/go/plain-ci | ||
|
||
- uses: actions/upload-artifact@v3 # upload test results | ||
if: success() || failure() # run this step even if previous step failed | ||
with: | ||
name: test-results | ||
path: report.xml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# See https://golangci-lint.run/usage/configuration/ for configuration options | ||
run: | ||
timeout: 5m | ||
skip-dirs: | ||
skip-files: | ||
- ".*\\.pb\\.go$" | ||
- ".*\\.lr\\.go$" | ||
modules-download-mode: readonly | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- gofmt | ||
# deactivated for now since its slow in github actions | ||
# - govet | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: false | ||
|
||
govet: | ||
# enable or disable analyzers by name | ||
# run `go tool vet help` to see all analyzers | ||
enable: | ||
- structtag | ||
- lostcancel | ||
disable-all: true |
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,74 @@ | ||
--- | ||
project_name: cnspec | ||
env: | ||
- CGO_ENABLED=0 | ||
builds: | ||
- id: linux | ||
main: ./apps/cnspec/cnspec.go | ||
binary: cnspec | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- 386 | ||
- arm64 | ||
- arm | ||
# ARM 6= Raspberry Pi A, A+, B, B+, Zero | ||
# ARM 7= Raspberry Pi 2, 3, 4 | ||
goarm: | ||
- 6 | ||
- 7 | ||
flags: | ||
- -tags="production netgo" | ||
ldflags: | ||
- "-extldflags=-static" | ||
- -s -w -X go.mondoo.com/cnspec.Version={{.Version}} -X go.mondoo.com/cnspec.Build={{.ShortCommit}} -X go.mondoo.com/cnspec.Date={{.Date}} | ||
- id: macos | ||
main: ./apps/cnspec/cnspec.go | ||
binary: cnspec | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
flags: -tags production | ||
ldflags: | ||
# clang + macos does not support static: - -extldflags "-static" | ||
- -s -w -X go.mondoo.com/cnspec.Version={{.Version}} -X go.mondoo.com/cnspec.Build={{.ShortCommit}} -X go.mondoo.com/cnspec.Date={{.Date}} | ||
- id: windows | ||
main: ./apps/cnspec/cnspec.go | ||
binary: cnspec | ||
goos: | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
# -buildmode exe is required since go 1.15.0 https://github.com/golang/go/issues/40795 | ||
flags: -tags production -buildmode exe | ||
ldflags: | ||
- "-extldflags -static" | ||
- -s -w -X go.mondoo.com/cnspec.Version={{.Version}} -X go.mondoo.com/cnspec.Build={{.ShortCommit}} -X go.mondoo.com/cnspec.Date={{.Date}} | ||
nfpms: | ||
- | ||
maintainer: Mondoo <[email protected]> | ||
description: Cloud-Native Security and Policy Framework | ||
homepage: https://mondoo.com/ | ||
vendor: Mondoo, Inc | ||
license: MPL-2.0 | ||
formats: | ||
- deb | ||
- rpm | ||
archives: | ||
- id: releases | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- none* | ||
checksum: | ||
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS' | ||
algorithm: sha256 | ||
snapshot: | ||
name_template: "{{ .Tag }}-snapshot" | ||
changelog: | ||
use: github-native |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//go:build debugtest | ||
// +build debugtest | ||
|
||
package plugin_test | ||
|
||
import ( | ||
|
Oops, something went wrong.