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

fix: lint #438

Merged
merged 4 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
args: --timeout=10m
version: v1.28
version: v1.49
github-token: ${{ secrets.GITHUB_TOKEN }}
tests-on-windows:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
runs-on: windows-latest
strategy:
matrix:
golang:
- 1.15.x
- 1.18.x
steps:
- uses: actions/checkout@v2
- name: Install Go
Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
golang:
- 1.15.x
- 1.18.x
steps:
- uses: actions/checkout@v2
- name: Install Go
Expand All @@ -68,8 +68,7 @@ jobs:
strategy:
matrix:
golang:
- 1.14.x
- 1.15.x
- 1.18.x
moul marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v2
- name: Install Go
Expand Down
2 changes: 1 addition & 1 deletion go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/cmd/yolo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func yolo(args []string) error {
}

if artifactsCachePath != "" {
if err := os.MkdirAll(artifactsCachePath, 0755); err != nil {
if err := os.MkdirAll(artifactsCachePath, 0o755); err != nil {
return err
}
}
Expand Down
1 change: 0 additions & 1 deletion go/pkg/yolopb/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (b *Build) PrepareOutput(salt string) error {

// AddSignedURLs adds new fields containing URLs with a signature
func (a *Artifact) AddSignedURLs(key string) error {

var err error
a.DLArtifactSignedURL, err = signature.GetSignedURL("GET", "/api/artifact-dl/"+a.ID, "", key)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions go/pkg/yolopb/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (
"strings"
)

var (
signedOffByLine = regexp.MustCompile(`Signed-off-by: (.*)`)
)
var signedOffByLine = regexp.MustCompile(`Signed-off-by: (.*)`)

func cleanupCommitMessage(msg string) string {
if msg == "" {
Expand Down
1 change: 0 additions & 1 deletion go/pkg/yolostore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

type Store interface {

// artifacts store
GetArtifactByID(id string) (*yolopb.Artifact, error)
GetAllArtifactsWithoutBundleID() ([]*yolopb.Artifact, error)
Expand Down
2 changes: 0 additions & 2 deletions go/pkg/yolosvc/api_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func TestServiceDevDumpObjects(t *testing.T) {

assert.Equal(t, expectedDownloads, resp.Downloads)
assert.Equal(t, expectedBatch, resp.Batch)

}

func TestServiceDevDumpObjects_withPreloading(t *testing.T) {
Expand Down Expand Up @@ -244,5 +243,4 @@ func TestServiceDevDumpObjects_withPreloading(t *testing.T) {

assert.Equal(t, expectedDownloads, resp.Downloads)
assert.Equal(t, expectedBatch, resp.Batch)

}
8 changes: 3 additions & 5 deletions go/pkg/yolosvc/api_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand All @@ -26,7 +25,6 @@ import (
)

func (svc *service) ArtifactDownloader(w http.ResponseWriter, r *http.Request) {

id := chi.URLParam(r, "artifactID")

artifact, err := svc.store.GetArtifactByID(id)
Expand Down Expand Up @@ -200,7 +198,7 @@ func (svc *service) signAndStreamIPA(artifact yolopb.Artifact, w io.Writer) erro
// sign ipa
var signed string
{
tempdir, err := ioutil.TempDir("", "yolo")
tempdir, err := os.MkdirTemp("", "yolo")
if err != nil {
return err
}
Expand All @@ -209,7 +207,7 @@ func (svc *service) signAndStreamIPA(artifact yolopb.Artifact, w io.Writer) erro
// write unsigned-file to tempdir
unsigned := filepath.Join(tempdir, "unsigned.ipa")
signed = filepath.Join(tempdir, "signed.ipa")
f, err := os.OpenFile(unsigned, os.O_RDWR|os.O_CREATE, 0755)
f, err := os.OpenFile(unsigned, os.O_RDWR|os.O_CREATE, 0o755)
if err != nil {
return err
}
Expand Down Expand Up @@ -308,7 +306,7 @@ func (svc *service) artifactDownloadFromProvider(artifact *yolopb.Artifact, w io
return fmt.Errorf("failed to download artifact: %w", err)
}
defer resp.Body.Close()
zipContent, err = ioutil.ReadAll(resp.Body)
zipContent, err = io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to download artifact stream: %w", err)
}
Expand Down
7 changes: 5 additions & 2 deletions go/pkg/yolosvc/api_plist.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"berty.tech/yolo/v2/go/pkg/plistgen"
"github.com/go-chi/chi"
"github.com/stretchr/signature"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"google.golang.org/grpc/codes"
)

Expand Down Expand Up @@ -36,9 +38,10 @@ func (svc *service) PlistGenerator(w http.ResponseWriter, r *http.Request) {
url = "/api/artifact-dl/" + id
)
if artifact.HasBuild != nil && artifact.HasBuild.HasProject != nil {
title = strings.Title(artifact.HasBuild.HasProject.Name)
c := cases.Title(language.Und)
title = c.String(artifact.HasBuild.HasProject.Name)
if artifact.HasBuild.HasProject.HasOwner != nil {
subtitle = strings.Title(artifact.HasBuild.HasProject.HasOwner.Name)
subtitle = c.String(artifact.HasBuild.HasProject.HasOwner.Name)
}
}
pkgURL, err := signature.GetSignedURL("GET", url, "", svc.authSalt)
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/yolosvc/driver_bintray.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type BintrayWorkerOpts struct {
func (svc *service) BintrayWorker(ctx context.Context, opts BintrayWorkerOpts) error {
opts.applyDefaults()

var logger = opts.Logger.Named("btry")
logger := opts.Logger.Named("btry")

for iteration := 0; ; iteration++ {
logger.Debug("bintray: refresh", zap.Int("iteration", iteration))
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/yolosvc/driver_circleci.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const circleciMaxPerPage = 30
func (svc *service) CircleciWorker(ctx context.Context, opts CircleciWorkerOpts) error {
opts.applyDefaults()

var logger = opts.Logger.Named("circ")
logger := opts.Logger.Named("circ")

for iteration := 0; ; iteration++ {
since, err := lastBuildCreatedTime(ctx, svc.store, yolopb.Driver_CircleCI)
Expand Down
8 changes: 4 additions & 4 deletions go/pkg/yolosvc/driver_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type githubWorker struct {
repoConfigs []githubRepoConfig
}

func (worker githubWorker) ParseConfig() (bool, error) {
func (worker *githubWorker) ParseConfig() (bool, error) {
if worker.opts.ReposFilter == "" {
return false, nil
}
Expand Down Expand Up @@ -392,9 +392,9 @@ func (worker *githubWorker) batchFromWorkflowRun(run *github.WorkflowRun, prs []
newBuild.State = yolopb.Build_Skipped
case conclusion == "timed_out":
newBuild.State = yolopb.Build_Timedout
//case conclusion == "action_required":
//case conclusion == "neutral":
//case conclusion == "state":
// case conclusion == "action_required":
// case conclusion == "neutral":
// case conclusion == "state":
default:
newBuild.State = yolopb.Build_UnknownState
worker.logger.Error(
Expand Down
4 changes: 2 additions & 2 deletions go/pkg/yolosvc/driver_pkgman.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type PkgmanWorkerOpts struct {
func (svc *service) PkgmanWorker(ctx context.Context, opts PkgmanWorkerOpts) error {
opts.applyDefaults()
// FIXME: handle pkgman version to recompute already computed artifacts with new filters
var logger = opts.Logger.Named("pman")
logger := opts.Logger.Named("pman")
for iteration := 0; ; iteration++ {
artifacts, err := svc.store.GetAllArtifactsWithoutBundleID()
if err != nil {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (svc *service) pkgmanExtractIPAAppIcon(app *ipa.App) (string, error) {

icon := md5Sum(b) + ".png"
iconsPath := filepath.Join(svc.artifactsCachePath, "icons")
if err := os.MkdirAll(iconsPath, 0755); err != nil {
if err := os.MkdirAll(iconsPath, 0o755); err != nil {
return "", err
}
iconPath := filepath.Join(iconsPath, icon)
Expand Down
3 changes: 2 additions & 1 deletion go/pkg/yolosvc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/subtle"
"fmt"
"google.golang.org/grpc/credentials/insecure"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -131,7 +132,7 @@ func NewServer(ctx context.Context, svc Service, opts ServerOpts) (*Server, erro
runtime.WithMarshalerOption(runtime.MIMEWildcard, &gateway.JSONPb{EmitDefaults: false, Indent: " ", OrigName: true}),
runtime.WithProtoErrorHandler(runtime.DefaultHTTPProtoErrorHandler),
)
grpcDialOpts := []grpc.DialOption{grpc.WithInsecure()}
grpcDialOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
if err := yolopb.RegisterYoloServiceHandlerFromEndpoint(ctx, gwmux, srv.grpcListenerAddr, grpcDialOpts); err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion go/pkg/yolosvc/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func testingCreateEntities(t *testing.T, db *gorm.DB) {
t.Helper()

if err := db.Transaction(func(tx *gorm.DB) error {

// create artifact
artifact := &yolopb.Artifact{
ID: "artif1",
Expand Down
6 changes: 2 additions & 4 deletions go/pkg/yolosvc/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import (
"berty.tech/yolo/v2/go/pkg/yolopb"
)

var (
githubMasterMerge = regexp.MustCompile(`Merge pull request #([0-9]+) from (.*)`)
)
var githubMasterMerge = regexp.MustCompile(`Merge pull request #([0-9]+) from (.*)`)

func artifactKindByPath(path string) yolopb.Artifact_Kind {
switch filepath.Ext(path) {
case ".ipa", ".unsigned-ipa", ".dummy-signed-ipa":
return yolopb.Artifact_IPA
case ".dmg", ".unsigned-dmg" , ".dummy-signed-dmg":
case ".dmg", ".unsigned-dmg", ".dummy-signed-dmg":
return yolopb.Artifact_DMG
case ".apk":
return yolopb.Artifact_APK
Expand Down