diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index eed46838962..10f17a2fcbf 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -23,7 +23,7 @@ Please avoid: ## Building the project Prerequisites: -- Go 1.19+ +- Go 1.21+ Build with: * Unix-like systems: `make` diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 3974737aae7..b15b23806f8 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -1,6 +1,6 @@ name: Deployment -concurrency: +concurrency: group: ${{ github.workflow }}-${{ github.ref_name }} cancel-in-progress: true @@ -17,7 +17,7 @@ on: default: production type: environment go_version: - default: "1.19" + default: "1.21" type: string platforms: default: "linux,macos,windows" @@ -61,7 +61,7 @@ jobs: dist/*.tar.gz dist/*.rpm dist/*.deb - + macos: runs-on: macos-latest environment: ${{ inputs.environment }} @@ -118,7 +118,7 @@ jobs: path: | dist/*.tar.gz dist/*.zip - + windows: runs-on: windows-latest environment: ${{ inputs.environment }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1a3a3331885..a375e2d8fec 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,10 +13,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Set up Go 1.19 + - name: Set up Go 1.21 uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dd1fede0dec..c8defbf3a3b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,10 +19,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.19 + - name: Set up Go 1.21 uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code uses: actions/checkout@v3 @@ -40,7 +40,7 @@ jobs: go mod verify go mod download - LINT_VERSION=1.50.1 + LINT_VERSION=1.54.1 curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \ tar xz --strip-components 1 --wildcards \*/golangci-lint mkdir -p bin && mv golangci-lint bin/ diff --git a/docs/source.md b/docs/source.md index 9034e9de599..cc1605b8cbf 100644 --- a/docs/source.md +++ b/docs/source.md @@ -1,6 +1,6 @@ # Installation from source -1. Verify that you have Go 1.19+ installed +1. Verify that you have Go 1.21+ installed ```sh $ go version diff --git a/go.mod b/go.mod index 2602fc49603..48632a1e3e7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cli/cli/v2 -go 1.19 +go 1.21 require ( github.com/AlecAivazis/survey/v2 v2.3.7 diff --git a/go.sum b/go.sum index 47e5159ae0a..14af85480e3 100644 --- a/go.sum +++ b/go.sum @@ -91,6 +91,7 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -182,6 +183,7 @@ golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -221,11 +223,13 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= diff --git a/internal/codespaces/api/api_test.go b/internal/codespaces/api/api_test.go index 75f82c39ed3..65852cc7914 100644 --- a/internal/codespaces/api/api_test.go +++ b/internal/codespaces/api/api_test.go @@ -136,6 +136,7 @@ func createHttpClient() (*http.Client, error) { func TestNew_APIURL_dotcomConfig(t *testing.T) { t.Setenv("GITHUB_API_URL", "") + t.Setenv("GITHUB_SERVER_URL", "https://github.com") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { return &config.AuthConfig{} @@ -158,6 +159,7 @@ func TestNew_APIURL_dotcomConfig(t *testing.T) { func TestNew_APIURL_customConfig(t *testing.T) { t.Setenv("GITHUB_API_URL", "") + t.Setenv("GITHUB_SERVER_URL", "https://github.mycompany.com") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { authCfg := &config.AuthConfig{} @@ -182,6 +184,7 @@ func TestNew_APIURL_customConfig(t *testing.T) { func TestNew_APIURL_env(t *testing.T) { t.Setenv("GITHUB_API_URL", "https://api.mycompany.com") + t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { return &config.AuthConfig{} @@ -218,6 +221,7 @@ func TestNew_APIURL_dotcomFallback(t *testing.T) { func TestNew_ServerURL_dotcomConfig(t *testing.T) { t.Setenv("GITHUB_SERVER_URL", "") + t.Setenv("GITHUB_API_URL", "https://api.github.com") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { return &config.AuthConfig{} @@ -240,6 +244,7 @@ func TestNew_ServerURL_dotcomConfig(t *testing.T) { func TestNew_ServerURL_customConfig(t *testing.T) { t.Setenv("GITHUB_SERVER_URL", "") + t.Setenv("GITHUB_API_URL", "https://github.mycompany.com/api/v3") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { authCfg := &config.AuthConfig{} @@ -264,6 +269,7 @@ func TestNew_ServerURL_customConfig(t *testing.T) { func TestNew_ServerURL_env(t *testing.T) { t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com") + t.Setenv("GITHUB_API_URL", "https://api.mycompany.com") cfg := &config.ConfigMock{ AuthenticationFunc: func() *config.AuthConfig { return &config.AuthConfig{} diff --git a/pkg/cmd/label/create.go b/pkg/cmd/label/create.go index f9c63f6e682..0a88fbcab5d 100644 --- a/pkg/cmd/label/create.go +++ b/pkg/cmd/label/create.go @@ -102,8 +102,8 @@ func createRun(opts *createOptions) error { } if opts.Color == "" { - rand.Seed(time.Now().UnixNano()) - opts.Color = randomColors[rand.Intn(len(randomColors)-1)] + r := rand.New(rand.NewSource(time.Now().UnixNano())) + opts.Color = randomColors[r.Intn(len(randomColors)-1)] } opts.IO.StartProgressIndicator() diff --git a/pkg/cmd/repo/credits/credits.go b/pkg/cmd/repo/credits/credits.go index 37390bcb194..4b7b9fb289f 100644 --- a/pkg/cmd/repo/credits/credits.go +++ b/pkg/cmd/repo/credits/credits.go @@ -178,7 +178,7 @@ func creditsRun(opts *CreditsOptions) error { return nil } - rand.Seed(time.Now().UnixNano()) + r := rand.New(rand.NewSource(time.Now().UnixNano())) lines := []string{} @@ -199,13 +199,13 @@ func creditsRun(opts *CreditsOptions) error { starLinesLeft := []string{} for x := 0; x < len(lines); x++ { - starLinesLeft = append(starLinesLeft, starLine(margin)) + starLinesLeft = append(starLinesLeft, starLine(r, margin)) } starLinesRight := []string{} for x := 0; x < len(lines); x++ { lineWidth := termWidth - (margin + len(lines[x])) - starLinesRight = append(starLinesRight, starLine(lineWidth)) + starLinesRight = append(starLinesRight, starLine(r, lineWidth)) } loop := true @@ -245,13 +245,13 @@ func creditsRun(opts *CreditsOptions) error { return nil } -func starLine(width int) string { +func starLine(r *rand.Rand, width int) string { line := "" starChance := 0.1 for y := 0; y < width; y++ { - chance := rand.Float64() + chance := r.Float64() if chance <= starChance { - charRoll := rand.Float64() + charRoll := r.Float64() switch { case charRoll < 0.3: line += "." diff --git a/pkg/cmd/repo/garden/garden.go b/pkg/cmd/repo/garden/garden.go index c9c59d420f7..840d5adca8f 100644 --- a/pkg/cmd/repo/garden/garden.go +++ b/pkg/cmd/repo/garden/garden.go @@ -169,7 +169,7 @@ func gardenRun(opts *GardenOptions) error { } seed := computeSeed(ghrepo.FullName(toView)) - rand.Seed(seed) + r := rand.New(rand.NewSource(seed)) termWidth, termHeight, err := utils.TerminalSize(out) if err != nil { @@ -198,7 +198,7 @@ func gardenRun(opts *GardenOptions) error { } player := &Player{0, 0, cs.Bold("@"), geo, 0} - garden := plantGarden(commits, geo) + garden := plantGarden(r, commits, geo) if len(garden) < geo.Height { geo.Height = len(garden) } @@ -334,11 +334,11 @@ func isQuit(b []byte) bool { return rune(b[0]) == 'q' || bytes.Equal(b, ctrlC) } -func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell { +func plantGarden(r *rand.Rand, commits []*Commit, geo *Geometry) [][]*Cell { cellIx := 0 grassCell := &Cell{RGB(0, 200, 0, ","), "You're standing on a patch of grass in a field of wildflowers."} garden := [][]*Cell{} - streamIx := rand.Intn(geo.Width - 1) + streamIx := r.Intn(geo.Width - 1) if streamIx == geo.Width/2 { streamIx-- } @@ -363,7 +363,7 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell { }) tint += 15 streamIx-- - if rand.Float64() < 0.5 { + if r.Float64() < 0.5 { streamIx++ } if streamIx < 0 { @@ -393,7 +393,7 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell { continue } - chance := rand.Float64() + chance := r.Float64() if chance <= geo.Density { commit := commits[cellIx] garden[y] = append(garden[y], &Cell{