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

update ci #45

Merged
merged 6 commits into from
Aug 25, 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
45 changes: 30 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
name: Run CI Tests
on: [push]
on:
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
push:
branches:
- 'main'
jobs:
lint:
runs-on: ubuntu-22.04
run-copywrite:
timeout-minutes: 5
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-golang@v3
with:
version-file: go.mod
- uses: golangci/golangci-lint-action@v3
- uses: hashicorp/setup-copywrite@v1.1.3
- name: verify copyright
run: |
copywrite --config .github/workflows/scripts/copywrite.hcl \
headers --spdx "MIT" --plan
run-lint:
timeout-minutes: 5
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
skip-cache: true
version: v1.60.3
args: --config .github/workflows/scripts/golangci.yaml
run-tests:
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- macos-12
- macos-13
- ubuntu-24.04
- macos-14
- windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-golang@v3
- uses: actions/setup-go@v5
with:
version-file: go.mod
go-version-file: go.mod
cache-dependency-path: '**/go.sum'
- name: Run Go Vet
run: |
make vet
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/scripts/copywrite.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schema_version = 1

project {
license = "MIT"
copyright_holder = "Seth Hoenig"
copyright_year = 2020
header_ignore = [
"**/*.sh",
".src/**",
".bin/**",
".github/**",
".goreleaser.yaml",
]
}
38 changes: 38 additions & 0 deletions .github/workflows/scripts/golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
run:
timeout: 5m
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- dogsled
- dupword
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
- gocritic
- gofmt
- gosimple
- govet
- ineffassign
- makezero
- misspell
- musttag
- nilnil
- noctx
- perfsprint
- prealloc
- predeclared
- reassign
- revive
- rowserrcheck
- staticcheck
- sqlclosecheck
- tagalign
- tenv
- unused
- whitespace

12 changes: 0 additions & 12 deletions .golangci.yaml

This file was deleted.

21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
NAME = envy

default: build

.PHONY: build
build: clean
@echo "--> Build ..."
CGO_ENABLED=0 go build -o output/$(NAME)

.PHONY: clean
clean:
@echo "--> Clean ..."
rm -rf dist output/$(NAME)

.PHONY: test
test:
@echo "--> Test Go Sources ..."
go test -race ./...

.PHONY: vet
vet:
@echo "--> Vet Go Sources ..."
go vet ./...

.PHONY: copywrite
copywrite:
@echo "--> Checking Copywrite ..."
copywrite \
--config .github/workflows/scripts/copywrite.hcl headers \
--spdx "MIT"

.PHONY: lint
lint: vet
@echo "--> Lint ..."
@golangci-lint run --config .github/workflows/scripts/golangci.yaml

.PHONY: release
release:
@echo "--> RELEASE ..."
envy exec gh-release goreleaser release --clean
$(MAKE) clean

default: build
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
module github.com/shoenig/envy

go 1.21
go 1.23

require (
github.com/gojuno/minimock/v3 v3.3.6
github.com/gojuno/minimock/v3 v3.3.14
github.com/google/subcommands v1.2.0
github.com/hashicorp/go-set/v2 v2.1.0
github.com/hashicorp/go-uuid v1.0.3
github.com/pkg/errors v0.9.1
github.com/shoenig/go-conceal v0.5.3
github.com/shoenig/go-conceal v0.5.4
github.com/shoenig/ignore v0.4.0
github.com/shoenig/regexplus v0.3.0
github.com/shoenig/test v0.6.7
github.com/zalando/go-keyring v0.2.3
go.etcd.io/bbolt v1.3.8
github.com/shoenig/test v1.9.1
github.com/zalando/go-keyring v0.2.5
go.etcd.io/bbolt v1.3.11
)

require (
github.com/alessio/shellescape v1.4.2 // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.24.0 // indirect
)
42 changes: 22 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs=
github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps=
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gojuno/minimock/v3 v3.3.6 h1:tZQQaDgKSxsKiVia9vt6zZ/qsKNGBw2D0ubHQPr+mHc=
github.com/gojuno/minimock/v3 v3.3.6/go.mod h1:kjvubEBVT8aUQ9e+g8x/hPfAhiOoqW7WinzzJgzr4ws=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gojuno/minimock/v3 v3.3.14 h1:tUzeohWMvJpz3ZXURPdARtGPsryV25ac8uFJIeucFzo=
github.com/gojuno/minimock/v3 v3.3.14/go.mod h1:lCxxcyH/BqkeMxE9h00ySVVZtRrsBzqd4UAQueQ0ru0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/hashicorp/go-set/v2 v2.1.0 h1:iERPCQWks+I+4bTgy0CT2myZsCqNgBg79ZHqwniohXo=
Expand All @@ -20,23 +20,25 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shoenig/go-conceal v0.5.3 h1:MUkStmwzC+1+TjOntRbpcMNy5svCIVlXVDjwpo+JCzI=
github.com/shoenig/go-conceal v0.5.3/go.mod h1:vsx01rl2gFFGcDvOPnieoGeJrpziMRbVEyGde4mA1Zc=
github.com/shoenig/go-conceal v0.5.4 h1:xLzarDUw3vUJjz+DirzO58yijkX4I9F1KA+RPZMLGLY=
github.com/shoenig/go-conceal v0.5.4/go.mod h1:LXmjZn/bO1Nrtvfex4VNbKViVE+aMhVvskZx8o7HBfs=
github.com/shoenig/ignore v0.4.0 h1:qPOWs0slbPMtenC0H3cKvu5Kn3hQFTE3yK6YJvyNDlA=
github.com/shoenig/ignore v0.4.0/go.mod h1:VF91FoiYAwXq4KinOq6zP5xfFw/Ib6MfftaGKYTpmwo=
github.com/shoenig/regexplus v0.3.0 h1:+eJZ5P4y1IY4+NgkIIvIqqdG/uYRBuSg4vWUjEppLcY=
github.com/shoenig/regexplus v0.3.0/go.mod h1:AT46KcYMK7iD/drPHdFtmB42TetxBe5S/O3vMGPa5cw=
github.com/shoenig/test v0.6.7 h1:k92ohN9VyRfZn0ezNfwamtIBT/5byyfLVktRmL/Jmek=
github.com/shoenig/test v0.6.7/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms=
github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
github.com/shoenig/test v1.9.1 h1:oO841L4cjcOd+wp+EZTqGGghT8pe6mXW9iHZLlNG9gg=
github.com/shoenig/test v1.9.1/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8=
github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16 changes: 9 additions & 7 deletions internal/commands/common.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Seth Hoenig
// SPDX-License-Identifier: MIT

package commands

import (
"flag"
"fmt"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -49,11 +51,11 @@ func newExtractor(ring keyring.Ring) Extractor {
// - any error
func (e *extractor) PreProcess(args []string) (string, *set.Set[string], *set.HashSet[*conceal.Text, int], error) {
if len(args) < 2 {
return "", nil, nil, fmt.Errorf("requires at least 2 arguments (namespace, <key,...>)")
return "", nil, nil, errors.New("requires at least 2 arguments (namespace, <key,...>)")
}
ns := args[0]
rm := set.New[string](4)
add := set.NewHashSet[*conceal.Text, int](8)
add := set.NewHashSet[*conceal.Text](8)
for i := 1; i < len(args); i++ {
s := args[i]
switch {
Expand All @@ -62,7 +64,7 @@ func (e *extractor) PreProcess(args []string) (string, *set.Set[string], *set.Ha
case strings.Contains(s, "="):
add.Insert(conceal.New(s))
default:
return "", nil, nil, fmt.Errorf("argument must start with '-' or contain '='")
return "", nil, nil, errors.New("argument must start with '-' or contain '='")
}
}
return ns, rm, add, nil
Expand All @@ -82,11 +84,11 @@ func (e *extractor) Namespace(vars *set.HashSet[*conceal.Text, int]) (*safe.Name
func (e *extractor) process(args []*conceal.Text) (map[string]safe.Encrypted, error) {
content := make(map[string]safe.Encrypted, len(args))
for _, kv := range args {
if key, secret, err := e.encryptEnvVar(kv); err != nil {
key, secret, err := e.encryptEnvVar(kv)
if err != nil {
return nil, err
} else {
content[key] = secret
}
content[key] = secret
}
return content, nil
}
Expand Down
3 changes: 3 additions & 0 deletions internal/commands/common_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Seth Hoenig
// SPDX-License-Identifier: MIT

package commands

import (
Expand Down
3 changes: 3 additions & 0 deletions internal/commands/exec.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Seth Hoenig
// SPDX-License-Identifier: MIT

package commands

import (
Expand Down
7 changes: 6 additions & 1 deletion internal/commands/exec_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Seth Hoenig
// SPDX-License-Identifier: MIT

package commands

import (
Expand All @@ -22,6 +25,8 @@ func skipOS(t *testing.T) {
switch runtime.GOOS {
case "windows":
t.Skip("skipping on windows")
default:
// do not skip
}
}

Expand Down Expand Up @@ -152,7 +157,7 @@ func TestExecCmd_Execute_badCommand(t *testing.T) {

switch runtime.GOOS {
case "windows":
must.Eq(t, "envy: failed to exec: exec: \"/does/not/exist\": file does not exist\n", b.String())
must.StrContains(t, b.String(), "envy: failed to exec: exec:") // nolint: dupword
default:
must.Eq(t, "envy: failed to exec: fork/exec /does/not/exist: no such file or directory\n", b.String())
}
Expand Down
13 changes: 8 additions & 5 deletions internal/commands/list.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Seth Hoenig
// SPDX-License-Identifier: MIT

package commands

import (
Expand Down Expand Up @@ -28,23 +31,23 @@ type listCmd struct {
box safe.Box
}

func (lc listCmd) Name() string {
func (listCmd) Name() string {
return listCmdName
}

func (lc listCmd) Synopsis() string {
func (listCmd) Synopsis() string {
return listCmdSynopsis
}

func (lc listCmd) Usage() string {
func (listCmd) Usage() string {
return listCmdUsage
}

func (lc listCmd) SetFlags(set *flag.FlagSet) {
func (listCmd) SetFlags(*flag.FlagSet) {
// no flags when listing namespaces
}

func (lc listCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
func (lc listCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
if f.NArg() != 0 {
lc.writer.Errorf("list command expects no args")
return subcommands.ExitUsageError
Expand Down
Loading
Loading