This repository was archived by the owner on Jan 25, 2023. It is now read-only.
File tree 3 files changed +35
-16
lines changed
3 files changed +35
-16
lines changed Original file line number Diff line number Diff line change @@ -468,6 +468,8 @@ ENV GOCACHE "/opt/buildhome/.gimme_cache/gocache"
468
468
# Install the default version
469
469
ENV GIMME_GO_VERSION "1.19.x"
470
470
ENV GIMME_ENV_PREFIX "/opt/buildhome/.gimme/env"
471
+ ENV GIMME_VERSION_PREFIX "/opt/buildhome/.gimme/versions"
472
+ ENV GIMME_TYPE "binary"
471
473
RUN gimme | bash
472
474
473
475
# ###############################################################################
Original file line number Diff line number Diff line change @@ -1015,28 +1015,27 @@ install_go() {
1015
1015
fi
1016
1016
fi
1017
1017
1018
- if [ " $GIMME_GO_VERSION " != " $installGoVersion " ]
1018
+ # Cache known version for 7days (604800 seconds)
1019
+ resolvedGoVersion=" $( GIMME_KNOWN_CACHE_MAX=604800 gimme --resolve $installGoVersion ) "
1020
+ if [ $? -ne 0 ]
1021
+ then
1022
+ echo " Failed to resolve Go version '$installGoVersion '"
1023
+ exit 1
1024
+ fi
1025
+
1026
+ gimmeEnvFile=$HOME /.gimme/env/go$resolvedGoVersion .linux.$( dpkg --print-architecture) .env
1027
+
1028
+ # Check if the version is already installed by gimme
1029
+ if [ ! -f $gimmeEnvFile ]
1019
1030
then
1020
- resolvedGoVersion=$( gimme --resolve $installGoVersion )
1021
1031
echo " Installing Go version $resolvedGoVersion (requested $installGoVersion )"
1022
1032
GIMME_ENV_PREFIX=$HOME /.gimme/env GIMME_VERSION_PREFIX=$HOME /.gimme/versions gimme $resolvedGoVersion
1023
- if [ $? -eq 0 ]
1033
+ if [ $? -ne 0 ]
1024
1034
then
1025
- source $HOME /.gimme/env/go$resolvedGoVersion .linux.$( dpkg --print-architecture) .env
1026
- else
1027
1035
echo " Failed to install Go version '$resolvedGoVersion '"
1028
1036
exit 1
1029
1037
fi
1030
- else
1031
- gimme | bash
1032
- if [ $? -eq 0 ]
1033
- then
1034
- source $HOME /.gimme/env/go$GIMME_GO_VERSION .linux.amd64.env
1035
- else
1036
- echo " Failed to install Go version '$GIMME_GO_VERSION '"
1037
- exit 1
1038
- fi
1039
1038
fi
1040
1039
1040
+ source $gimmeEnvFile
1041
1041
}
1042
-
Original file line number Diff line number Diff line change @@ -15,10 +15,28 @@ setup() {
15
15
run install_go
16
16
assert_success
17
17
# we can't specify which patch version because it will change
18
- assert_output --partial " Installing Go version 1.19."
18
+ # Also no message about installation will be shown because it is the default already installed version
19
+ refute_output --partial " Installing Go version 1.19."
19
20
assert_output --partial " go version go1.19."
20
21
}
21
22
23
+ @test ' go version 1.19 at the latest patch is installed and available at startup by default when specifying default version' {
24
+ run install_go $GIMME_GO_VERSION
25
+ assert_success
26
+ # we can't specify which patch version because it will change
27
+ # Also no message about installation will be shown because it is the default already installed version
28
+ refute_output --partial " Installing Go version 1.19."
29
+ assert_output --partial " go version go1.19."
30
+ }
31
+
32
+ @test ' an unresolvable go version fails script' {
33
+ run install_go " notaversion"
34
+ assert_failure
35
+ assert_output --partial " Failed to resolve Go version 'notaversion'"
36
+ refute_output --partial " Installing Go version"
37
+ refute_output --partial " go version go"
38
+ }
39
+
22
40
@test ' install custom go version' {
23
41
local customGoVersion=1.16.4
24
42
run install_go $customGoVersion
You can’t perform that action at this time.
0 commit comments