Skip to content

Commit fc2646c

Browse files
allmightyspiffGitHub Enterprise
authored andcommitted
Merge pull request #800 from SoftLayer/docUpdates
Updating readme for new workflow
2 parents 0f0b740 + e9cf662 commit fc2646c

2 files changed

Lines changed: 42 additions & 89 deletions

File tree

README.md

Lines changed: 42 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
1-
[![Build Status](https://travis.ibm.com/SoftLayer/softlayer-cli.svg?token=pYVqatXcXJaVqayApo1Y&branch=master)](https://travis.ibm.com/SoftLayer/softlayer-cli)
1+
[![Build Status](https://v3.travis.ibm.com/SoftLayer/softlayer-cli.svg?token=96jYRp3ei3sE2H3zUgDN&branch=master)](https://travis.ibm.com/SoftLayer/softlayer-cli)
22

33

44
# softlayer-cli
55

6-
This repository houses the code that powers the [ibmcloud-cli sl](https://github.ibm.com/Bluemix/bluemix-cli) command. Altough this project is packaged as a plugin, it is built directly into the ibmcloud-cli.
7-
6+
This repository houses the code that powers the [ibmcloud-cli sl](https://github.ibm.com/Bluemix/bluemix-cli) command.
87

98
# Project Setup
109

11-
Your golang source directory should be setup as follows
12-
13-
```
14-
~/go/src/github.ibm.com/ibmcloud-cli/bluemix-cli
15-
~/go/src/github.ibm.com/SoftLayer/softlayer-cli
16-
```
17-
18-
github.ibm.com/ibmcloud-cli/bluemix-cli should be branched off from the `dev` branch
19-
github.ibm.com/SoftLayer/softlayer-cli should be branched off from the `master` branch
20-
21-
Edit github.ibm.com/Bluemix/bluemix-cli/go.mod and add this line to the `replace` section. This will force `go mod vendor` to read changes from your local directory instead of off github.ibm.com. You may also need to change `github.ibm.com/SoftLayer/softlayer-cli v0.0.1` to `github.ibm.com/SoftLayer/softlayer-cli latest` in the require section.
22-
23-
```
24-
github.ibm.com/SoftLayer/softlayer-cli => ../../SoftLayer/softlayer-cli
25-
```
26-
27-
From there, make any changes you need to the code in `github.ibm.com/SoftLayer/softlayer-cli`. To actually see those changes apparent in `ibmcloud sl` you will need to switch directories to `github.ibm.com/Bluemix/bluemix-cli` and run `go build`
10+
Clone the repo, then just run `go mod vendor` and `go build` and you should have a running binary for the `sl` plugin.
2811

2912

3013
# Testing
3114
Before making a pull request, make sure everything looks good with these tools.
32-
Working directory: `github.ibm.com/SoftLayer/softlayer-cli`
15+
Working directory: `$GO_PATH/src/github.ibm.com/SoftLayer/softlayer-cli`
3316

3417
### What the build runs
3518

@@ -42,7 +25,8 @@ go test $(go list ./... | grep -v "fixtures" | grep -v "vendor")
4225

4326
This will test all the block commands, with verbose output
4427
```
45-
go test -v github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/block
28+
go test -v github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/<command_group>
29+
go test -v github.ibm.com/SoftLayer/softlayer-cli/plugin/managers
4630
```
4731

4832
This will test only the block commands that have "Access Password" in their test name, and stop after 1 failure
@@ -335,11 +319,9 @@ This command will build the Mac (arm64) version. Replace GOOS and GOARCH with th
335319
$> GOOS=darwin GOARCH=arm64 go build -o i18n4go_mac -ldflags "-s -w" i18n4go/i18n4go.go
336320
$> GOOS=linux GOARCH=amd64 go build -o out/i18n4go ./i18n4go/i18n4go.go
337321
```
338-
339-
340-
341322
[go-bindata](https://github.com/jteeuwen/go-bindata) takes the json files, and turns them into a go binary.
342323

324+
343325
### Basic Patterns and Tips
344326

345327
Where possible, you should try to minimize the number of unique strings we need to translate. To do this, make use of substitutions. For example:
@@ -358,68 +340,18 @@ T("This is some output for a {{.CMDTYPE}} command", subs)
358340

359341
### Useful Scripts
360342

361-
#### `./bin/catch-i18n-mismatch.sh`
362-
363-
If you get the following output, everything is fine
364-
```
365-
$ ./bin/catch-i18n-mismatch.sh
366-
OKTotal time: 372.753966ms
367-
```
368-
369-
If you get the following output, you need to edit the translation files
370-
```
371-
$> ./bin/catch-i18n-mismatch.sh
372-
>>> |"IP address {{.IP}} is not found on your account. Please confirm IP and try again.\n" exists in the code, but not in en_US| <<<
373-
>>> |" The server ID to remove from the security group" exists in the code, but not in en_US| <<<
374-
>>> |" The test ID to remove from the security group" exists in en_US, but not in the code| <<<
375-
====== ADD THESE =======
376-
[
377-
{"id": "IP address {{.IP}} is not found on your account. Please confirm IP and try again.\n", "translation": "IP address {{.IP}} is not found on your account. Please confirm IP and try again.\n"},
378-
{"id": " The server ID to remove from the security group", "translation": " The server ID to remove from the security group"}
379-
]
380-
====== DEL THESE =======
381-
[
382-
{"id": " The test ID to remove from the security group", "translation": " The test ID to remove from the security group"}
383-
]
384-
```
385-
386-
387-
#### `./bin/fixeverything_i18n.sh`
388-
389-
You can either do so manually, or run the following command which will do almost all the work for you
390-
391-
```
392-
$> sh bin/fixeverything_i18n.sh
393-
Running: ./bin/catch-i18n-mismatch.sh
394-
Running: python ./bin/split_i18n.py
395-
Running: ./bin/generate-i18n-resources.sh
396-
Running: git add ./plugin/i18n/resources/*.json
397-
Running: git add ./plugin/resources/i18n_resources.go
398-
Running: git commit --message="Translation fixes from ./bin/fixeverything_i18n.sh"
399-
[badBranch c12f1d7] Translation fixes from ./bin/fixeverything_i18n.sh
400-
11 files changed, 40 insertions(+), 20 deletions(-)
401-
Running: git checkout ./old-i18n/*.json
402-
Done
403-
```
404-
405-
406-
### Manually
407-
If you decided to edit the i18n files manually, make sure to run `bin/generate-i18n-resources` to build the required go source files. These sources files are what actually get built into the command, otherwise your translation additions wont show up.
343+
#### `./bin/buildAndDeploy.py i18n`
408344

345+
Should in general take care of all these steps for you. The binaries for win/mac/linux should be in the repo.
409346
```
410-
# This command will generate/update i18n_resources.go file
411-
$ ./bin/generate-i18n-resources
412-
Generating i18n resource file ...
413-
Done.
347+
$> python bin/buildAndDeploy.py i18n
348+
Running: C:\Users\allmi\go\src\github.ibm.com\softlayer\softlayer-cli\bin\i18n4go.exe -c=checkup -q=i18n -v -d=C:\Users\allmi\go\src\github.ibm.com\softlayer\softlayer-cli\plugin
349+
No Changes Needed!
350+
Building I18N: ./bin/go-bindata.exe -pkg=resources -o=plugin/resources/i18n_resources.go plugin/i18n/resources
351+
OK!
414352
```
415353

416354

417-
Removing and Adding translations automatically.
418-
419-
There are 2 files in `old-i18n` called `old-i18n/add_these.json` and `old-i18n/remove_these.json`. Dont commit changes to them, but do use them help automatically modify the translation files.
420-
421-
Run `./bin/split_i18n.py` (with python3.8 at least) to add everything in `add_these.json` and remove everything in `remove_these.json`.
422-
423355

424356
# Vendor
425357

@@ -487,13 +419,34 @@ It("return error", func() {
487419
# Plugin Support / Release Process
488420
After v1.4.1 `sl` will be a normal plugin, so where are the instructions to build the plugin.
489421

490-
0. Create a new version and tag it in github like normal.
491-
1. Build the binaries.
492-
```bash
493-
./bin/build-all
494-
for i in `ls --indicator-style=none out`; do echo "Uploading $i"; ibmcloud.exe cos upload --bucket softlayer-cli-binaries --file ./out/$i --key $i; done;
495-
```
496-
2. Run the Jenkins job https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Publish%20Plugin%20to%20YS1/
422+
Use the `./bin/buildAndDeploy.py` script to do a release:
423+
```
424+
$> python bin/buildAndDeploy.py
425+
Usage: buildAndDeploy.py [OPTIONS] COMMAND [ARGS]...
426+
427+
Options:
428+
--help Show this message and exit.
429+
430+
Commands:
431+
build Builds the SL binaries
432+
deploy Deploys the SL binaries
433+
i18n Checks and builds the i18n files
434+
jenkins Trigger a Jenkins build with existing files.
435+
release Builds, then deploys the release
436+
test Runs the tests
437+
```
438+
439+
1. `./bin/buildAndDeploy.py test` : Runs all the tests, required to pass
440+
2. `./bin/buildAndDeploy.py i18n` : Fixing missing i18n problems, builds the i18n gobindata
441+
3. `./bin/buildAndDeploy.py build` : Generates binaries for all architectures in `./out`
442+
4. `./bin/buildAndDeploy.py deploy` : Uploads binaries to our object storage account [softlayer-cli-binaries](https://s3.us-east.cloud-object-storage.appdomain.cloud/softlayer-cli-binaries/index.html):
443+
5. `./bin/buildAndDeploy.py release` : Spins up the [Jenkins](https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Publish%20Plugin%20to%20YS1/build ) job to publish a release
444+
445+
446+
ENV Variables that need to be set:
447+
1. `JENKINS_TOKEN` : Auth token to run Jenkins. Username is hardcoded for me at the moment.
448+
2. `IBMCLOUD_APIKEY` : API key for using `ibmcloud`. This is how we upload to COS. The COS plugin needs to be installed as well. `ibmcloud plugin install cloud-object-storage`
449+
497450

498451
## TODO
499452
Automate build with https://github.ibm.com/coligo/cli/tree/main/script

bin/go-bindata.exe

2.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)