From 4e1bf56efbbc480c60b01874148d069fafb9f9ae Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 15:11:43 -0500 Subject: [PATCH 01/19] update --- .bindown.yaml | 205 +++++++++++++++++++++++++++++++++++++++ bindown.yml | 110 --------------------- script/bindown | 13 ++- script/fmt | 10 ++ script/generate | 4 +- script/generate-readme | 6 +- src/install-go | 5 +- src/lib | 32 +++--- src/lib.pl | 55 ++--------- src/lib_test.pl | 14 --- src/lib_test.sh | 2 +- src/run | 17 +++- src/run_test_long.sh | 43 ++++++++ src/select_go_version.pl | 14 ++- src/semver-select | 21 +--- 15 files changed, 329 insertions(+), 222 deletions(-) create mode 100644 .bindown.yaml delete mode 100644 bindown.yml create mode 100755 script/fmt create mode 100755 src/run_test_long.sh diff --git a/.bindown.yaml b/.bindown.yaml new file mode 100644 index 0000000..5ad1784 --- /dev/null +++ b/.bindown.yaml @@ -0,0 +1,205 @@ +cache: .bindown +systems: + - darwin/amd64 + - darwin/arm64 + - linux/amd64 + - windows/amd64 +dependencies: + action-doc: + template: action-doc#action-doc + vars: + version: 0.4.0 + caddy: + template: caddy + vars: + version: 2.7.3 + octo: + template: origin#octo + vars: + version: 0.23.0 + semver: + url: https://github.com/fsaintjacques/semver-tool/archive/{{.version}}.tar.gz + archive_path: ./semver-tool-{{.version}}/src/semver + vars: + version: 3.1.0 + required_vars: + - version + shellcheck: + template: origin#shellcheck + vars: + version: 0.7.1 + shfmt: + template: origin#shfmt + vars: + version: 3.6.0 + shunit2: + url: https://github.com/kward/shunit2/archive/{{.ref}}.tar.gz + archive_path: ./shunit2-{{.ref}}/shunit2 + vars: + ref: ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d + required_vars: + - ref +templates: + action-doc#action-doc: + url: https://github.com/WillAbides/action-doc/releases/download/v{{.version}}/action-doc_{{.version}}_{{.os}}_{{.arch}}.tar.gz + systems: + - darwin/amd64 + - linux/386 + - linux/amd64 + required_vars: + - version + caddy: + homepage: https://caddyserver.com + description: Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS + url: https://github.com/caddyserver/caddy/releases/download/v{{.version}}/caddy_{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} + archive_path: caddy{{.archivePathSuffix}} + bin: caddy + vars: + archivePathSuffix: "" + urlSuffix: .tar.gz + overrides: + - matcher: + os: + - windows + dependency: + vars: + archivePathSuffix: .exe + urlSuffix: .zip + substitutions: + os: + darwin: mac + systems: + - darwin/amd64 + - darwin/arm64 + - linux/amd64 + - windows/amd64 + required_vars: + - version + origin#octo: + homepage: https://github.com/octo-cli/octo-cli + url: https://github.com/octo-cli/octo-cli/releases/download/v{{.version}}/octo-cli_{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} + archive_path: octo{{.archivePathSuffix}} + bin: octo + vars: + archivePathSuffix: "" + urlSuffix: .tar.gz + overrides: + - matcher: + os: + - windows + dependency: + vars: + archivePathSuffix: .exe + substitutions: + arch: + "386": i386 + amd64: x86_64 + arm64: x86_64 + os: + windows: Windows + substitutions: + arch: + "386": i386 + amd64: x86_64 + arm64: x86_64 + os: + darwin: Darwin + linux: Linux + windows: Windows + systems: + - darwin/amd64 + - darwin/arm64 + - linux/386 + - linux/amd64 + - windows/386 + - windows/amd64 + required_vars: + - version + origin#shellcheck: + homepage: https://www.shellcheck.net + description: ShellCheck, a static analysis tool for shell scripts + url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.{{.os}}.{{.arch}}{{.urlSuffix}} + archive_path: shellcheck-v{{.version}}/shellcheck{{.archivePathSuffix}} + bin: shellcheck + vars: + archivePathSuffix: "" + urlSuffix: .tar.xz + overrides: + - matcher: + os: + - windows + dependency: + url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.zip + archive_path: shellcheck.exe + - matcher: + arch: + - arm64 + os: + - darwin + dependency: + substitutions: + arch: + arm64: x86_64 + substitutions: + arch: + amd64: x86_64 + arm: armv6hf + arm64: aarch64 + systems: + - darwin/amd64 + - darwin/arm64 + - linux/amd64 + - linux/arm + - linux/arm64 + - windows/amd64 + required_vars: + - version + origin#shfmt: + homepage: https://github.com/mvdan/sh + description: A shell parser, formatter, and interpreter with bash support; includes shfmt + url: https://github.com/mvdan/sh/releases/download/v{{.version}}/shfmt_v{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} + archive_path: shfmt_v{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} + bin: shfmt + vars: + archivePathSuffix: "" + urlSuffix: "" + overrides: + - matcher: + os: + - windows + dependency: + vars: + urlSuffix: .exe + systems: + - darwin/amd64 + - darwin/arm64 + - linux/386 + - linux/amd64 + - linux/arm + - linux/arm64 + - windows/386 + - windows/amd64 + required_vars: + - version +template_sources: + action-doc: https://raw.githubusercontent.com/WillAbides/action-doc/main/bindown.yml + origin: https://raw.githubusercontent.com/WillAbides/bindown-templates/master/bindown.yml +url_checksums: + https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_darwin_amd64.tar.gz: 6fcdd45d6a30bf5d17c27b09725fbd4cea5fef96e635abc82c894156207bf9b8 + https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_linux_amd64.tar.gz: 7c09a3b9270b4589e11a4f5248e0eb5eb9f5a0126625b5a0675c36554efb76d2 + https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_linux_amd64.tar.gz: a3da54761ab593ffc5e3dd4ecea8fd736663433b33680547e49c0d5e17585f5d + https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_mac_amd64.tar.gz: 3415ef4a1c63b1cb4101870d428971287ab01869d32c1f194a75b08156ed0955 + https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_mac_arm64.tar.gz: 7d6d796875d27217e22dc18f48ee052cfbb69f6f6f1409d8497426fe2764798c + https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_windows_amd64.zip: 94b3fb0b876f277be380b18980329ff78255f18ca1fdbae7e49d7f1ef48312d2 + https://github.com/fsaintjacques/semver-tool/archive/3.1.0.tar.gz: 7cad0dea3a6249190f98167476f322c61577b3a069d6afd0022bef9f1824f202 + https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.darwin.x86_64.tar.xz: b080c3b659f7286e27004aa33759664d91e15ef2498ac709a452445d47e3ac23 + https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 + https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.zip: 1763f8f4a639d39e341798c7787d360ed79c3d68a1cdbad0549c9c0767a75e98 + https://github.com/kward/shunit2/archive/ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d.tar.gz: d18b23a0db5deed5b0e10a732ac1f94579ac2781ce9408d62f0e847e3fa6910b + https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_darwin_amd64: b8c9c025b498e2816b62f0b717f6032e9ab49e725a45b8205f52f66318f17185 + https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_darwin_arm64: 633f242246ee0a866c5f5df25cbf61b6af0d5e143555aca32950059cf13d91e0 + https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_linux_amd64: 5741a02a641de7e56b8da170e71a97e58050d66a3cf485fb268d6a5a8bb74afb + https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_windows_amd64.exe: 18122d910ba434be366588f37c302c309cde4ca5403f93285254a3cf96839d01 + https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Darwin_x86_64.tar.gz: 1388c1ca5838a453055930035c81b231b829ef3b0511cc7765dffdd73b83d355 + https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Linux_x86_64.tar.gz: 7bad6194d91bd9cd86a348dadafd7725b3bb4010afe36294df0740e8c815947a + https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Windows_x86_64.tar.gz: 5c2a2b706b626b62db1790a7dec324d6fe8ecf72f791fda5ff4bb595f741e5bc diff --git a/bindown.yml b/bindown.yml deleted file mode 100644 index 664c5b8..0000000 --- a/bindown.yml +++ /dev/null @@ -1,110 +0,0 @@ -systems: -- darwin/amd64 -- linux/amd64 -dependencies: - action-doc: - template: action-doc#action-doc - vars: - version: 0.4.0 - octo: - template: origin#octo - vars: - version: 0.23.0 - semver: - url: https://github.com/fsaintjacques/semver-tool/archive/{{.version}}.tar.gz - archive_path: ./semver-tool-{{.version}}/src/semver - vars: - version: 3.1.0 - required_vars: - - version - shellcheck: - template: origin#shellcheck - vars: - version: 0.7.1 - shunit2: - url: https://github.com/kward/shunit2/archive/{{.ref}}.tar.gz - archive_path: ./shunit2-{{.ref}}/shunit2 - vars: - ref: ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d - required_vars: - - ref -templates: - action-doc#action-doc: - url: https://github.com/WillAbides/action-doc/releases/download/v{{.version}}/action-doc_{{.version}}_{{.os}}_{{.arch}}.tar.gz - required_vars: - - version - systems: - - darwin/amd64 - - linux/386 - - linux/amd64 - origin#octo: - url: https://github.com/octo-cli/octo-cli/releases/download/v{{.version}}/octo-cli_{{.version}}_{{.os}}_{{.arch}}.tar.gz - archive_path: octo{{.archivepathsuffix}} - bin: octo - vars: - archivepathsuffix: "" - required_vars: - - version - overrides: - - matcher: - os: - - windows - dependency: - vars: - archivepathsuffix: .exe - - matcher: - arch: - - arm64 - os: - - darwin - dependency: - vars: - arch: amd64 - substitutions: - arch: - "386": i386 - amd64: x86_64 - os: - darwin: Darwin - linux: Linux - windows: Windows - systems: - - darwin/386 - - darwin/amd64 - - darwin/arm64 - - linux/386 - - linux/amd64 - - windows/386 - - windows/amd64 - origin#shellcheck: - url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.{{.os}}.{{.arch}}.tar.xz - archive_path: shellcheck-v{{.version}}/shellcheck - bin: shellcheck - required_vars: - - version - overrides: - - matcher: - os: - - windows - dependency: - url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.zip - archive_path: shellcheck-v{{.version}}.exe - substitutions: - arch: - amd64: x86_64 - systems: - - darwin/amd64 - - linux/amd64 - - windows/amd64 -template_sources: - action-doc: https://raw.githubusercontent.com/WillAbides/action-doc/main/bindown.yml - origin: https://raw.githubusercontent.com/WillAbides/bindown-templates/master/bindown.yml -url_checksums: - https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_darwin_amd64.tar.gz: 6fcdd45d6a30bf5d17c27b09725fbd4cea5fef96e635abc82c894156207bf9b8 - https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_linux_amd64.tar.gz: 7c09a3b9270b4589e11a4f5248e0eb5eb9f5a0126625b5a0675c36554efb76d2 - https://github.com/fsaintjacques/semver-tool/archive/3.1.0.tar.gz: 7cad0dea3a6249190f98167476f322c61577b3a069d6afd0022bef9f1824f202 - https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.darwin.x86_64.tar.xz: b080c3b659f7286e27004aa33759664d91e15ef2498ac709a452445d47e3ac23 - https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 - https://github.com/kward/shunit2/archive/ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d.tar.gz: d18b23a0db5deed5b0e10a732ac1f94579ac2781ce9408d62f0e847e3fa6910b - https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Darwin_x86_64.tar.gz: 1388c1ca5838a453055930035c81b231b829ef3b0511cc7765dffdd73b83d355 - https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Linux_x86_64.tar.gz: 7bad6194d91bd9cd86a348dadafd7725b3bb4010afe36294df0740e8c815947a diff --git a/script/bindown b/script/bindown index 6d225db..c977b0e 100755 --- a/script/bindown +++ b/script/bindown @@ -6,6 +6,17 @@ CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" mkdir -p bin -[ -f bin/bindown ] || sh -c "$(curl -sfL https://github.com/WillAbides/bindown/releases/download/v3.10.1/bootstrap-bindown.sh)" +BINDOWN_VERSION="4.5.0" + +if ! [ -f bin/bindown ]; then + set +e + VERSION_OUTPUT="$(bin/bindown version 2> /dev/null)" + set -e + if ! echo "$VERSION_OUTPUT" || grep -q "$BINDOWN_VERSION"; then + sh -c "$( + curl -sfL https://github.com/WillAbides/bindown/releases/download/"v$BINDOWN_VERSION"/bootstrap-bindown.sh + )" + fi +fi exec bin/bindown "$@" diff --git a/script/fmt b/script/fmt new file mode 100755 index 0000000..4492e02 --- /dev/null +++ b/script/fmt @@ -0,0 +1,10 @@ +#!/bin/sh +#/ script/fmt formats go code and shell scripts. + +set -e + +CDPATH="" cd -- "$(dirname -- "$0")/.." + +script/bindown -q install shfmt + +bin/shfmt -ci -i 2 -ci -sr -w -s ./script ./src diff --git a/script/generate b/script/generate index 235ae57..84c32d1 100755 --- a/script/generate +++ b/script/generate @@ -7,13 +7,13 @@ CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" if [ "$1" = "--check" ]; then [ -z "$(git status --porcelain)" ] || { git status - 1>&2 echo "Running 'script/generate --check' requires a clean git working tree. Please commit or stash changes and try again." + echo 1>&2 "Running 'script/generate --check' requires a clean git working tree. Please commit or stash changes and try again." exit 1 } script/generate [ -z "$(git status --porcelain)" ] || { git status - 1>&2 echo "script/generate resulted in changes. Please commit changes (or 'git reset --hard HEAD' if you aren't ready to commit changes)." + echo 1>&2 "script/generate resulted in changes. Please commit changes (or 'git reset --hard HEAD' if you aren't ready to commit changes)." git diff exit 1 } diff --git a/script/generate-readme b/script/generate-readme index 0981db9..0a5a547 100755 --- a/script/generate-readme +++ b/script/generate-readme @@ -7,13 +7,13 @@ CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" gen_pattern="*" gen_sub="$( - cat < $( script/action-doc \ --skip-action-name \ --skip-action-description \ - --header-prefix='#'\ + --header-prefix='#' \ action.yml ) @@ -21,4 +21,4 @@ EOF )" readme="$(cat README.md)" -echo "${readme//$gen_pattern/$gen_sub}" >README.md +echo "${readme//$gen_pattern/$gen_sub}" > README.md diff --git a/src/install-go b/src/install-go index 6d8330d..8672750 100755 --- a/src/install-go +++ b/src/install-go @@ -2,6 +2,7 @@ # required global vars: # RUNNER_TOOL_CACHE # provided by action +# GITHUB_OUTPUT # provided by action # # optional vars: # INSTALL_GO_FORCE # set to non-empty to force the install @@ -62,8 +63,8 @@ GOPATH GOROOT GOTOOLDIR' -echo "GOROOT=$(go env GOROOT)" >>"$GITHUB_ENV" +echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV" for var in $govars; do - echo "$var=$(go env "$var")" >>"$GITHUB_OUTPUT" + echo "$var=$(go env "$var")" >> "$GITHUB_OUTPUT" done diff --git a/src/lib b/src/lib index 2d381b3..ca7da21 100755 --- a/src/lib +++ b/src/lib @@ -2,22 +2,22 @@ set -e -CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" +CDPATH="" cd -- "$(dirname -- "$0")/.." goos() { case "$RUNNER_OS" in - macOS) - echo "darwin" - ;; - Linux) - echo "linux" - ;; - Windows) - echo "windows" - ;; - *) - uname -s | tr '[:upper:]' '[:lower:]' - ;; + macOS) + echo "darwin" + ;; + Linux) + echo "linux" + ;; + Windows) + echo "windows" + ;; + *) + uname -s | tr '[:upper:]' '[:lower:]' + ;; esac } @@ -90,7 +90,7 @@ install_go() { fi mv "go" "$target_dir" - cd - >/dev/null + cd - > /dev/null } add_to_system_path() { @@ -103,7 +103,7 @@ add_to_system_path() { add_to_github_path() { element="$1" - echo "$element" >>"$GITHUB_PATH" + echo "$element" >> "$GITHUB_PATH" } exe_name() { @@ -159,7 +159,7 @@ select_remote_version() { local constraint="$1" local versions="$2" # shellcheck disable=SC2001 - versions="$(echo "$versions"| sed 's/^go//g')" + versions="$(echo "$versions" | sed 's/^go//g')" if got="$(select_go_version "$constraint" "$versions")"; then echo "$got" && return diff --git a/src/lib.pl b/src/lib.pl index c7b7800..2fc1c6d 100644 --- a/src/lib.pl +++ b/src/lib.pl @@ -2,24 +2,17 @@ use strict; use warnings; -my $exp = qr/^(x|\d+)(\.(x|\d+)(\.(x|\d+))?)?(\w+)?$/; +my $exp = qr/^(?:go)?(?x|\d+)(?:\.(?x|\d+)(?:\.(?x|\d+))?)?(?\w+)?$/; sub parse_go_version { my $ver = shift; return unless $ver =~ m/$exp/; - my $major = $1; - my $minor = $3; - my $patch = $5; - my $pre_release = $6; - $major = 0 unless $major; - $minor = 0 unless $minor; - $patch = 0 unless $patch; - $pre_release = "" unless $pre_release; my $result = { - major => $major, - minor => $minor, - patch => $patch, - pre_release => $pre_release + original => $&, + major => $+{major} || 0, + minor => $+{minor} || 0, + patch => $+{patch} || 0, + pre_release => $+{pre_release} || "" }; return unless is_valid_go_version_pattern($result); return $result; @@ -45,7 +38,7 @@ sub go_version_greater { # false if a is a pre-release and b isn't return 0 if $$a{"pre_release"} ne "" && $$b{"pre_release"} eq ""; - # true if a's preview is asciibetical ahead of b's + # true if a's pre-release is asciibetical ahead of b's return 1 if $$a{"pre_release"} gt $$b{"pre_release"}; return 0; } @@ -67,34 +60,6 @@ () return 1; } -sub go_version_string { - my $v = shift; - my $major_v = $$v{"major"}; - my $minor_v = $$v{"minor"}; - my $patch_v = $$v{"patch"}; - - # For 1.21 and above with no pre-release, always return major.minor.patch - if ( $major_v > 1 || ( $major_v == 1 && $minor_v >= 21 ) ) { - if ( $$v{"pre_release"} eq "" ) { - return "$major_v.$minor_v.$patch_v"; - } - } - - $patch_v = "" if $patch_v == 0; - $minor_v = "" if $minor_v == 0 && $patch_v eq ""; - my $st = "$$v{'major'}"; - if ( $minor_v ne "" ) { - $st = "$st.$minor_v"; - } - if ( $patch_v ne "" ) { - $st = "$st.$patch_v"; - } - if ( $$v{"pre_release"} ) { - $st = "$st$$v{'pre_release'}"; - } - return $st; -} - sub go_version_pattern_match { my $pattern = shift; my $ver = shift; @@ -106,10 +71,4 @@ sub go_version_pattern_match { return 1; } -sub exit_err() { - my $msg = shift; - print "$msg\n"; - exit 1; -} - 1; diff --git a/src/lib_test.pl b/src/lib_test.pl index cf3625e..8fe4bfb 100755 --- a/src/lib_test.pl +++ b/src/lib_test.pl @@ -36,19 +36,5 @@ sub parse_and_match { ok( parse_and_match( "1.2.x", "1.2.3" ) == 1 ); ok( parse_and_match( "1.2.x", "1.2.3beta1" ) == 0 ); -sub test_go_version_string { - my $in = shift; - my $p = parse_go_version($in); - ok( go_version_string($p) eq $in, "test_go_version_string $in" ); -} - -test_go_version_string "1.2.3"; -test_go_version_string "1"; -test_go_version_string "0"; -test_go_version_string "1.0.1"; -test_go_version_string "1.1"; -test_go_version_string "1.1beta1"; -test_go_version_string "1beta1"; - done_testing(); diff --git a/src/lib_test.sh b/src/lib_test.sh index 56f9c2f..7bdb844 100755 --- a/src/lib_test.sh +++ b/src/lib_test.sh @@ -90,7 +90,7 @@ test_select_go_version() { do_test_select_go_version "" "1.2.3" do_test_select_go_version "1.21.0" "1.21.x" "1.21.0" do_test_select_go_version "1.21.0" "1.21" "1.21.0" - do_test_select_go_version "1.20" "1.20.x" "1.20.0" + do_test_select_go_version "go1.20" "1.20.x" "go1.20" } test_select_remote_version() { diff --git a/src/run b/src/run index 4984e29..0ef7579 100755 --- a/src/run +++ b/src/run @@ -1,19 +1,28 @@ #!/bin/bash # required global vars: -# RUNNER_TOOL_CACHE # provided by action # GO_VERSION= version constraint +# RUNNER_TOOL_CACHE # provided by action +# RUNNER_WORKSPACE # provided by action +# GITHUB_ACTION_PATH # provided by action +# GITHUB_OUTPUT # provided by action # # optional vars: -# INSTALL_GO_FORCE # set to non-empty to force the install +# INSTALL_GO_FORCE # set to non-empty to force the install +# IGNORE_LOCAL_GO # set to non-empty to ignore local go installations +# +# for testing: +# VERSIONS_URL # override the url used to get the list of known versions set -e [ -n "$DEBUG" ] && set -x -CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" +CDPATH="" cd -- "$(dirname -- "$0")/.." . src/lib +VERSIONS_URL="${VERSIONS_URL:-https://raw.githubusercontent.com/WillAbides/goreleases/main/versions.txt}" + debug_out starting run export INSTALL_GO_TIP @@ -49,7 +58,7 @@ if [ -z "$lv" ]; then fi if [ -z "$lv" ]; then - known_versions="$(curl --retry 4 -s --fail 'https://raw.githubusercontent.com/WillAbides/goreleases/main/versions.txt')" + known_versions="$(curl --retry 4 -s --fail "$VERSIONS_URL")" lv="$(select_remote_version "$constraint" "$known_versions")" target_dir="$install_parent/$lv/x64" fi diff --git a/src/run_test_long.sh b/src/run_test_long.sh new file mode 100755 index 0000000..b06d36c --- /dev/null +++ b/src/run_test_long.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +CDPATH="" cd -- "$(dirname -- "$0")/.." + +. src/lib + +# Nothing special about this one. It just happens to be HEAD of main when writing this. +# Most recent version is go1.21rc4 +STABLE_VERSIONS_URL="https://raw.githubusercontent.com/WillAbides/goreleases/077db58ac86a8a2fb63c90817090e132eded0f3d/versions.txt" + +do_test_run() { + CONSTRAINT="$1" + WANT_VERSION="$2" + tmp_dir="$SHUNIT_TMPDIR"/test_run + rm -rf -- "$tmp_dir" + mkdir -p -- "$tmp_dir" + export RUNNER_TEMP="$tmp_dir/runner_temp" + export RUNNER_TOOL_CACHE="$tmp_dir/runner_tool_cache" + export RUNNER_WORKSPACE="$tmp_dir/runner_workspace" + export GITHUB_OUTPUT="$tmp_dir/github_output" + export GITHUB_ACTION_PATH="$PWD" + export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" + GO_VERSION="$CONSTRAINT" ./src/run + WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" + cat "$GITHUB_OUTPUT" + assertContains "$(grep '^GOROOT=' "$GITHUB_OUTPUT")" "$WANT_GOROOT" +} + +test_run_1_15_x() { + do_test_run 1.15.x 1.15.15 +} + +test_run_star() { + do_test_run '*' 1.20.7 +} + +test_run_1_16rc1() { + do_test_run 1.16rc1 1.16rc1 +} + +. ./external/shunit2 diff --git a/src/select_go_version.pl b/src/select_go_version.pl index 246fe1d..3c2d449 100755 --- a/src/select_go_version.pl +++ b/src/select_go_version.pl @@ -10,9 +10,16 @@ my $usage = "usage: echo | select_go_version.pl pattern"; my $pat_arg = shift; -exit_err($usage) unless $pat_arg; +unless ($pat_arg) { + print "$usage\n"; + exit 1; +} + my $pat = parse_go_version($pat_arg); -exit_err("invalid pattern: $pat_arg") unless $pat; +unless ($pat) { + print "invalid pattern: $pat_arg\n"; + exit 1; +} my $max; @@ -26,4 +33,5 @@ } exit 1 unless $max; -print go_version_string($max) . "\n"; + +print $$max{"original"} . "\n"; diff --git a/src/semver-select b/src/semver-select index 1109394..f1bb15c 100755 --- a/src/semver-select +++ b/src/semver-select @@ -3,24 +3,9 @@ set -e [ -n "$DEBUG" ] && set -x -CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" - -goos() { - case "$RUNNER_OS" in - macOS) - echo "darwin" - ;; - Linux) - echo "linux" - ;; - Windows) - echo "windows" - ;; - *) - uname -s | tr '[:upper:]' '[:lower:]' - ;; - esac -} +CDPATH="" cd -- "$(dirname -- "$0")/.." + +. src/lib target_version="0.1.0" bin_path="./bin/semver-select" From b151b0d1cda17a847717adb24867b9ce01eb6c87 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 15:19:47 -0500 Subject: [PATCH 02/19] update script/bindown from goproject-tmpl --- script/bindown | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/script/bindown b/script/bindown index c977b0e..354ef85 100755 --- a/script/bindown +++ b/script/bindown @@ -1,22 +1,14 @@ #!/bin/sh +#/ script/bindown runs bindown with the given arguments set -e -CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" +CDPATH="" cd -- "$(dirname -- "$0")/.." mkdir -p bin -BINDOWN_VERSION="4.5.0" - -if ! [ -f bin/bindown ]; then - set +e - VERSION_OUTPUT="$(bin/bindown version 2> /dev/null)" - set -e - if ! echo "$VERSION_OUTPUT" || grep -q "$BINDOWN_VERSION"; then - sh -c "$( - curl -sfL https://github.com/WillAbides/bindown/releases/download/"v$BINDOWN_VERSION"/bootstrap-bindown.sh - )" - fi -fi +[ -f bin/bindown ] || sh -c "$( + curl -sfL https://github.com/WillAbides/bindown/releases/download/v4.5.0/bootstrap-bindown.sh +)" exec bin/bindown "$@" From ebba213f1bf96c4b8d97132f8dc305fe372ecec1 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 15:59:12 -0500 Subject: [PATCH 03/19] SKIP_MATCHER --- src/run | 3 ++- src/run_test_long.sh | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/run b/src/run index 0ef7579..02347ba 100755 --- a/src/run +++ b/src/run @@ -13,6 +13,7 @@ # # for testing: # VERSIONS_URL # override the url used to get the list of known versions +# SKIP_MATCHER # don't issue the add-matcher command because it breaks when running tests on windows set -e [ -n "$DEBUG" ] && set -x @@ -68,6 +69,6 @@ if [ -z "$lv" ]; then exit 1 fi -echo "::add-matcher::$GITHUB_ACTION_PATH/matchers.json" +[ -n "$SKIP_MATCHER" ] || echo "::add-matcher::$GITHUB_ACTION_PATH/matchers.json" src/install-go "$lv" "$target_dir" "$install_parent/tip/x64" diff --git a/src/run_test_long.sh b/src/run_test_long.sh index b06d36c..86e2a9f 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -22,6 +22,7 @@ do_test_run() { export GITHUB_OUTPUT="$tmp_dir/github_output" export GITHUB_ACTION_PATH="$PWD" export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" + export SKIP_MATCHER=1 GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" cat "$GITHUB_OUTPUT" From 9157410ab4d39de3227362112311c379cdd134c4 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:13:11 -0500 Subject: [PATCH 04/19] IGNORE_LOCAL_GO --- src/run_test_long.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 86e2a9f..78ffe68 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -23,6 +23,7 @@ do_test_run() { export GITHUB_ACTION_PATH="$PWD" export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" export SKIP_MATCHER=1 + export IGNORE_LOCAL_GO=1 GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" cat "$GITHUB_OUTPUT" From 31c17e8b8aa4e799f37e0a874763bd3f8562311a Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:18:05 -0500 Subject: [PATCH 05/19] unset GOROOT --- src/run_test_long.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 78ffe68..21f584e 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -24,6 +24,7 @@ do_test_run() { export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" export SKIP_MATCHER=1 export IGNORE_LOCAL_GO=1 + unset GOROOT GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" cat "$GITHUB_OUTPUT" From 5744712c5d0aface9f77408d18d3c2ec50103083 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:21:37 -0500 Subject: [PATCH 06/19] export GOROOT="" --- src/run_test_long.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 21f584e..765824a 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -24,7 +24,7 @@ do_test_run() { export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" export SKIP_MATCHER=1 export IGNORE_LOCAL_GO=1 - unset GOROOT + export GOROOT="" GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" cat "$GITHUB_OUTPUT" From de842164daf29bbadf93f14857ca9e6dd51de355 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:27:47 -0500 Subject: [PATCH 07/19] env --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff6a2b0..101eed3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: run: shell: bash steps: + - run: env - uses: actions/checkout@v3.3.0 - run: script/bootstrap - run: script/test From 35f8903396ee0c0f3d54c79de382a781d994bdce Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:32:45 -0500 Subject: [PATCH 08/19] go env --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 101eed3..84d31ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,7 @@ jobs: shell: bash steps: - run: env + - run: go env - uses: actions/checkout@v3.3.0 - run: script/bootstrap - run: script/test From 8ab4fb7ac4218f77f56fb908bd74f93a95679952 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Sun, 6 Aug 2023 16:48:43 -0500 Subject: [PATCH 09/19] system path --- src/install-go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/install-go b/src/install-go index 8672750..3f0f26c 100755 --- a/src/install-go +++ b/src/install-go @@ -37,6 +37,7 @@ GITHUB_PATH="${GITHUB_PATH:-/dev/null}" add_to_github_path "$target_dir/bin" PATH="$(add_to_system_path "$target_dir/bin")" +echo PATH="$PATH" gopath=$(go env GOPATH) mkdir -p "$gopath/bin" From be9fd182c2b7dd3d43bd75d28a3a2ab29cf55dd5 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Thu, 10 Aug 2023 11:42:26 -0500 Subject: [PATCH 10/19] rm empty bindown.yml --- bindown.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bindown.yml diff --git a/bindown.yml b/bindown.yml deleted file mode 100644 index e69de29..0000000 From 4c107da6334f6bb8e9baa75142b896940436fcd7 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Thu, 10 Aug 2023 13:29:03 -0500 Subject: [PATCH 11/19] revert bindown --- .bindown.yaml | 205 -------------------------------------------------- 1 file changed, 205 deletions(-) delete mode 100644 .bindown.yaml diff --git a/.bindown.yaml b/.bindown.yaml deleted file mode 100644 index 5ad1784..0000000 --- a/.bindown.yaml +++ /dev/null @@ -1,205 +0,0 @@ -cache: .bindown -systems: - - darwin/amd64 - - darwin/arm64 - - linux/amd64 - - windows/amd64 -dependencies: - action-doc: - template: action-doc#action-doc - vars: - version: 0.4.0 - caddy: - template: caddy - vars: - version: 2.7.3 - octo: - template: origin#octo - vars: - version: 0.23.0 - semver: - url: https://github.com/fsaintjacques/semver-tool/archive/{{.version}}.tar.gz - archive_path: ./semver-tool-{{.version}}/src/semver - vars: - version: 3.1.0 - required_vars: - - version - shellcheck: - template: origin#shellcheck - vars: - version: 0.7.1 - shfmt: - template: origin#shfmt - vars: - version: 3.6.0 - shunit2: - url: https://github.com/kward/shunit2/archive/{{.ref}}.tar.gz - archive_path: ./shunit2-{{.ref}}/shunit2 - vars: - ref: ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d - required_vars: - - ref -templates: - action-doc#action-doc: - url: https://github.com/WillAbides/action-doc/releases/download/v{{.version}}/action-doc_{{.version}}_{{.os}}_{{.arch}}.tar.gz - systems: - - darwin/amd64 - - linux/386 - - linux/amd64 - required_vars: - - version - caddy: - homepage: https://caddyserver.com - description: Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS - url: https://github.com/caddyserver/caddy/releases/download/v{{.version}}/caddy_{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} - archive_path: caddy{{.archivePathSuffix}} - bin: caddy - vars: - archivePathSuffix: "" - urlSuffix: .tar.gz - overrides: - - matcher: - os: - - windows - dependency: - vars: - archivePathSuffix: .exe - urlSuffix: .zip - substitutions: - os: - darwin: mac - systems: - - darwin/amd64 - - darwin/arm64 - - linux/amd64 - - windows/amd64 - required_vars: - - version - origin#octo: - homepage: https://github.com/octo-cli/octo-cli - url: https://github.com/octo-cli/octo-cli/releases/download/v{{.version}}/octo-cli_{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} - archive_path: octo{{.archivePathSuffix}} - bin: octo - vars: - archivePathSuffix: "" - urlSuffix: .tar.gz - overrides: - - matcher: - os: - - windows - dependency: - vars: - archivePathSuffix: .exe - substitutions: - arch: - "386": i386 - amd64: x86_64 - arm64: x86_64 - os: - windows: Windows - substitutions: - arch: - "386": i386 - amd64: x86_64 - arm64: x86_64 - os: - darwin: Darwin - linux: Linux - windows: Windows - systems: - - darwin/amd64 - - darwin/arm64 - - linux/386 - - linux/amd64 - - windows/386 - - windows/amd64 - required_vars: - - version - origin#shellcheck: - homepage: https://www.shellcheck.net - description: ShellCheck, a static analysis tool for shell scripts - url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.{{.os}}.{{.arch}}{{.urlSuffix}} - archive_path: shellcheck-v{{.version}}/shellcheck{{.archivePathSuffix}} - bin: shellcheck - vars: - archivePathSuffix: "" - urlSuffix: .tar.xz - overrides: - - matcher: - os: - - windows - dependency: - url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.zip - archive_path: shellcheck.exe - - matcher: - arch: - - arm64 - os: - - darwin - dependency: - substitutions: - arch: - arm64: x86_64 - substitutions: - arch: - amd64: x86_64 - arm: armv6hf - arm64: aarch64 - systems: - - darwin/amd64 - - darwin/arm64 - - linux/amd64 - - linux/arm - - linux/arm64 - - windows/amd64 - required_vars: - - version - origin#shfmt: - homepage: https://github.com/mvdan/sh - description: A shell parser, formatter, and interpreter with bash support; includes shfmt - url: https://github.com/mvdan/sh/releases/download/v{{.version}}/shfmt_v{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} - archive_path: shfmt_v{{.version}}_{{.os}}_{{.arch}}{{.urlSuffix}} - bin: shfmt - vars: - archivePathSuffix: "" - urlSuffix: "" - overrides: - - matcher: - os: - - windows - dependency: - vars: - urlSuffix: .exe - systems: - - darwin/amd64 - - darwin/arm64 - - linux/386 - - linux/amd64 - - linux/arm - - linux/arm64 - - windows/386 - - windows/amd64 - required_vars: - - version -template_sources: - action-doc: https://raw.githubusercontent.com/WillAbides/action-doc/main/bindown.yml - origin: https://raw.githubusercontent.com/WillAbides/bindown-templates/master/bindown.yml -url_checksums: - https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_darwin_amd64.tar.gz: 6fcdd45d6a30bf5d17c27b09725fbd4cea5fef96e635abc82c894156207bf9b8 - https://github.com/WillAbides/action-doc/releases/download/v0.4.0/action-doc_0.4.0_linux_amd64.tar.gz: 7c09a3b9270b4589e11a4f5248e0eb5eb9f5a0126625b5a0675c36554efb76d2 - https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_linux_amd64.tar.gz: a3da54761ab593ffc5e3dd4ecea8fd736663433b33680547e49c0d5e17585f5d - https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_mac_amd64.tar.gz: 3415ef4a1c63b1cb4101870d428971287ab01869d32c1f194a75b08156ed0955 - https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_mac_arm64.tar.gz: 7d6d796875d27217e22dc18f48ee052cfbb69f6f6f1409d8497426fe2764798c - https://github.com/caddyserver/caddy/releases/download/v2.7.3/caddy_2.7.3_windows_amd64.zip: 94b3fb0b876f277be380b18980329ff78255f18ca1fdbae7e49d7f1ef48312d2 - https://github.com/fsaintjacques/semver-tool/archive/3.1.0.tar.gz: 7cad0dea3a6249190f98167476f322c61577b3a069d6afd0022bef9f1824f202 - https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.darwin.x86_64.tar.xz: b080c3b659f7286e27004aa33759664d91e15ef2498ac709a452445d47e3ac23 - https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 - https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.zip: 1763f8f4a639d39e341798c7787d360ed79c3d68a1cdbad0549c9c0767a75e98 - https://github.com/kward/shunit2/archive/ebc4baa08f045b7ef0f45c4b7d6f34f08d732f3d.tar.gz: d18b23a0db5deed5b0e10a732ac1f94579ac2781ce9408d62f0e847e3fa6910b - https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_darwin_amd64: b8c9c025b498e2816b62f0b717f6032e9ab49e725a45b8205f52f66318f17185 - https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_darwin_arm64: 633f242246ee0a866c5f5df25cbf61b6af0d5e143555aca32950059cf13d91e0 - https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_linux_amd64: 5741a02a641de7e56b8da170e71a97e58050d66a3cf485fb268d6a5a8bb74afb - https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_windows_amd64.exe: 18122d910ba434be366588f37c302c309cde4ca5403f93285254a3cf96839d01 - https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Darwin_x86_64.tar.gz: 1388c1ca5838a453055930035c81b231b829ef3b0511cc7765dffdd73b83d355 - https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Linux_x86_64.tar.gz: 7bad6194d91bd9cd86a348dadafd7725b3bb4010afe36294df0740e8c815947a - https://github.com/octo-cli/octo-cli/releases/download/v0.23.0/octo-cli_0.23.0_Windows_x86_64.tar.gz: 5c2a2b706b626b62db1790a7dec324d6fe8ecf72f791fda5ff4bb595f741e5bc From b5488b37471c45928275a64e20e2c7c635528701 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Thu, 10 Aug 2023 13:37:19 -0500 Subject: [PATCH 12/19] debug GITHUB_OUTPUT --- src/run_test_long.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 765824a..d81b75d 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -27,7 +27,9 @@ do_test_run() { export GOROOT="" GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" + echo "start GITHUB_OUTPUT" cat "$GITHUB_OUTPUT" + echo "end GITHUB_OUTPUT" assertContains "$(grep '^GOROOT=' "$GITHUB_OUTPUT")" "$WANT_GOROOT" } From abccc0444fce1422e8a1e7b36dc7843756aed912 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 09:23:41 -0500 Subject: [PATCH 13/19] output go env --- src/run_test_long.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index d81b75d..687f65f 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -25,6 +25,9 @@ do_test_run() { export SKIP_MATCHER=1 export IGNORE_LOCAL_GO=1 export GOROOT="" + echo "****** start go env" + go env + echo "****** end go env" GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" echo "start GITHUB_OUTPUT" From b5ac2893af20788e0c8632110d43681e1d305cda Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 09:44:54 -0500 Subject: [PATCH 14/19] go_exec --- .github/workflows/ci.yml | 3 ++- .github/workflows/integration.yml | 3 ++- src/install-go | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fe6085..b940bd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,10 @@ name: ci on: push: + branches: [ main ] workflow_dispatch: pull_request: - types: [opened, synchronize, reopened] + types: [ opened, synchronize, reopened ] jobs: cibuild: name: cibuild diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 26c9baf..9e4d050 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,9 +1,10 @@ name: integration on: push: + branches: [ main ] workflow_dispatch: pull_request: - types: [opened, synchronize, reopened] + types: [ opened, synchronize, reopened ] jobs: install_go_tip: name: install tip diff --git a/src/install-go b/src/install-go index 4db82cc..b3a1154 100755 --- a/src/install-go +++ b/src/install-go @@ -39,7 +39,9 @@ add_to_github_path "$target_dir/bin" PATH="$(add_to_system_path "$target_dir/bin")" echo PATH="$PATH" -gopath=$(go env GOPATH) +go_exec="$target_dir/bin/$(exe_name go)" + +gopath=$("$go_exec" env GOPATH) mkdir -p "$gopath/bin" add_to_github_path "$gopath/bin" @@ -48,7 +50,7 @@ PATH="$(add_to_system_path "$gopath/bin")" unset GOROOT if [ -n "$INSTALL_GO_TIP" ]; then - GO111MODULE=off go get golang.org/dl/gotip + GO111MODULE=off "$go_exec" get golang.org/dl/gotip "$gopath/bin/$(exe_name gotip)" download rm -rf "$tip_target_dir" mkdir -p "$(dirname "$tip_target_dir")" @@ -56,6 +58,7 @@ if [ -n "$INSTALL_GO_TIP" ]; then add_to_github_path "$tip_target_dir/bin" PATH="$(add_to_system_path "$tip_target_dir/bin")" + go_exec="$tip_target_dir/bin/$(exe_name go)" fi govars='GOCACHE @@ -64,8 +67,12 @@ GOPATH GOROOT GOTOOLDIR' -echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV" +echo target_dir +echo "$target_dir" +echo which go +which go +echo "GOROOT=$("$go_exec" env GOROOT)" >> "$GITHUB_ENV" for var in $govars; do - echo "$var=$(go env "$var")" >> "$GITHUB_OUTPUT" + echo "$var=$("$go_exec" env "$var")" >> "$GITHUB_OUTPUT" done From 709c4fef82d708961703c1306b6ff6efa4201e26 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 10:02:43 -0500 Subject: [PATCH 15/19] easy on the windows --- src/run_test_long.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 687f65f..3d0c872 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -4,7 +4,9 @@ set -e CDPATH="" cd -- "$(dirname -- "$0")/.." -. src/lib +setUp() { + . src/lib +} # Nothing special about this one. It just happens to be HEAD of main when writing this. # Most recent version is go1.21rc4 @@ -30,6 +32,11 @@ do_test_run() { echo "****** end go env" GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" + if [ "$(goos)" = "windows" ]; then + # Windows is trickier because of how it translates paths. + # Just check that is has the right suffix. + WANT_GOROOT="setup-go-faster\\go\\$WANT_VERSION\\x64" + fi echo "start GITHUB_OUTPUT" cat "$GITHUB_OUTPUT" echo "end GITHUB_OUTPUT" From f98877aa21c704681bce1a5cfaae21f490456873 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 10:07:15 -0500 Subject: [PATCH 16/19] revert install-go --- src/install-go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/install-go b/src/install-go index b3a1154..4db82cc 100755 --- a/src/install-go +++ b/src/install-go @@ -39,9 +39,7 @@ add_to_github_path "$target_dir/bin" PATH="$(add_to_system_path "$target_dir/bin")" echo PATH="$PATH" -go_exec="$target_dir/bin/$(exe_name go)" - -gopath=$("$go_exec" env GOPATH) +gopath=$(go env GOPATH) mkdir -p "$gopath/bin" add_to_github_path "$gopath/bin" @@ -50,7 +48,7 @@ PATH="$(add_to_system_path "$gopath/bin")" unset GOROOT if [ -n "$INSTALL_GO_TIP" ]; then - GO111MODULE=off "$go_exec" get golang.org/dl/gotip + GO111MODULE=off go get golang.org/dl/gotip "$gopath/bin/$(exe_name gotip)" download rm -rf "$tip_target_dir" mkdir -p "$(dirname "$tip_target_dir")" @@ -58,7 +56,6 @@ if [ -n "$INSTALL_GO_TIP" ]; then add_to_github_path "$tip_target_dir/bin" PATH="$(add_to_system_path "$tip_target_dir/bin")" - go_exec="$tip_target_dir/bin/$(exe_name go)" fi govars='GOCACHE @@ -67,12 +64,8 @@ GOPATH GOROOT GOTOOLDIR' -echo target_dir -echo "$target_dir" -echo which go -which go -echo "GOROOT=$("$go_exec" env GOROOT)" >> "$GITHUB_ENV" +echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV" for var in $govars; do - echo "$var=$("$go_exec" env "$var")" >> "$GITHUB_OUTPUT" + echo "$var=$(go env "$var")" >> "$GITHUB_OUTPUT" done From f19abb50172b108ffa3ff7f589ce250424d1fa8e Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 10:15:17 -0500 Subject: [PATCH 17/19] revert revert --- src/install-go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/install-go b/src/install-go index 4db82cc..7e6db22 100755 --- a/src/install-go +++ b/src/install-go @@ -37,9 +37,10 @@ GITHUB_PATH="${GITHUB_PATH:-/dev/null}" add_to_github_path "$target_dir/bin" PATH="$(add_to_system_path "$target_dir/bin")" -echo PATH="$PATH" -gopath=$(go env GOPATH) +go_exec="$target_dir/bin/$(exe_name go)" + +gopath=$("$go_exec" env GOPATH) mkdir -p "$gopath/bin" add_to_github_path "$gopath/bin" @@ -48,7 +49,7 @@ PATH="$(add_to_system_path "$gopath/bin")" unset GOROOT if [ -n "$INSTALL_GO_TIP" ]; then - GO111MODULE=off go get golang.org/dl/gotip + GO111MODULE=off "$go_exec" get golang.org/dl/gotip "$gopath/bin/$(exe_name gotip)" download rm -rf "$tip_target_dir" mkdir -p "$(dirname "$tip_target_dir")" @@ -56,6 +57,7 @@ if [ -n "$INSTALL_GO_TIP" ]; then add_to_github_path "$tip_target_dir/bin" PATH="$(add_to_system_path "$tip_target_dir/bin")" + go_exec="$tip_target_dir/bin/$(exe_name go)" fi govars='GOCACHE @@ -64,8 +66,8 @@ GOPATH GOROOT GOTOOLDIR' -echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV" +echo "GOROOT=$("$go_exec" env GOROOT)" >> "$GITHUB_ENV" for var in $govars; do - echo "$var=$(go env "$var")" >> "$GITHUB_OUTPUT" + echo "$var=$("$go_exec" env "$var")" >> "$GITHUB_OUTPUT" done From 8c702f426527bf4391ef74315ad5869005b9c708 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 10:19:13 -0500 Subject: [PATCH 18/19] remove test debug outputs --- src/run_test_long.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 3d0c872..473c415 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -27,9 +27,6 @@ do_test_run() { export SKIP_MATCHER=1 export IGNORE_LOCAL_GO=1 export GOROOT="" - echo "****** start go env" - go env - echo "****** end go env" GO_VERSION="$CONSTRAINT" ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" if [ "$(goos)" = "windows" ]; then @@ -37,9 +34,6 @@ do_test_run() { # Just check that is has the right suffix. WANT_GOROOT="setup-go-faster\\go\\$WANT_VERSION\\x64" fi - echo "start GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" - echo "end GITHUB_OUTPUT" assertContains "$(grep '^GOROOT=' "$GITHUB_OUTPUT")" "$WANT_GOROOT" } From 184ba11be290875daf52d8fcf24d9bee5e3bfce9 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 11 Aug 2023 12:44:39 -0500 Subject: [PATCH 19/19] fix rc in go.mod --- src/lib | 6 ++-- src/lib_test.sh | 68 ++++++++++++++++++++++---------------------- src/run | 8 +++--- src/run_test_long.sh | 36 ++++++++++++++++++----- src/semver-select | 2 +- 5 files changed, 70 insertions(+), 50 deletions(-) diff --git a/src/lib b/src/lib index d0833ee..f9435d0 100755 --- a/src/lib +++ b/src/lib @@ -70,7 +70,7 @@ download_go_url() { } install_go() { - local go_version="$1" + local go_version="${1#go}" local target_dir="$2" debug_out "installing go $go_version to $target_dir" rm -rf "$target_dir" @@ -160,8 +160,6 @@ select_local_version() { select_remote_version() { local constraint="$1" local versions="$2" - # shellcheck disable=SC2001 - versions="$(echo "$versions" | sed 's/^go//g')" if got="$(select_go_version "$constraint" "$versions")"; then echo "$got" && return @@ -172,7 +170,7 @@ select_remote_version() { return fi - echo "$versions" | ./src/"semver-select" --go -c "$constraint" -n 1 -i - + echo "$versions" | ./src/"semver-select" --orig --go -c "$constraint" -n 1 -i - } # uses semver-select to convert a go version to semver diff --git a/src/lib_test.sh b/src/lib_test.sh index 79440cf..da03300 100755 --- a/src/lib_test.sh +++ b/src/lib_test.sh @@ -97,43 +97,43 @@ test_select_go_version() { } test_select_remote_version() { - versions='1.15.7 -1.15.6 -1.14.3 -1.15.6 -1.15.5 -1.15.4 -1.15.3 -1.15.2 -1.15.1 -1.15 -1.14.3 -1.14.2 -1.14.1 -1.14 -1.13.3 -1.13.2 -1.13.1 -1.13 -1.3.3 -1.3.2 -1.3.1 -1.3 -1.2.2 -1 -1.16beta1 -1.16rc1' - - tests='*;1.15.7 + versions='go1.15.7 +go1.15.6 +go1.14.3 +go1.15.6 +go1.15.5 +go1.15.4 +go1.15.3 +go1.15.2 +go1.15.1 +go1.15 +go1.14.3 +go1.14.2 +go1.14.1 +go1.14 +go1.13.3 +go1.13.2 +go1.13.1 +go1.13 +go1.3.3 +go1.3.2 +go1.3.1 +go1.3 +go1.2.2 +go1 +go1.16beta1 +go1.16rc1' + + tests='*;go1.15.7 1.17.x; 1.16.x; -1.15;1.15 -1.15.x;1.15.7 -^1;1.15.7 +1.15;go1.15 +1.15.x;go1.15.7 +^1;go1.15.7 ^1.15.999; -1.13.x;1.13.3 -1.16beta1;1.16beta1 -x;1.15.7' +1.13.x;go1.13.3 +1.16beta1;go1.16beta1 +x;go1.15.7' for td in $tests; do input="$(echo "$td" | cut -d ';' -f1)" diff --git a/src/run b/src/run index cb95589..391a60e 100755 --- a/src/run +++ b/src/run @@ -59,25 +59,25 @@ mkdir -p "$go_tool_cache" if [ -z "$IGNORE_LOCAL_GO" ]; then lv="$(select_local_version "$constraint" "$install_parent")" - target_dir="$install_parent/$lv/x64" + target_dir="$install_parent/${lv#go}/x64" fi if [ -z "$IGNORE_LOCAL_GO" ] && [ -z "$lv" ]; then lv="$(select_local_version "$constraint" "$go_tool_cache")" - target_dir="$go_tool_cache/$lv/x64" + target_dir="$go_tool_cache/${lv#go}/x64" fi if [ -z "$lv" ]; then if is_precise_version "$constraint"; then lv="$constraint" - target_dir="$install_parent/$lv/x64" + target_dir="$install_parent/${lv#go}/x64" fi fi if [ -z "$lv" ]; then known_versions="$(curl --retry 4 -s --fail "$VERSIONS_URL")" lv="$(select_remote_version "$constraint" "$known_versions")" - target_dir="$install_parent/$lv/x64" + target_dir="$install_parent/${lv#go}/x64" fi if [ -z "$lv" ]; then diff --git a/src/run_test_long.sh b/src/run_test_long.sh index 473c415..5c7a0c3 100755 --- a/src/run_test_long.sh +++ b/src/run_test_long.sh @@ -13,8 +13,6 @@ setUp() { STABLE_VERSIONS_URL="https://raw.githubusercontent.com/WillAbides/goreleases/077db58ac86a8a2fb63c90817090e132eded0f3d/versions.txt" do_test_run() { - CONSTRAINT="$1" - WANT_VERSION="$2" tmp_dir="$SHUNIT_TMPDIR"/test_run rm -rf -- "$tmp_dir" mkdir -p -- "$tmp_dir" @@ -23,11 +21,11 @@ do_test_run() { export RUNNER_WORKSPACE="$tmp_dir/runner_workspace" export GITHUB_OUTPUT="$tmp_dir/github_output" export GITHUB_ACTION_PATH="$PWD" - export VERSIONS_URL="${VERSIONS_URL:-$STABLE_VERSIONS_URL}" + export VERSIONS_URL="$STABLE_VERSIONS_URL" export SKIP_MATCHER=1 export IGNORE_LOCAL_GO=1 export GOROOT="" - GO_VERSION="$CONSTRAINT" ./src/run + ./src/run WANT_GOROOT="$RUNNER_WORKSPACE/setup-go-faster/go/$WANT_VERSION/x64" if [ "$(goos)" = "windows" ]; then # Windows is trickier because of how it translates paths. @@ -38,15 +36,39 @@ do_test_run() { } test_run_1_15_x() { - do_test_run 1.15.x 1.15.15 + GO_VERSION="1.15.x" \ + WANT_VERSION="1.15.15" \ + do_test_run } test_run_star() { - do_test_run '*' 1.20.7 + GO_VERSION="*" \ + WANT_VERSION="1.20.7" \ + do_test_run } test_run_1_16rc1() { - do_test_run 1.16rc1 1.16rc1 + GO_VERSION="1.16rc1" \ + WANT_VERSION="1.16rc1" \ + do_test_run +} + +test_run_1_21rc4() { + GO_VERSION="1.21rc4" \ + WANT_VERSION="1.21rc4" \ + do_test_run +} + +test_go_mod() { + GO_VERSION_FILE="$SHUNIT_TMPDIR"/test_go_mod/go.mod + mkdir -p -- "$(dirname -- "$GO_VERSION_FILE")" + echo " +module foo +go 1.20.7 // the go version +" > "$GO_VERSION_FILE" + GO_VERSION_FILE="$GO_VERSION_FILE" \ + WANT_VERSION="1.20.7" \ + do_test_run } . ./external/shunit2 diff --git a/src/semver-select b/src/semver-select index d989062..70de7b0 100755 --- a/src/semver-select +++ b/src/semver-select @@ -7,7 +7,7 @@ CDPATH="" cd -- "$(dirname -- "$0")/.." . src/lib -target_version="0.3.0" +target_version="0.4.0" bin_path="./bin/semver-select" [ "$(goos)" = "windows" ] && bin_path+=".exe"