Skip to content

Commit 85325ad

Browse files
Revert jenkins removal (#3828)
* partly revert removal of jenkins-related scripts
1 parent 3afa073 commit 85325ad

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed

.ci/bump-golang.yml

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: Bump golang-version to latest version
3+
4+
scms:
5+
githubConfig:
6+
kind: github
7+
spec:
8+
user: '{{ requiredEnv "GIT_USER" }}'
9+
email: '{{ requiredEnv "GIT_EMAIL" }}'
10+
owner: elastic
11+
repository: elastic-agent
12+
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
13+
username: '{{ requiredEnv "GIT_USER" }}'
14+
branch: main
15+
16+
actions:
17+
elastic-agent:
18+
kind: github/pullrequest
19+
scmid: githubConfig
20+
sourceid: latestGoVersion
21+
spec:
22+
automerge: false
23+
labels:
24+
- dependencies
25+
- backport-skip
26+
title: '[Automation] Bump Golang version to {{ source "latestGoVersion" }}'
27+
description: |
28+
It requires the version to be bumped first in golang-crossbuild project, then a new release will be added to:
29+
https://github.com/elastic/golang-crossbuild/releases/tag/v{{ source "latestGoVersion" }}.
30+
Otherwise it will fail until the docker images are available.
31+
32+
sources:
33+
minor:
34+
name: Get minor version in .go-version
35+
kind: shell
36+
transformers:
37+
- findsubmatch:
38+
pattern: '^\d+.(\d+).\d+$'
39+
captureindex: 1
40+
spec:
41+
command: cat .go-version
42+
43+
latestGoVersion:
44+
name: Get Latest Go Release
45+
kind: githubrelease
46+
dependson:
47+
- minor
48+
transformers:
49+
- trimprefix: go
50+
spec:
51+
owner: golang
52+
repository: go
53+
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
54+
username: '{{ requiredEnv "GIT_USER" }}'
55+
versionfilter:
56+
kind: regex
57+
pattern: go1\.{{ source "minor" }}\.(\d*)$
58+
59+
gomod:
60+
dependson:
61+
- latestGoVersion
62+
name: Get version in go.mod format
63+
kind: shell
64+
transformers:
65+
- findsubmatch:
66+
pattern: '^(\d+.\d+).\d+'
67+
captureindex: 1
68+
spec:
69+
command: echo {{ source "latestGoVersion" }}
70+
71+
conditions:
72+
dockerTag:
73+
name: Is docker image golang:{{ source "latestGoVersion" }} published
74+
kind: dockerimage
75+
spec:
76+
image: golang
77+
tag: '{{ source "latestGoVersion" }}'
78+
sourceid: latestGoVersion
79+
80+
goDefaultVersion-check:
81+
name: Check if defined golang version differs
82+
kind: shell
83+
sourceid: latestGoVersion
84+
spec:
85+
command: 'grep -v -q {{ source "latestGoVersion" }} .go-version #'
86+
87+
targets:
88+
update-go-version:
89+
name: "Update .go-version"
90+
sourceid: latestGoVersion
91+
scmid: githubConfig
92+
kind: file
93+
spec:
94+
content: '{{ source "latestGoVersion" }}'
95+
file: .go-version
96+
matchpattern: '\d+.\d+.\d+'
97+
update-golang.ci:
98+
name: "Update .golangci.yml"
99+
sourceid: latestGoVersion
100+
scmid: githubConfig
101+
kind: file
102+
spec:
103+
content: '{{ source "latestGoVersion" }}'
104+
file: .golangci.yml
105+
matchpattern: '\d+.\d+.\d+'
106+
update-version.asciidoc:
107+
name: "Update version.asciidoc"
108+
sourceid: latestGoVersion
109+
scmid: githubConfig
110+
kind: file
111+
spec:
112+
content: ':go-version: {{ source "latestGoVersion" }}'
113+
file: version/docs/version.asciidoc
114+
matchpattern: ':go-version: \d+.\d+.\d+'
115+
update-dockerfiles:
116+
name: "Update from dockerfiles"
117+
sourceid: latestGoVersion
118+
scmid: githubConfig
119+
kind: file
120+
spec:
121+
content: 'ARG GO_VERSION={{ source "latestGoVersion" }}'
122+
files:
123+
- Dockerfile
124+
- Dockerfile.skaffold
125+
matchpattern: 'ARG GO_VERSION=\d+.\d+.\d+'
126+
update-gomod:
127+
name: "Update go.mod"
128+
sourceid: gomod
129+
scmid: githubConfig
130+
kind: file
131+
spec:
132+
content: 'go {{ source "gomod" }}'
133+
file: go.mod
134+
matchpattern: 'go \d+.\d+'

.ci/scripts/install-go.bat

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
set GOPATH=%WORKSPACE%
2+
set MAGEFILE_CACHE=%WORKSPACE%\.magefile
3+
4+
set PATH=%WORKSPACE%\bin;C:\ProgramData\chocolatey\bin;%PATH%
5+
6+
curl --version >nul 2>&1 && (
7+
echo found curl
8+
) || (
9+
choco install curl -y --no-progress --skipdownloadcache
10+
)
11+
12+
mkdir %WORKSPACE%\bin
13+
14+
IF EXIST "%PROGRAMFILES(X86)%" (
15+
REM Force the gvm installation.
16+
SET GVM_BIN=gvm.exe
17+
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-amd64.exe
18+
IF ERRORLEVEL 1 (
19+
REM gvm installation has failed.
20+
del bin\gvm.exe /s /f /q
21+
exit /b 1
22+
)
23+
) ELSE (
24+
REM Windows 7 workers got a broken gvm installation.
25+
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-386.exe
26+
IF ERRORLEVEL 1 (
27+
REM gvm installation has failed.
28+
del bin\gvm.exe /s /f /q
29+
exit /b 1
30+
)
31+
)
32+
33+
SET GVM_BIN=gvm.exe
34+
WHERE /q %GVM_BIN%
35+
%GVM_BIN% version
36+
37+
REM Install the given go version
38+
%GVM_BIN% --debug install %GO_VERSION%
39+
40+
REM Configure the given go version
41+
FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i
42+
43+
go env
44+
IF ERRORLEVEL 1 (
45+
REM go is not configured correctly.
46+
rmdir %WORKSPACE%\.gvm /s /q
47+
exit /b 1
48+
)
49+
50+
where mage
51+
mage -version
52+
IF ERRORLEVEL 1 (
53+
go get github.com/magefile/mage
54+
IF ERRORLEVEL 1 (
55+
exit /b 1
56+
)
57+
)

.ci/scripts/install-go.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -exuo pipefail
3+
4+
MSG="environment variable missing"
5+
GO_VERSION=${GO_VERSION:?$MSG}
6+
PROPERTIES_FILE=${PROPERTIES_FILE:-"go_env.properties"}
7+
HOME=${HOME:?$MSG}
8+
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
9+
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]')
10+
GVM_CMD="${HOME}/bin/gvm"
11+
12+
if command -v go
13+
then
14+
set +e
15+
echo "Found Go. Checking version.."
16+
FOUND_GO_VERSION=$(go version|awk '{print $3}'|sed s/go//)
17+
if [ "$FOUND_GO_VERSION" == "$GO_VERSION" ]
18+
then
19+
echo "Versions match. No need to install Go. Exiting."
20+
exit 0
21+
fi
22+
set -e
23+
fi
24+
25+
if [ "${ARCH}" == "aarch64" ] ; then
26+
GVM_ARCH_SUFFIX=arm64
27+
elif [ "${ARCH}" == "x86_64" ] ; then
28+
GVM_ARCH_SUFFIX=amd64
29+
elif [ "${ARCH}" == "i686" ] ; then
30+
GVM_ARCH_SUFFIX=386
31+
else
32+
GVM_ARCH_SUFFIX=arm
33+
fi
34+
35+
echo "UNMET DEP: Installing Go"
36+
mkdir -p "${HOME}/bin"
37+
38+
curl -sSLo "${GVM_CMD}" "https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-${OS}-${GVM_ARCH_SUFFIX}"
39+
chmod +x "${GVM_CMD}"
40+
41+
${GVM_CMD} "${GO_VERSION}" |cut -d ' ' -f 2|tr -d '\"' > ${PROPERTIES_FILE}
42+
43+
eval "$("${GVM_CMD}" "${GO_VERSION}")"

0 commit comments

Comments
 (0)