...
Plan - We will create our custom CLI, which can wrap around many of the gh cli commands that we expect will be used.
Temporary Location: BuildSystem/bs_cli at main · ad-build-test/BuildSystem (github.com)
Proposed list of additional CLI commands/operations:
- create related GH Issue (or JIRA) based on given CATER
- create new repo from template - Done
- Command is there, need to create the template(s).
- checkout component repo
- create bugfix branch from designated branch/tag/commit
- Run workflow:
- build - locally or remotely
- deploy - specific location
- test - locally or at specific location
- mark bugfix branch as ready for official/final review
- tag management
- create
- modify
- mark as bad
- delete
Current:
...
Introduction:
This command allows for auto completion (Shell Completion — Click Documentation (8.1.x) (palletsprojects.com):
Code Block |
---|
eval "$(_BS_COMPLETE=bash_source bs)" |
Example:
Image Added
TODO: See if we can add it to every user's .bashrc (or maybe just call that within the CLI once)
Sample build workflow using CLI
- Add test-ioc repo to db
Code Block |
---|
pnispero@PC100942:~/BuildSystem/bs_cli$ ./bs create repo -c test-ioc -u https://github.com/ad-build-test/test-ioc
[?] Specify organization name: ad-build-test
[?] Specify testing criteria: all
[?] Specify approval rule: all
[?] Specify component description: Test IOC used for BuildSystem testing
INFO-root:[create_commands.py:38 - repo() ] | {'linux_username': 'pnispero', 'github_username': 'test'}
INFO-root:[create_commands.py:39 - repo() ] | {'name': 'test-ioc', 'description': 'Test IOC used for BuildSystem testing', 'testingCriteria': 'all', 'approvalRule': 'all', 'organization': 'ad-build-test', 'url': 'https://github.com/ad-build-test/test-ioc'}
INFO-root:[create_commands.py:40 - repo() ] | 201
INFO-root:[create_commands.py:41 - repo() ] | {'errorCode': 0, 'payload': '66720253fd891a5aac14b3cf'}
INFO-root:[create_commands.py:42 - repo() ] | https://accel-webapp-dev.slac.stanford.edu/api/cbs/v1/component
INFO-root:[create_commands.py:43 - repo() ] | b'{"name": "test-ioc", "description": "Test IOC used for BuildSystem testing", "testingCriteria": "all", "approvalRule": "all", "organization": "ad-build-test", "url": "https://github.com/ad-build-test/test-ioc"}'
INFO-root:[create_commands.py:44 - repo() ] | {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'linux_username': 'pnispero', 'github_username': 'test', 'Content-Length': '210', 'Content-Type': 'application/json'}
pnispero@PC100942:~/BuildSystem/bs_cli$ |
2. Add dev branch to db
Code Block |
---|
pnispero@PC100942:~/test-ioc$ bs create branch -a
Checking current directory if a component...
[?] Specify what to branch from:
> branch
tag
commit
Specify name of branch: main
main
Specify name of branch: main
[?] Specify type of branch to create:
fix
feat
> dev
Specify name of issue number (or dev name): patrick
INFO-root:[create_commands.py:128 - branch() ] | 200
INFO-root:[create_commands.py:129 - branch() ] | {'errorCode': 0, 'payload': True}
INFO-root:[create_commands.py:130 - branch() ] | https://accel-webapp-dev.slac.stanford.edu/api/cbs/v1/component/test-ioc/branch
INFO-root:[create_commands.py:131 - branch() ] | b'{"type": "branch", "branchPoint": "main", "branchName": "dev-patrick"}'
INFO-root:[create_commands.py:132 - branch() ] | {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'linux_username': 'pnispero', 'github_username': 'test', 'Content-Length': '70', 'Content-Type': 'application/json'}
pnispero@PC100942:~/test-ioc$ |
3. Start a build
Code Block |
---|
pnispero@PC100942:~/test-ioc$ bs run build
Checking current directory if a component...
INFO-root:[run_commands.py:27 - build() ] | 201
INFO-root:[run_commands.py:28 - build() ] | {'errorCode': 0, 'payload': ['66721557fd891a5aac14b3d0']}
INFO-root:[run_commands.py:29 - build() ] | https://accel-webapp-dev.slac.stanford.edu/api/cbs/v1/build/component/test-ioc/branch/dev-patrick
INFO-root:[run_commands.py:30 - build() ] | b'{}'
INFO-root:[run_commands.py:31 - build() ] | {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'linux_username': 'pnispero', 'github_username': 'test', 'Content-Length': '2', 'Content-Type': 'application/json'}
pnispero@PC100942:~/test-ioc$ |
4. Check build (didn't make cli for this yet)
Code Block |
---|
pnispero@PC100942:~/BuildSystem$ curl -X 'GET' \
'https://accel-webapp-dev.slac.stanford.edu/api/cbs/v1/build/component/test-ioc/branch/dev-patrick' \
-H 'accept: application/json'
{"errorCode":0,"payload":[{"id":"66721557fd891a5aac14b3d0","buildOs":"ROCKY9","buildStatus":"PENDING"}]} |
5. Check log (didn't make cli for this yet - don't know if we want a command for this or to automatically show when 'bs run build'. Also Claudio is still working on this endpoint)
Code Block |
---|
pnispero@PC100942:~$ curl -X 'GET' \
'https://accel-webapp-dev.slac.stanford.edu/api/cbs/v1/build/66721557fd891a5aac14b3d0/log' \
-H 'accept: application/json'{"errorCode":0,"payload":[{},{},{},{},{},{},{},{},{},{},{},{},{},{}.....} |
Build Results working (checked manually)
Code Block |
---|
language | bash |
---|
linenumbers | true |
---|
collapse | true |
---|
|
bash-5.1$ pwd
/mnt/eed/ad-build/scratch/66721557fd891a5aac14b3d0-ROCKY9-test-ioc-dev-patrick/iocBoot/iocGuardianTest
bash-5.1$ ./st.cmd
#!../../bin/linux-x86_64/Guardian
< envPaths
epicsEnvSet("IOC","iocGuardianTest")
epicsEnvSet("TOP","/mnt/eed/ad-build/scratch/66721557fd891a5aac14b3d0-ROCKY9-test-ioc-dev-patrick")
epicsEnvSet("ASYN","/build/asyn")
epicsEnvSet("EPICS_BASE","/build/epics-base")
cd "/mnt/eed/ad-build/scratch/66721557fd891a5aac14b3d0-ROCKY9-test-ioc-dev-patrick"
## Register all support components
dbLoadDatabase "dbd/Guardian.dbd"
Guardian_registerRecordDeviceDriver pdbbase
## Load record instances
#dbLoadRecords("db/xxx.db","user=GUARDIAN")
dbLoadRecords("db/test.db") # PATRICK TODO: Temp here for testing
dbLoadRecords("db/guardian_snapshot.db", "BASE=SIOC:B34:GD_PATRICK") # PATRICK TODO: Temp add patrick so its unique
dbLoadRecords("db/guardian_device_data.db", "BASE=SIOC:B34:GD_PATRICK") # PATRICK TODO: Temp add patrick so its unique
## Configure Guardian driver
# GuardianDriverConfigure(
# Port Name, # Name given to this port driver
GuardianDriverConfigure("GUARDIAN")
cd "/mnt/eed/ad-build/scratch/66721557fd891a5aac14b3d0-ROCKY9-test-ioc-dev-patrick/iocBoot/iocGuardianTest"
iocInit
Starting iocInit
############################################################################
## EPICS R7.0.8.1-DEV
## Rev. R7.0.8-43-g72d50ce2749bbc791907
## Rev. Date Git: 2024-06-14 16:45:07 -0700
############################################################################
iocRun: All initialization complete
## Start any sequence programs
#seq sncxxx,"user=GUARDIAN"
epics> dbl
SIOC:B34:GD_PATRICK:FEL_PULSE_E
FBCK:FB02:GN01:S2DES_STORED_RBV
FBCK:FB02:GN01:S2DES_TEST
FBCK:FB02:GN01:S2DES_STORED
SIOC:B34:GD_PATRICK:SNAPSHOT_TRG_RBV
SIOC:B34:GD_PATRICK:SNAPSHOT_TRG_EN
epics> status: 0
curVal after get : 1
status: 0
curVal after get : 1
status: 0
curVal after set : 1
status: 0
curVal after get : 1
^C
bash-5.1$ |
...