Skip to content

Commit

Permalink
NOISSUE - Fix failing CI (#21)
Browse files Browse the repository at this point in the history
* Fix failing CI

Signed-off-by: nyagamunene <[email protected]>

* Update check generated files

Signed-off-by: nyagamunene <[email protected]>

* Update linter and protoc issues

Signed-off-by: nyagamunene <[email protected]>

* Update protoc version

Signed-off-by: nyagamunene <[email protected]>

---------

Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene authored Sep 24, 2024
1 parent 56751e0 commit 7188f89
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 126 deletions.
160 changes: 80 additions & 80 deletions .github/workflows/check-generated-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,83 +33,83 @@ jobs:
uses: dorny/paths-filter@v3
id: changes
with:
base: main
filters: |
proto:
- ".github/workflows/check-generated-files.yml"
mocks:
- ".github/workflows/check-generated-files.yml"
- "sdk/mocks/sdk.go"
- "mocks/repository.go"
- "mocks/service.go"
- name: Set up protoc
if: steps.changes.outputs.proto == 'true'
run: |
PROTOC_VERSION=27.2
PROTOC_GEN_VERSION=v1.34.2
PROTOC_GRPC_VERSION=v1.4.0
# Download and install protoc
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -0L -o $PROTOC_ZIP https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
unzip -o $PROTOC_ZIP -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/
rm -rf $PROTOC_ZIP protoc3
# Install protoc-gen-go and protoc-gen-go-grpc
go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_VERSION
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GRPC_VERSION
# Add protoc to the PATH
export PATH=$PATH:/usr/local/bin/protoc
- name: Check Protobuf is up to Date
if: steps.changes.outputs.proto == 'true'
run: |
for p in $(find . -name "*.pb.go"); do
mv $p $p.tmp
done
make proto
for p in $(find . -name "*.pb.go"); do
if ! cmp -s $p $p.tmp; then
echo "Error: Proto file and generated Go file $p are out of sync!"
echo "Please run 'make proto' with protoc version $PROTOC_VERSION, protoc-gen-go version $PROTOC_GEN_VERSION and protoc-gen-go-grpc version $PROTOC_GRPC_VERSION and commit the changes."
exit 1
fi
done
- name: Check Mocks are up to Date
if: steps.changes.outputs.mocks == 'true'
run: |
MOCKERY_VERSION=v2.43.2
STRINGER_VERSION=v0.19.0
go install github.com/vektra/mockery/v2@$MOCKERY_VERSION
go install golang.org/x/tools/cmd/stringer@$STRINGER_VERSION
mv ./sdk/mocks/sdk.go ./sdk/mocks/sdk.go.tmp
mv ./mocks/repository.go ./mocks/repository.go.tmp
mv ./mocks/service.go ./mocks/service.go.tmp
make mocks
check_mock_changes() {
local file_path=$1
local tmp_file_path=$1.tmp
local entity_name=$2
if ! cmp -s "$file_path" "$tmp_file_path"; then
echo "Error: Generated mocks for $entity_name are out of sync!"
echo "Please run 'make mocks' with mockery version $MOCKERY_VERSION and commit the changes."
exit 1
fi
}
check_mock_changes ./sdk/mocks/sdk.go "SDK ./sdk/mocks/sdk.go"
check_mock_changes ./mocks/repository.go "Certs Repository ./mocks/repository.go"
check_mock_changes ./mocks/service.go "Certs Service ./mocks/service.go"
base: main
filters: |
proto:
- ".github/workflows/check-generated-files.yml"
mocks:
- ".github/workflows/check-generated-files.yml"
- "sdk/mocks/sdk.go"
- "mocks/repository.go"
- "mocks/service.go"
- name: Set up protoc
if: steps.changes.outputs.proto == 'true'
run: |
PROTOC_VERSION=27.1
PROTOC_GEN_VERSION=v1.34.2
PROTOC_GRPC_VERSION=v1.4.0
# Download and install protoc
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -0L -o $PROTOC_ZIP https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
unzip -o $PROTOC_ZIP -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/
rm -rf $PROTOC_ZIP protoc3
# Install protoc-gen-go and protoc-gen-go-grpc
go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_VERSION
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GRPC_VERSION
# Add protoc to the PATH
export PATH=$PATH:/usr/local/bin/protoc
- name: Check Protobuf is up to Date
if: steps.changes.outputs.proto == 'true'
run: |
for p in $(find . -name "*.pb.go"); do
mv $p $p.tmp
done
make proto
for p in $(find . -name "*.pb.go"); do
if ! cmp -s $p $p.tmp; then
echo "Error: Proto file and generated Go file $p are out of sync!"
echo "Please run 'make proto' with protoc version $PROTOC_VERSION, protoc-gen-go version $PROTOC_GEN_VERSION and protoc-gen-go-grpc version $PROTOC_GRPC_VERSION and commit the changes."
exit 1
fi
done
- name: Check Mocks are up to Date
if: steps.changes.outputs.mocks == 'true'
run: |
MOCKERY_VERSION=v2.43.2
STRINGER_VERSION=v0.19.0
go install github.com/vektra/mockery/v2@$MOCKERY_VERSION
go install golang.org/x/tools/cmd/stringer@$STRINGER_VERSION
mv ./sdk/mocks/sdk.go ./sdk/mocks/sdk.go.tmp
mv ./mocks/repository.go ./mocks/repository.go.tmp
mv ./mocks/service.go ./mocks/service.go.tmp
make mocks
check_mock_changes() {
local file_path=$1
local tmp_file_path=$1.tmp
local entity_name=$2
if ! cmp -s "$file_path" "$tmp_file_path"; then
echo "Error: Generated mocks for $entity_name are out of sync!"
echo "Please run 'make mocks' with mockery version $MOCKERY_VERSION and commit the changes."
exit 1
fi
}
check_mock_changes ./sdk/mocks/sdk.go "SDK ./sdk/mocks/sdk.go"
check_mock_changes ./mocks/repository.go "Certs Repository ./mocks/repository.go"
check_mock_changes ./mocks/service.go "Certs Service ./mocks/service.go"
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:
with:
node-version: lts/*

- name: Install dependencies
run: npm install

- name: Run Prettier
id: prettier-run
uses: rutajdash/[email protected]
Expand Down
14 changes: 4 additions & 10 deletions api/http/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ var (
_ Response = (*ocspRes)(nil)
)

type pageRes struct {
Limit uint64 `json:"limit"`
Offset uint64 `json:"offset"`
Total uint64 `json:"total"`
}

type renewCertRes struct {
renewed bool
}
Expand Down Expand Up @@ -135,6 +129,10 @@ func (res listCertsRes) Headers() map[string]string {
return map[string]string{}
}

func (res listCertsRes) Empty() bool {
return false
}

type viewCertRes struct {
SerialNumber string `json:"serial_number"`
Certificate string `json:"certificate"`
Expand All @@ -156,10 +154,6 @@ func (res viewCertRes) Empty() bool {
return false
}

func (res listCertsRes) Empty() bool {
return false
}

type ocspRes struct {
template ocsp.Response
signer crypto.Signer
Expand Down
4 changes: 1 addition & 3 deletions certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import (

const serialNumber = "serial number"

var (
invalidToken = "123"
)
var invalidToken = "123"

func TestIssueCert(t *testing.T) {
cRepo := new(mocks.MockRepository)
Expand Down
1 change: 0 additions & 1 deletion cli/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ func TestGetTokenCmd(t *testing.T) {
t.Fatalf("Failed to unmarshal JSON: %v", err)
}
assert.Equal(t, tc.token, token, fmt.Sprintf("%v unexpected response, expected: %v, got: %v", tc.desc, tc.token, token))

}
sdkCall.Unset()
})
Expand Down
10 changes: 3 additions & 7 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,9 @@ type config struct {
const filePermission = 0o644

var (
errReadFail = errors.New("failed to read config file")
errNoKey = errors.New("no such key")
errUnsupportedKeyValue = errors.New("unsupported data type for key")
errWritingConfig = errors.New("error in writing the updated config to file")
errInvalidURL = errors.New("invalid url")
errURLParseFail = errors.New("failed to parse url")
defaultConfigPath = "./config.toml"
errReadFail = errors.New("failed to read config file")
errWritingConfig = errors.New("error in writing the updated config to file")
defaultConfigPath = "./config.toml"
)

func read(file string) (config, error) {
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ go 1.23.0

require (
github.com/caarlos0/env/v10 v10.0.0
github.com/fatih/color v1.17.0
github.com/go-chi/chi v1.5.5
github.com/go-kit/kit v0.13.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f
github.com/jackc/pgx/v5 v5.6.0
github.com/jmoiron/sqlx v1.4.0
github.com/ory/dockertest/v3 v3.11.0
github.com/pelletier/go-toml v1.9.5
github.com/prometheus/client_golang v1.19.1
github.com/rubenv/sql-migrate v1.7.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0
Expand All @@ -25,6 +29,7 @@ require (
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
moul.io/http2curl v1.0.0
)

require (
Expand All @@ -41,7 +46,6 @@ require (
github.com/docker/docker v27.1.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -52,7 +56,6 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
Expand All @@ -65,14 +68,13 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.13 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
Expand All @@ -87,5 +89,4 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
moul.io/http2curl v1.0.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU=
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8=
Expand All @@ -84,6 +86,8 @@ github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down Expand Up @@ -137,6 +141,10 @@ github.com/rubenv/sql-migrate v1.7.0/go.mod h1:S4wtDEG1CKn+0ShpTtzWhFpHHI5PvCUti
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand Down
6 changes: 3 additions & 3 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const (

var (
// Version represents the last service git tag in git history.
// It's meant to be set using go build ldflags:
// It's meant to be set using go build ldflags.
Version = "0.0.0"
// Commit represents the service git commit hash.
// It's meant to be set using go build ldflags:
// It's meant to be set using go build ldflags.

Commit = "ffffffff"
// BuildTime represetns the service build time.
// It's meant to be set using go build ldflags:
// It's meant to be set using go build ldflags.
BuildTime = "1970-01-01_00:00:00"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/server/http/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (c) Ultraviolet
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

package http
4 changes: 3 additions & 1 deletion internal/server/http/http.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) Ultraviolet
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

package http

import (
Expand Down
Loading

0 comments on commit 7188f89

Please sign in to comment.