Skip to content

Commit

Permalink
Merge pull request #2429 from ActiveState/green/go_1x20.DX-668
Browse files Browse the repository at this point in the history
Update to Go 1.20
  • Loading branch information
Naatan authored Apr 5, 2023
2 parents af87ff2 + 42ffcc5 commit 0173f51
Show file tree
Hide file tree
Showing 40 changed files with 105 additions and 9,386 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
go-version:
- 1.16.x
- 1.20.x
platform:
- ubuntu-20.04
- macos-11
Expand All @@ -37,7 +37,6 @@ jobs:
runs-on: ${{ matrix.platform }}
env:
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
GOFLAGS: -mod=vendor
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
Expand All @@ -47,13 +46,13 @@ jobs:
# === OS Specific Steps ===
steps:

- # Checkout Code
- # === Checkout Code ===
name: Checkout code
uses: actions/checkout@v2

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand Down Expand Up @@ -103,8 +102,8 @@ jobs:
- # === Preprocess ===
name: Preprocess
shell: bash
timeout-minutes: 1
run: state run preprocess
timeout-minutes: 3
run: state run preprocess -v

- # === Parallel Tasks ===
name: Parallel Tasks
Expand Down Expand Up @@ -377,7 +376,6 @@ jobs:
runs-on: ubuntu-20.04
env:
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
GOFLAGS: -mod=vendor
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 10
Expand All @@ -392,7 +390,7 @@ jobs:

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand Down Expand Up @@ -429,7 +427,7 @@ jobs:
- # === Preprocess ===
name: Preprocess
shell: bash
run: state run preprocess
run: state run preprocess -v

- # === Cleanup Build Dir ===
name: Cleanup Build Dir
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/propagate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
propagate:
name: Propagate to affected version branches
runs-on: ubuntu-20.04
strategy:
matrix:
go-version:
- 1.20.x
env:
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
SHELL: bash
Expand All @@ -33,7 +37,7 @@ jobs:

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -56,7 +60,7 @@ jobs:
- # === Preprocess ===
name: Preprocess
shell: bash
run: state run preprocess
run: state run preprocess -v

- # === Propagate PR ===
name: Propagate PR
Expand Down Expand Up @@ -95,4 +99,4 @@ jobs:
name: Fail If Propagate PR failed
if: steps.propagate_pr.outcome == 'failure'
shell: bash
run: exit 1
run: exit 1
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
timeout-minutes: 30
runs-on: windows-2019
if: github.event.ref_type == 'tag' && contains(github.event.ref, 'release/remote-installer')
strategy:
matrix:
go-version:
- 1.20.x
env:
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
GOFLAGS: -mod=vendor
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -27,9 +30,9 @@ jobs:

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: ${{ matrix.go-version }}

- # === Setup ===
name: Setup
Expand All @@ -54,7 +57,7 @@ jobs:
name: Preprocess
shell: bash
timeout-minutes: 1
run: state run preprocess
run: state run preprocess -v

- # === Build Remote Installer ===
name: Build Remote Installer
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
verifypr:
name: Target & Verify PR
runs-on: ubuntu-20.04
strategy:
matrix:
go-version:
- 1.20.x
env:
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
SHELL: bash
Expand All @@ -36,7 +40,7 @@ jobs:

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -58,7 +62,7 @@ jobs:
- # === Preprocess ===
name: Preprocess
shell: bash
run: state run preprocess
run: state run preprocess -v

- # === Set Target PR & FixVersion ===
name: Set Target PR and FixVersion
Expand Down
55 changes: 29 additions & 26 deletions activestate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ constants:
- name: SET_ENV
description: The environment settings used throughout our project
value: |
GOFLAGS='-mod=vendor'
GOPATH="${GOPATH:=`go env GOPATH`}"
GOROOT="${GOROOT:=`go env GOROOT`}"
export CGO_ENABLED=0
Expand All @@ -49,14 +48,33 @@ constants:
scripts:
- name: install-deps
language: bash
if: ne .Shell "cmd"
value: |
export GO111MODULE=on
goflags="${GOFLAGS}"; unset GOFLAGS
GOFLAGS="${goflags}"
pushd ~
go install github.com/ActiveState/gozip/cmd/gozip@e455986
popd
$scripts.install-deps-os
if ! type "gozip" &> /dev/null; then
echo "gozip was not found on your PATH, installing .."
go install github.com/ActiveState/gozip/cmd/gozip@e455986
fi
- name: install-deps-dev
language: bash
if: ne .Shell "cmd"
value: |
if ! type "go" &> /dev/null; then
echo "go is not installed. Please install Go version 1.20 or above."
exit 1
fi
if ! type "golangci-lint" &> /dev/null; then
echo "golangci-lint was not found on your PATH, installing .."
go install github.com/golangci/golangci-lint/cmd/[email protected]
fi
git config core.hooksPath .githooks
if ! type "swagger" &> /dev/null; then
echo "swagger was not found on your PATH, installing .."
go install github.com/go-swagger/go-swagger/cmd/[email protected]
fi
if ! type "actionlint" &> /dev/null; then
echo "actionlint was not found on your PATH, installing .."
go install github.com/rhysd/actionlint/cmd/[email protected]
fi
- name: install-deps-os
language: bash
if: ne .OS.Name "Linux"
Expand All @@ -68,7 +86,7 @@ scripts:
value: |
set -e
$constants.SET_ENV
go run scripts/constants-generator/main.go -- internal/constants/generated.go
go run scripts/constants-generator/main.go ${@} -- internal/constants/generated.go
- name: build
language: bash
description: Builds the project with the host OS as the target OS.
Expand Down Expand Up @@ -391,23 +409,8 @@ events:
- name: activate
if: ne .Shell "cmd"
value: |
if ! type "go" &> /dev/null; then
echo "go is not installed. Please install Go version 1.11 or above."
exit 1
fi
if ! type "golangci-lint" &> /dev/null; then
echo "golangci-lint was not found on your PATH, installing .."
go install github.com/golangci/golangci-lint/cmd/[email protected]
fi
git config core.hooksPath .githooks
if ! type "swagger" &> /dev/null; then
echo "swagger was not found on your PATH, installing .."
go install github.com/go-swagger/go-swagger/cmd/[email protected]
fi
if ! type "actionlint" &> /dev/null; then
echo "actionlint was not found on your PATH, installing .."
go install github.com/rhysd/actionlint/cmd/[email protected]
fi
$scripts.install-deps-dev
$scripts.install-deps
- name: file-changed
scope: ["internal/locale/locales"]
value: build
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ActiveState/cli

go 1.17
go 1.20

require (
cloud.google.com/go v0.64.0
Expand Down Expand Up @@ -65,6 +65,7 @@ require (
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/term v0.1.0
golang.org/x/text v0.3.7
google.golang.org/genproto v0.0.0-20200815001618-f69a88009b70
gopkg.in/AlecAivazis/survey.v1 v1.8.8
Expand Down Expand Up @@ -150,7 +151,6 @@ require (
go.opencensus.io v0.22.4 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
golang.org/x/tools v0.1.11 // indirect
google.golang.org/api v0.30.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vbauerster/mpb/v7 v7.1.5 h1:vtUEUfQHmNeJETyF4AcRCOV6RC4wqFwNORy52UMXPbQ=
github.com/vbauerster/mpb/v7 v7.1.5/go.mod h1:4M8+qAoQqV60WDNktBM5k05i1iTrXE7rjKOHEVkVlec=
github.com/vektah/gqlparser v1.1.2 h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68=
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
Expand Down Expand Up @@ -732,7 +731,6 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200427165652-729f1e841bcc/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down
59 changes: 45 additions & 14 deletions scripts/constants-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,84 @@ package main

import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"time"

"github.com/dave/jennifer/jen"

"github.com/ActiveState/cli/internal/constants/preprocess"
)

var inTest = false
var (
inTest bool
start = time.Now()
verbose bool
silent bool
)

func logit(format string, as ...any) {
if verbose {
d := time.Since(start)
fmt.Fprintf(os.Stderr, "[%08dμs] ", d.Microseconds())
}
fmt.Fprintf(os.Stderr, format, as...)
fmt.Fprintln(os.Stderr)
}

func log(format string, as ...any) {
if silent {
return
}
logit(format, as...)
}

func logFatal(format string, as ...any) {
logit(format, as...)
os.Exit(1)
}

func main() {
if ! inTest {
flag.BoolVar(&verbose, "v", verbose, "Turn on verbose output")
flag.BoolVar(&silent, "s", silent, "Silence all non-critical output")
flag.Parse()

if !inTest {
run(os.Args)
}
}

func run(args []string) {
if len(args) < 2 || (args[1] == "--" && len(args) < 3) {
log.Fatalf("Usage: %s <target-file>", args[0])
log("Starting run logic")
if len(args) < 2 || strings.HasPrefix(args[len(args)-1], "-") {
logFatal("Usage: %s [-v] <target-file>", args[0])
}

log("Storing constants data in file buffer")
f := jen.NewFile("constants")

f.HeaderComment("Do NOT manually edit this file. It is generated using scripts/constants-generator using data from constants/preprocess.")
f.HeaderComment("This script is automatically ran by `make build`, so you shouldn't have to run this manually.")

for k, v := range preprocess.Constants {
fmt.Printf("Adding Constant: %s, Value: %s\n", k, v())
log("Adding Constant: %s, Value: %s", k, v())
f.Const().Id(k).Op("=").Lit(v())
}

log("Rendering file buffer")
buf := &bytes.Buffer{}
err := f.Render(buf)
if err != nil {
log.Fatalf("Rendering failed: %v", err)
logFatal("Rendering failed: %v", err)
}

target := args[1]
if target == "--" {
target = args[2]
}
target := args[len(args)-1]

wd, _ := os.Getwd()
fmt.Printf("Writing generated constants to: %s (pwd: %s)\n", target, wd)
log("Writing generated constants to: %s (pwd: %s)", target, wd)
ioutil.WriteFile(target, buf.Bytes(), 0666)

fmt.Println("Constants generated")
log("Constants file generated")
}
Loading

0 comments on commit 0173f51

Please sign in to comment.