Skip to content

Commit

Permalink
Merge branch 'main' into do-not-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 21, 2023
2 parents 3fe5e53 + 16460b1 commit f36b91a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 36 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/sethvargo/go-envconfig v0.8.0 // indirect
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/net v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s=
golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
9 changes: 6 additions & 3 deletions setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ runs:
uses: actions/cache@v3
with:
path: ${{ steps.run.outputs.cache_path }}
key: ${{ inputs.cache-key }}-${{ steps.run.outputs.cache_week }}-${{ hashFiles('**/go.mod') }}
key: ${{ inputs.cache-key }}-${{ steps.run.outputs.cache_week }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**') }}
restore-keys: |
${{ inputs.cache-key }}-${{ steps.run.outputs.cache_week }}-
${{ inputs.cache-key }}-${{ steps.run.outputs.cache_week }}-${{ hashFiles('**/go.mod') }}
${{ inputs.cache-key }}-${{ steps.run.outputs.cache_week }}
# we don't want them on CI
- name: Clean test and fuzz caches
run: go clean -testcache -fuzzcache
run: |
go clean -testcache
go clean -fuzzcache
shell: bash
37 changes: 10 additions & 27 deletions setup-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,13 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"time"

"github.com/sethvargo/go-githubactions"

"github.com/FerretDB/github-actions/internal"
)

// tidyDir runs `go mod tidy` in the specified directory.
func tidyDir(action *githubactions.Action, dir string) {
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = filepath.Dir(dir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

start := time.Now()

action.Infof("Running `%s` in %s ...", strings.Join(cmd.Args, " "), cmd.Dir)

if err := cmd.Run(); err != nil {
action.Fatalf("%s", err)
}

action.Infof("Done in %s.", time.Since(start))
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -101,7 +82,6 @@ func main() {
action.SetOutput("cache_path", gocache)

// download modules in directories with `go.mod` file
var wg sync.WaitGroup
err := filepath.Walk(workspace, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
Expand All @@ -121,17 +101,20 @@ func main() {
return nil
}

wg.Add(1)
go func() {
defer wg.Done()
tidyDir(action, filepath.Dir(path))
}()
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = filepath.Dir(path)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
start := time.Now()
action.Infof("Running `%s` in %s ...", strings.Join(cmd.Args, " "), cmd.Dir)
if err = cmd.Run(); err != nil {
return err
}
action.Infof("Done in %s.", time.Since(start))

return nil
})
if err != nil {
action.Fatalf("Error walking directory: %s", err)
}

wg.Wait()
}
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ require (
golang.org/x/exp v0.0.0-20220930202632-ec3f01382ef9 // indirect
golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down

0 comments on commit f36b91a

Please sign in to comment.