Skip to content

Commit 2c5fc8d

Browse files
updated i18n_resources
2 parents 9648f3a + c4906a4 commit 2c5fc8d

12 files changed

Lines changed: 1125 additions & 187 deletions

File tree

bin/buildAndDeploy.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import platform
1111
import hashlib
1212
import glob
13-
import sys
1413
from rich import print
1514
from rich.markup import escape
1615

@@ -40,19 +39,11 @@ def buildArchs() -> dict:
4039
"""Returns the list of binaries we should build"""
4140
buildArchs = {
4241
'darwin': ['arm64', 'amd64'],
43-
'linux': ['amd64', '386', 'arm64'],
42+
'linux': ['amd64', '386', 'arm64', 'ppc64le', 's390x'],
4443
'windows': ['386', 'amd64'],
4544
}
4645
return buildArchs
4746

48-
def cgoEnable(theOs: str, theArch: str) -> int:
49-
"""Disable cgo for these archs"""
50-
cgo_disable = ["amd64", "386", "arm64"]
51-
if theOs == "linux" and theArch in cgo_disable:
52-
return 0
53-
return 1
54-
55-
5647

5748
def runTests() -> None:
5849
"""Runs unit tests"""
@@ -94,9 +85,6 @@ def runTests() -> None:
9485
except FileNotFoundError:
9586
gosec_instal = "curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin"
9687
print(f"[red]gosec not found. Try running:\n{gosec_instal}")
97-
98-
99-
10088

10189
### Section for i18n4go stuff ###
10290
def runI18n4go(path: str) -> None:
@@ -182,7 +170,6 @@ def add_i18n(file_name: str, updates: dict) -> None:
182170

183171
write_source_data(file_name, source_i18n)
184172

185-
186173
def del_i18n(file_name: str, updates: dict) -> None:
187174
"""Removes unneeded translations
188175
@@ -200,7 +187,6 @@ def del_i18n(file_name: str, updates: dict) -> None:
200187

201188
write_source_data(file_name, source_i18n)
202189

203-
204190
def get_source_data(file_name: str) -> dict:
205191
"""Reads from the i18n files and returns a formatted dict"""
206192
source_i18n = {}
@@ -277,11 +263,11 @@ def deploy(self):
277263
"""Uploads binaries to IBM COS"""
278264
apikey = os.getenv("IBMCLOUD_APIKEY")
279265
# if IBMCLOUD_TRACE is true the upload will print out the binary file data to the screen.
280-
os.environ["IBMCLOUD_TRACE"] = "False"
266+
os.environ["IBMCLOUD_TRACE"] = "false"
281267
if not apikey:
282268
raise Exception("IBMCLOUD_APIKEY needs to be set to the proper API key first.")
283-
login_cmd = ["ibmcloud", "login", f"--apikey={apikey}", "-r=us-east"]
284-
print(f"[yellow]Running: ibmcloud login --apikey $IBMCLOUD_APIKEY -r us-east")
269+
login_cmd = ["ibmcloud", "login", f"--apikey={apikey}"]
270+
print(f"[yellow]Running: ibmcloud login --apikey $IBMCLOUD_APIKEY")
285271
subprocess.run(login_cmd)
286272
files = glob.glob(os.path.join(self.cwd, 'out', f"sl-{self.version}-*"))
287273
for f in files:
@@ -296,6 +282,8 @@ def getChecksums(self) -> dict:
296282
'Linux_X86': {'file': f"sl-{self.version}-linux-386", 'checksum': ''},
297283
'Linux_X64': {'file': f"sl-{self.version}-linux-amd64", 'checksum': ''},
298284
'Linux_arm64' : {'file': f"sl-{self.version}-linux-arm64", 'checksum': ''},
285+
'Linux_Ppc64le': {'file': f"sl-{self.version}-linux-ppc64le", 'checksum': ''},
286+
'Linux_s390x': {'file': f"sl-{self.version}-linux-s390x", 'checksum': ''},
299287
'MacOS': {'file': f"sl-{self.version}-darwin-amd64", 'checksum': ''},
300288
'MacOS_arm64': {'file': f"sl-{self.version}-darwin-arm64", 'checksum': ''},
301289
'Win_X86': {'file': f"sl-{self.version}-windows-386.exe", 'checksum': ''},
@@ -325,7 +313,14 @@ def runJenkins(self):
325313
'{"name":"Url_Linux_X86", "value":"https://s3.us-east.cloud-object-storage.appdomain.cloud/softlayer-cli-binaries/sl-1.4.2-linux-386"}]}' -v
326314
"""
327315
checksums = self.getChecksums()
316+
# Set this to true if you want to use the Refresh-Plugin-Version-on-YS1 job
317+
refresh = False
318+
# This create a new version
328319
jenkinsUrl = 'https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Publish%20Plugin%20to%20YS1'
320+
321+
if refresh:
322+
# This updates an existing version
323+
jenkinsUrl = 'https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Refresh-Plugin-Version-on-YS1'
329324
jenkins_token = os.getenv('JENKINS_TOKEN')
330325
if not jenkins_token:
331326
raise Exception("JENKINS_TOKEN is not set to an API key")
@@ -342,7 +337,11 @@ def runJenkins(self):
342337

343338
for x in checksums.keys():
344339
urlData = {'name': f"Url_{x}", "value": self.cnd_url + checksums[x]['file']}
345-
checkData = {'name': f"Checksum_{x}", "value": checksums[x]['checksum']}
340+
# This one doesn't follow the normal pattern so it needs a special case.
341+
if x == "Linux_s390x" and not refresh:
342+
checkData = {'name': f"Checksum_Linux_S390x", "value": checksums[x]['checksum']}
343+
else:
344+
checkData = {'name': f"Checksum_{x}", "value": checksums[x]['checksum']}
346345
form_json['parameter'].append(urlData)
347346
form_json['parameter'].append(checkData)
348347

@@ -353,7 +352,10 @@ def runJenkins(self):
353352
print(f"[green] Created Job! Check {jenkinsUrl}" )
354353
else:
355354
print(f"[red]Error: {result.status_code} {result.reason}")
356-
raise Excetion("Error in runJenkins()")
355+
print(f"[yellow] {result.text}")
356+
print(f"[yellow] {result.url}")
357+
print(f"[yellow] {result.request}")
358+
raise Exception("Error in runJenkins()")
357359

358360

359361

@@ -364,16 +366,17 @@ def goBuild(self, theOs: str, theArch: str) -> None:
364366
:param str theOs: OS to build for
365367
:param str theArch: Architecture to build for
366368
"""
369+
cgo_enabled = 0
367370
os.environ["GOOS"] = theOs
368371
os.environ["GOARCH"] = theArch
369-
os.environ["CGO_ENABLED"] = str(cgoEnable(theOs, theArch))
372+
os.environ["CGO_ENABLED"] = str(cgo_enabled)
370373

371374
print(f"[green]Building {theOs}-{theArch}")
372375
binaryName = os.path.join(self.cwd, 'out', f"sl-{self.version}-{theOs}-{theArch}")
373376
if theOs == "windows":
374377
binaryName = f"{binaryName}.exe"
375-
buildCmd = f"go build -ldflags \"-s -w\" -o {binaryName} ."
376-
print(f"[turquoise2]Running {buildCmd}")
378+
buildCmd = f" go build -ldflags \"-s -w\" -o {binaryName} ."
379+
print(f"[turquoise2]Running GOOS={theOs} GOARCH={theArch} CGO_ENABLED={cgo_enabled} {buildCmd}")
377380
# This command basically requires shell=True on mac because -ldflags doesn't get parsed properly withoutit.
378381
subprocess.run(buildCmd, shell=True)
379382

@@ -442,4 +445,3 @@ def i18n(ctx):
442445
# except Exception as e:
443446
# print(f"[red]{e}")
444447

445-

0 commit comments

Comments
 (0)