-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cocli: Create a separate repo for this tool under Veraison org
- Update module name - Update references to cocli path - Copy GitHub workflows from the corim repo Signed-off-by: Jagannathan Raman <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,000 additions
and
3 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,39 @@ | ||
# Copyright 2020-present Montgomery Edwards⁴⁴⁸ (github.com/x448). | ||
# This file is licensed under the MIT License. See LICENSE at https://github.com/x448/workflows for the full text. | ||
# | ||
# CI Go Cover 2020.1.28. | ||
# This GitHub Actions workflow checks if Go (Golang) code coverage satisfies the required minimum. | ||
# The required minimum is specified in the workflow name to keep badge.svg and verified minimum in sync. | ||
# | ||
# To help protect your privacy, this workflow avoids external services. | ||
# This workflow simply runs `go test -short -cover` --> grep --> python. | ||
# The python script is embedded and readable in this file. | ||
# | ||
# Steps to install and set minimum required coverage: | ||
# 0. Copy this file to github.com/OWNER_NAME/REPO_NAME/.github/workflows/ci-go-cover.yml | ||
# 1. Change workflow name from "cover 100%" to "cover ≥92.5%". Script will automatically use 92.5%. | ||
# 2. Update README.md to use the new path to badge.svg because the path includes the workflow name. | ||
|
||
name: cover ≥84.4% | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
# Verify minimum coverage is reached using `go test -short -cover` on latest-ubuntu with default version of Go. | ||
# The grep expression can't be too strict, it needed to be relaxed to work with different versions of Go. | ||
cover: | ||
name: Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.22" | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install mockgen | ||
run: | | ||
go install github.com/golang/mock/[email protected] | ||
- name: Go Coverage | ||
run: | | ||
go version | ||
make test-cover | grep -o "coverage:.*of statements$" | python scripts/cov.py | ||
shell: bash |
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,30 @@ | ||
# GitHub Actions - CI for Go to build & test. See ci-go-cover.yml and linters.yml for code coverage and linters. | ||
# Taken from: https://github.com/fxamacker/cbor/workflows/ci.yml (thanks!) | ||
name: ci | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
# Test on various OS with specified Go version. | ||
tests: | ||
name: Test on ${{matrix.os}} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest] | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.22" | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- name: Install mockgen | ||
run: | | ||
go install github.com/golang/mock/[email protected] | ||
- name: Build project | ||
run: go build ./... | ||
- name: Run tests | ||
run: | | ||
go version | ||
make test |
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,26 @@ | ||
# Go Linters - GitHub Actions | ||
name: linters | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
# Check linters on latest-ubuntu with default version of Go. | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.22" | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install golangci-lint | ||
run: | | ||
go version | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 | ||
- name: Install mockgen | ||
run: | | ||
go install github.com/golang/mock/[email protected] | ||
- name: Run required linters in .golangci.yml plus hard-coded ones here | ||
run: make lint | ||
- name: Run optional linters (not required to pass) | ||
run: make lint-extra |
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,80 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
SHELL := /bin/bash | ||
|
||
GO111MODULE := on | ||
|
||
GOPKG += github.com/veraison/cocli/cmd | ||
|
||
MOCKGEN := $(shell go env GOPATH)/bin/mockgen | ||
INTERFACES := cmd/isubmitter.go | ||
MOCKPKG := mocks | ||
|
||
GOLINT ?= golangci-lint | ||
|
||
ifeq ($(MAKECMDGOALS),lint) | ||
GOLINT_ARGS ?= run --timeout=3m | ||
else | ||
ifeq ($(MAKECMDGOALS),lint-extra) | ||
GOLINT_ARGS ?= run --timeout=3m --issues-exit-code=0 -E dupl -E gocritic -E gosimple -E lll -E prealloc | ||
endif | ||
endif | ||
|
||
.PHONY: lint lint-extra | ||
lint lint-extra: _mocks; $(GOLINT) $(GOLINT_ARGS) | ||
|
||
ifeq ($(MAKECMDGOALS),test) | ||
GOTEST_ARGS ?= -v -race $(GOPKG) | ||
else | ||
ifeq ($(MAKECMDGOALS),test-cover) | ||
GOTEST_ARGS ?= -short -cover $(GOPKG) | ||
endif | ||
endif | ||
|
||
COVER_THRESHOLD := $(shell grep '^name: cover' .github/workflows/ci-go-cover.yml | cut -c13-) | ||
|
||
|
||
define MOCK_template | ||
mock_$(1): $(1) | ||
$$(MOCKGEN) -source=$$< -destination=cmd/mocks/$$$$(basename $$@) -package=$$(MOCKPKG) | ||
endef | ||
|
||
$(foreach m,$(INTERFACES),$(eval $(call MOCK_template,$(m)))) | ||
MOCK_FILES := $(foreach m,$(INTERFACES),$(join mock_,$(m))) | ||
CLEANFILES := $(MOCK_FILES) | ||
|
||
_mocks: $(MOCK_FILES) | ||
.PHONY: _mocks | ||
|
||
.PHONY: test test-cover | ||
test test-cover: _mocks; go test $(GOTEST_ARGS) | ||
|
||
realtest: _mocks; go test $(GOTEST_ARGS) | ||
.PHONY: realtest | ||
|
||
.PHONY: clean | ||
clean: ; $(RM) $(CLEANFILES) | ||
|
||
presubmit: | ||
@echo | ||
@echo ">>> Check that the reported coverage figures are $(COVER_THRESHOLD)" | ||
@echo | ||
$(MAKE) test-cover | ||
@echo | ||
@echo ">>> Fix any lint error" | ||
@echo | ||
$(MAKE) lint-extra | ||
|
||
.PHONY: licenses | ||
licenses: ; @./scripts/licenses.sh | ||
|
||
.PHONY: help | ||
help: | ||
@echo "Available targets:" | ||
@echo " * test: run unit tests for $(GOPKG)" | ||
@echo " * test-cover: run unit tests and measure coverage for $(GOPKG)" | ||
@echo " * lint: lint sources using default configuration" | ||
@echo " * lint-extra: lint sources using default configuration and some extra checkers" | ||
@echo " * presubmit: check you are ready to push your local branch to remote" | ||
@echo " * help: print this menu" | ||
@echo " * licenses: check licenses of dependent packages" |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module github.com/veraison/cocli | ||
|
||
go 1.22 | ||
|
||
require ( | ||
github.com/golang/mock v1.6.0 | ||
github.com/google/uuid v1.3.0 | ||
github.com/spf13/afero v1.9.2 | ||
github.com/spf13/cobra v1.2.1 | ||
github.com/spf13/pflag v1.0.5 | ||
github.com/spf13/viper v1.9.0 | ||
github.com/stretchr/testify v1.8.2 | ||
github.com/veraison/apiclient v0.3.1-0.20240807160142-9141ad363e45 | ||
github.com/veraison/corim v0.0.0-00010101000000-000000000000 | ||
github.com/veraison/go-cose v1.1.1-0.20230825153510-da0f9a62ade7 | ||
github.com/veraison/swid v1.1.1-0.20230911094910-8ffdd07a22ca | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect | ||
github.com/fsnotify/fsnotify v1.5.1 // indirect | ||
github.com/fxamacker/cbor/v2 v2.5.0 // indirect | ||
github.com/goccy/go-json v0.9.11 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/lestrrat-go/blackmagic v1.0.1 // indirect | ||
github.com/lestrrat-go/httpcc v1.0.1 // indirect | ||
github.com/lestrrat-go/httprc v1.0.4 // indirect | ||
github.com/lestrrat-go/iter v1.0.2 // indirect | ||
github.com/lestrrat-go/jwx/v2 v2.0.8 // indirect | ||
github.com/lestrrat-go/option v1.0.0 // indirect | ||
github.com/magiconair/properties v1.8.5 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/moogar0880/problems v0.1.1 // indirect | ||
github.com/pelletier/go-toml v1.9.4 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/spf13/cast v1.4.1 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/subosito/gotenv v1.2.0 // indirect | ||
github.com/veraison/eat v0.0.0-20210331113810-3da8a4dd42ff // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/crypto v0.12.0 // indirect | ||
golang.org/x/net v0.14.0 // indirect | ||
golang.org/x/oauth2 v0.11.0 // indirect | ||
golang.org/x/sys v0.11.0 // indirect | ||
golang.org/x/text v0.12.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/ini.v1 v1.63.2 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace github.com/veraison/corim => /home/ubuntu/github/veraison/corim |
Oops, something went wrong.