Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up audit and linting errors #2

Merged
merged 7 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Run Tests
on: [push]
on: [push, workflow_dispatch]

jobs:
lint:
qualitycheck:
name: Quality Check
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -12,11 +13,33 @@ jobs:
with:
go-version-file: "go.mod"
check-latest: true
- name: Setup golangci-lint
- name: Lint code
uses: golangci/golangci-lint-action@v4
with:
version: "v1.56.2"
args: --verbose
- name: Quality Check
- name: Audit code
run: |
make audit

test:
name: Test
needs: qualitycheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: Run tests
run: make test
- name: Generate coverage report
run: make test/cover
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: vwhitteron/gt-telemetry
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# MacOS hidden files
.DS_Store

# Build files
examples/bin/

# Coverage reports
*.out
54 changes: 40 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
MAIN_PACKAGE_PATH := ./examples/simple
BINARY_NAME := gt-telemetry


# ==================================================================================== #
# HELPERS
# ==================================================================================== #
Expand Down Expand Up @@ -36,11 +37,16 @@ tidy:
.PHONY: audit
audit:
go mod verify
go vet ./...
go vet ./ ./internal/utils # ignore Kaitai Struct files as they trip some rules
go run honnef.co/go/tools/cmd/staticcheck@latest -checks=all,-ST1000,-U1000 ./...
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
go test -race -buildvcs -vet=off ./...

## lint: run linters
.PHONY: lint
lint:
golangci-lint run


# ==================================================================================== #
# DEVELOPMENT
Expand All @@ -54,19 +60,42 @@ test:
## test/cover: run all tests and display coverage
.PHONY: test/cover
test/cover:
go test -v -race -buildvcs -coverprofile=/tmp/coverage.out ./...
go tool cover -html=/tmp/coverage.out

## kaitai: compile the GT telemetry kaitai struct
.PHONY: kaitai
kaitai-struct:
go test -v -race -buildvcs -coverprofile=coverage.out ./...

## test/cover/show: run all tests and display coverage in a browser
.PHONY: test/cover/show
test/cover/show: test/cover
go tool cover -html=coverage.out

## kaitai: compile the GT telemetry package from the Kaitai Struct
.PHONY: build/kaitai
build/kaitai:
ifeq (, $(shell which kaitai-struct-compilerx))
$(error "kaitai-struct-compiler command not found, see https://kaitai.io/#download for installation instructions.")
endif
@kaitai-struct-compiler --target go --go-package gttelemetry --outdir internal internal/kaitai/gran_turismo_telemetry.ksy

## build: build the application
.PHONY: build
build: kaitai
build:
@go build -o examples/bin/${BINARY_NAME} ${MAIN_PACKAGE_PATH}

.PHONY: build-darwin
build-darwin:
@GOOS=darwin GOARCH=arm64 go build -o examples/bin/${BINARY_NAME}-darwin-arm64 ${MAIN_PACKAGE_PATH}

.PHONY: build-linux
build-linux:
@GOOS=linux GOARCH=amd64 go build -o examples/bin/${BINARY_NAME}-linux-amd64 ${MAIN_PACKAGE_PATH}

.PHONY: build-rpi
build-rpi:
@GOOS=linux GOARCH=arm64 go build -o examples/bin/${BINARY_NAME}-rpi-arm64 ${MAIN_PACKAGE_PATH}

.PHONY: build-windows
build-windows:
@GOOS=windows GOARCH=amd64 go build -o examples/bin/${BINARY_NAME}-amd64.exe ${MAIN_PACKAGE_PATH}

## run: run the application
.PHONY: run
run: build
Expand All @@ -75,14 +104,11 @@ run: build
## run/live: run the application with reloading on file changes
.PHONY: run/live
run/live:
@go run ${MAIN_PACKAGE_PATH}/main.go \
--build.cmd "make build" --build.bin "/tmp/bin/${BINARY_NAME}" --build.delay "100" \
--build.exclude_dir "" \
--build.include_ext "go, tpl, tmpl, html, css, scss, js, ts, sql, jpeg, jpg, gif, png, bmp, svg, webp, ico" \
--misc.clean_on_exit "true"
@go run ${MAIN_PACKAGE_PATH}/main.go

## clean: clean up project and return to a pristine state
.PHONY: clean
clean:
@go clean
@rm -rf examples/bin
@rm -rf examples/bin
@rm -f coverage.out
2 changes: 1 addition & 1 deletion telemetry_client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telemetry_client
package telemetry

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion transformer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telemetry_client
package telemetry

import (
"math"
Expand Down
2 changes: 1 addition & 1 deletion unit_alternates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package telemetry_client
package telemetry

import (
"fmt"
Expand Down
Loading