-
Notifications
You must be signed in to change notification settings - Fork 5
/
prereq.yml
206 lines (191 loc) · 5.67 KB
/
prereq.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
version: 3
vars:
OS: "{{or .__OS OS}}"
ARCH: "{{or .__ARCH ARCH}}"
ARC: '{{if eq .OS "windows"}}.zip{{else}}.tar.gz{{end}}'
EXE: '{{if eq .OS "windows"}}.exe{{else}}{{end}}'
DRY: ""
tasks:
download-and-extract:
requires:
vars:
- FILE
- URL
- OUT
cmds:
- echo "{{.OUT}} {{.FILE}} {{.URL}} {{.FILETAR}}"
- curl -sL "{{.URL}}" -o {{.FILE}}
- extract "{{.FILE}}" "{{.OUT}}{{.EXE}}"
- remove "{{.FILE}}"
download:
requires:
vars:
- URL
- OUT
cmds:
- curl -sL -o"{{.OUT}}" "{{.URL}}"
- executable "{{.OUT}}"
7zz:
desc: download 7zz
vars:
VERSION: "2407"
SUFFIX:
sh: |
case "{{.OS}}-{{.ARCH}}" in
linux-amd64) echo "7z{{.VERSION}}-linux-x64.tar.xz" ;;
linux-arm64) echo "7z{{.VERSION}}-linux-arm64.tar.xz" ;;
darwin-*) echo "7z{{.VERSION}}-mac.tar.xz" ;;
windows-*) echo "7zr.exe" ;;
*) echo "unknown" ;;
esac
URL: "https://7-zip.org/a/{{.SUFFIX}}"
FILE: "{{base .URL}}"
cmds:
- curl -sL "{{.URL}}" -o "{{.FILE}}"
- |
if test "{{.OS}}" == "windows"
then rename 7zr.exe 7zz.exe
else extract "{{.FILE}}" 7zz
fi
- if test -e "{{.FILE}}" ; then remove "{{.FILE}}" ; fi
coreutils:
desc: download coreutils
vars:
# when changing this add the list of utilites to nuvroot.json in config.ops.coreutils
# do NOT include [ test false true echo base64
VERSION: "0.0.27"
SUFFIX:
sh: |
case "{{.OS}}-{{.ARCH}}" in
linux-amd64) echo "x86_64-unknown-linux-gnu" ;;
linux-arm64) echo "aarch64-unknown-linux-gnu" ;;
darwin-amd64) echo "x86_64-apple-darwin" ;;
darwin-arm64) echo "aarch64-apple-darwin" ;;
windows-*) echo "x86_64-pc-windows-gnu" ;;
*) echo "unknown" ;;
esac
URL: "https://github.com/uutils/coreutils/releases/download/{{.VERSION}}/coreutils-{{.VERSION}}-{{.SUFFIX}}{{.ARC}}"
FILE: "{{base .URL}}"
OUT: coreutils
cmds:
- task: download-and-extract
vars:
URL: "{{.URL}}"
FILE: "{{.FILE}}"
OUT: coreutils
bun:
desc: download bun
vars:
VERSION: "1.1.27"
ARCH2: '{{if eq .ARCH "amd64"}}x64{{else}}aarch64{{end}}'
URL: 'https://github.com/oven-sh/bun/releases/download/bun-v{{.VERSION}}/bun-{{.OS}}-{{.ARCH2}}.zip'
FILE: '{{base .URL}}'
cmds:
- echo "{{.URL}}"
- curl -sL "{{.URL}}" -o "{{.FILE}}"
- extract "{{.FILE}}" bun{{.EXE}}
- remove "{{.FILE}}"
kubectl:
desc: download kubectl
vars:
VERSION: 1.30.3
cmds:
- task: download
vars:
URL: "https://dl.k8s.io/release/v{{.VERSION}}/bin/{{.OS}}/{{.ARCH}}/kubectl{{.EXE}}"
OUT: kubectl
kind:
desc: download kind
vars:
VERSION: 0.22.0
cmds:
- task: download
vars:
URL: "https://kind.sigs.k8s.io/dl/v{{.VERSION}}/kind-{{.OS}}-{{.ARCH}}"
OUT: kind
k3sup:
desc: download k3sup
vars:
VERSION: 0.13.6
BASE: "https://github.com/alexellis/k3sup/releases/download/{{.VERSION}}"
FILE:
sh: |
case {{.OS}}-{{.ARCH}} in
(linux-amd64) echo k3sup ;;
(linux-arm64) echo k3sup-arm64 ;;
(darwin-amd64) echo k3sup-darwin ;;
(darwin-arm64) echo k3sup-darwin-arm64 ;;
(windows-amd64) echo k3sup.exe ;;
esac
cmds:
- task: download
vars:
URL: "{{.BASE}}/{{.FILE}}"
OUT: k3sup
rg:
desc: download ripgrep
vars:
# when changing this add the list of utilites to nuvroot.json in config.ops.coreutils
# do NOT include [ test false true echo
VERSION: "14.1.0"
SUFFIX:
sh: |
case "{{.OS}}-{{.ARCH}}" in
linux-amd64) echo "x86_64-unknown-linux-musl" ;;
linux-arm64) echo "aarch64-unknown-linux-gnu" ;;
darwin-amd64) echo "x86_64-apple-darwin" ;;
darwin-arm64) echo "aarch64-apple-darwin" ;;
windows-*) echo "x86_64-pc-windows-msvc" ;;
*) echo "unknown" ;;
esac
URL: "https://github.com/BurntSushi/ripgrep/releases/download/{{.VERSION}}/ripgrep-{{.VERSION}}-{{.SUFFIX}}{{.ARC}}"
FILE: "{{base .URL}}"
OUT: rg
cmds:
- task: download-and-extract
vars:
URL: "{{.URL}}"
FILE: "{{.FILE}}"
OUT: "{{.OUT}}"
all:
- task: 7zz
- task: coreutils
- task: bun
- task: kind
- task: k3sup
- task: kubectl
- task: rg
test:
vars:
DIR: "{{.OPS_PWD}}/bin/{{.OS}}-{{.ARCH}}"
cmds:
- |
{{.DRY}} rm -Rvf {{.DIR}}
mkdir -p {{.DIR}}
cd {{.DIR}}
{{.DRY}} ops -task -t ../../prereq.yml -d {{.DIR}} all
- task: check
check:
vars:
DIR: "{{.OPS_PWD}}/bin/{{.OS}}-{{.ARCH}}"
FILETYPE:
sh: |
case "{{.OS}}" in
(windows) echo application/vnd.microsoft.portable-executable ;;
(darwin) echo application/x-mach-binary ;;
(linux) echo application/x-executable ;;
(*) unknown ;;
esac
sources:
- '{{.DIR}}/*'
status:
- false
cmds:
- for: sources
cmd: filetype -m {{.ITEM}} | rg {{.FILETYPE}}
tests:
- __OS=linux __ARCH=amd64 ops -task -t prereq.yml test
- __OS=linux __ARCH=arm64 ops -task -t prereq.yml test
- __OS=darwin __ARCH=amd64 ops -task -t prereq.yml test
- __OS=darwin __ARCH=arm64 ops -task -t prereq.yml test
- __OS=windows __ARCH=amd64 ops -task -t prereq.yml test