Skip to content

Commit

Permalink
fixup: fix linter, incorrect directory references (#3)
Browse files Browse the repository at this point in the history
* fixup

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* run pre-commits

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* GOFLAGS

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

---------

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
  • Loading branch information
golanglemonade authored Sep 6, 2024
1 parent 3f518a3 commit 530d433
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ steps:
cancel_on_build_failing: true
plugins:
- docker#v5.11.0:
image: "registry.hub.docker.com/golangci/golangci-lint:latest-alpine"
command: ["golangci-lint", "run", "-v"]
image: "ghcr.io/theopenlane/build-image:latest"
always-pull: true
command: ["task", "go:lint"]
environment:
- "GOTOOLCHAIN=auto"
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ enhancement:
# Add 'breaking-change' label to any PR where the head branch name starts with `breaking-change` or has a `breaking-change` section in the name
breaking-change:
- head-branch: ["^breaking-change", "breaking-change"]
# Add 'dependencies' label to any PR where the head branch name starts with `dependencies` or has a `dependencies` section in the name
dependencies:
- head-branch: ["^dependencies", "dependencies", "^deps", "deps"]
ci:
- changed-files:
- any-glob-to-any-file: .github/**
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ Thumbs.db

*.mime
*.mim

*.env
*.env-dev
*.config.yaml
39 changes: 39 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 10m
allow-serial-runners: true
linters-settings:
goimports:
local-prefixes: github.com/theopenlane/jsonschema-templates
gofumpt:
extra-rules: true
gosec:
exclude-generated: true
revive:
ignore-generated-header: true
linters:
enable:
- bodyclose
- errcheck
- gocritic
- gocyclo
- err113
- gofmt
- goimports
- mnd
- gosimple
- govet
- gosec
- ineffassign
- misspell
- noctx
- revive
- staticcheck
- stylecheck
- typecheck
- unused
- whitespace
- wsl
issues:
fix: true
exclude-use-default: true
exclude-files: []
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ repos:
hooks:
- id: yamlfmt
- repo: https://github.com/crate-ci/typos
rev: v1.24.1
rev: v1.24.5
hooks:
- id: typos
2 changes: 1 addition & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ identifier-leading-digits = false
locale = "en"
extend-ignore-identifiers-re = []
extend-ignore-words-re = ["(?i)requestor","(?i)indentity","(?i)encrypter","(?i)seeked","(?i)generater"]
extend-ignore-re = ["#\\s*spellchecker:off\\s*\\n.*\\n\\s*#\\s*spellchecker:on"]
extend-ignore-re = ["(?Rm)^.*//\\s*spellchecker:disable-line$"]
11 changes: 4 additions & 7 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: "3"

env:
GOFLAGS: -buildvcs=false

tasks:
default:
silent: true
Expand All @@ -8,40 +11,34 @@ tasks:

generate:invoice:
desc: generate jsonschema for invoices
dir: generate
cmds:
- go run schema_generator.go
- go run schemagenerator.go

## Go tasks
go:lint:
desc: runs golangci-lint, the most annoying opinionated linter ever
dir: generate
cmds:
- golangci-lint run --config=.golangci.yaml --verbose --fast

go:test:
desc: runs and outputs results of created go tests
dir: generate
cmds:
- go test -v ./...

go:test:cover:
desc: runs and outputs results of created go tests with coverage
aliases: [cover]
dir: generate
cmds:
- go test -v ./... -coverprofile=coverage.out
- go tool cover -html=coverage.out

go:fmt:
desc: format all go code
dir: generate
cmds:
- go fmt ./...

go:tidy:
desc: Runs go mod tidy on the backend
dir: generate
aliases: [tidy]
cmds:
- go mod tidy
Expand Down
2 changes: 1 addition & 1 deletion invoice.go → invoice/invoice.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsonschematemplates
package invoice

import "time"

Expand Down
2 changes: 1 addition & 1 deletion jsonschemas/openlane.invoice.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/theopenlane/jsonschema-templates/generate/invoice/config",
"$id": "https://github.com/theopenlane/jsonschema-templates/invoice/config",
"$defs": {
"BusinessPartner": {
"properties": {
Expand Down
14 changes: 8 additions & 6 deletions schema_generator.go → schemagenerator.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsonschematemplates
package main

import (
"encoding/json"
Expand All @@ -7,15 +7,17 @@ import (
"github.com/invopop/jsonschema"
"github.com/invopop/yaml"
"github.com/mcuadros/go-defaults"

"github.com/theopenlane/jsonschema-templates/invoice"
)

// const values used for the schema generator
const (
tagName = "json"
skipper = "-"
defaultTag = "default"
jsonSchemaPath = "../jsonschemas/theopenlane.invoice.json"
yamlConfigPath = "../jsonschemas/theopenlane.invoice.yaml"
jsonSchemaPath = "jsonschemas/openlane.invoice.json"
yamlConfigPath = "jsonschemas/openlane.invoice.yaml"
ownerReadWrite = 0600
)

Expand All @@ -33,7 +35,7 @@ func main() {
yamlConfigPath: yamlConfigPath,
}

if err := generateSchema(c, &Config{}); err != nil {
if err := generateSchema(c, &invoice.Config{}); err != nil {
panic(err)
}
}
Expand All @@ -48,7 +50,7 @@ func generateSchema(c schemaConfig, structure interface{}) error {
// set the tag name to `koanf` for the koanf struct tags
r.FieldNameTag = tagName

if err := r.AddGoComments("github.com/theopenlane/jsonschema-templates/generate", "./"); err != nil {
if err := r.AddGoComments("github.com/theopenlane/jsonschema-templates", "./"); err != nil {
panic(err.Error())
}

Expand All @@ -65,7 +67,7 @@ func generateSchema(c schemaConfig, structure interface{}) error {
}

// generate yaml schema with default
yamlConfig := &Config{}
yamlConfig := &invoice.Config{}
defaults.SetDefaults(yamlConfig)

// this uses the `json` tag to generate the yaml schema
Expand Down

0 comments on commit 530d433

Please sign in to comment.