-
Notifications
You must be signed in to change notification settings - Fork 72
184 lines (179 loc) · 8.74 KB
/
cli.yml
File metadata and controls
184 lines (179 loc) · 8.74 KB
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
# Copyright 2026 OpenC3, Inc.
# All Rights Reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE.md for more details.
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.
name: CLI Tests
# Only run on a push to main to avoid running for all the dependabot PRs
on:
push:
branches:
- main
pull_request:
branches:
- "**"
env:
OPENC3_API_PASSWORD: password
OPENC3_API_PORT: 2900
jobs:
openc3-cli:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: openc3.sh build
# This `shell` line is required to get around a known issue: https://github.com/actions/runner/issues/241#issuecomment-745902718
shell: 'script -q -e -c "bash {0}"'
run: ./openc3.sh build
- name: openc3.sh run
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
! docker ps | grep openc3
./openc3.sh run
sleep 10s
docker ps | grep openc3
- name: openc3.sh stop
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
./openc3.sh stop
sleep 20s
! docker ps | grep openc3
- name: openc3.sh start
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
./openc3.sh start
sleep 30s
docker ps | grep openc3
# Not testing openc3.sh dev, openc3.sh test
- name: openc3.sh util encode,hash
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
./openc3.sh util | grep Usage || true
./openc3.sh util encode hello | grep aGVsbG8=
./openc3.sh util hash hello | grep 2cf24d
- name: openc3.sh util tag
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
./openc3.sh util tag | grep "Usage: tag" || true
./openc3.sh util tag docker.io localhost:12345 openc3inc latest openc3 mine
docker image ls | grep localhost:12345/openc3/openc3-cosmos-cmd-tlm-api | grep mine
docker image ls | grep localhost:12345/openc3/openc3-cosmos-script-runner-api | grep mine
docker image ls | grep localhost:12345/openc3/openc3-cosmos-init | grep mine
docker image ls | grep localhost:12345/openc3/openc3-operator | grep mine
docker image ls | grep localhost:12345/openc3/openc3-buckets | grep mine
docker image ls | grep localhost:12345/openc3/openc3-redis | grep mine
docker image ls | grep localhost:12345/openc3/openc3-traefik | grep mine
- name: openc3.sh util generate
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
### PLUGIN ###
./openc3.sh cli generate plugin | grep "Usage" || true
./openc3.sh cli generate plugin cli-test --ruby
./openc3.sh cli generate plugin cli-test --ruby | grep "already exists" || true
cd openc3-cosmos-cli-test
../openc3.sh cli rake build VERSION=1.0.0
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.0.gem
### TARGET ###
../openc3.sh cli generate target MY-cli --ruby
# Verify the target name 'MY_CLI' and lib filename 'my_cli.rb'
ls targets/MY_CLI/lib | grep my_cli.rb
../openc3.sh cli rake build VERSION=1.0.1
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.1.gem
### MICROSERVICE ###
../openc3.sh cli generate microservice background --ruby
# Verify the microservice name 'BACKGROUND' and filename 'background.rb'
ls microservices/BACKGROUND | grep background.rb
../openc3.sh cli rake build VERSION=1.0.2
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.2.gem
### CONVERSION ###
../openc3.sh cli generate conversion MY_CLI upcase --ruby
# Verify the conversion filename 'upcase_conversion.rb'
ls targets/MY_CLI/lib | grep upcase_conversion.rb
../openc3.sh cli rake build VERSION=1.0.3
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.3.gem
### PROCESSOR ###
../openc3.sh cli generate processor MY_CLI slope --ruby
# Verify the conversion filename 'slope_processor.rb'
ls targets/MY_CLI/lib | grep slope_processor.rb
../openc3.sh cli rake build VERSION=1.0.4
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.4.gem
### LIMITS_RESPONSE ###
../openc3.sh cli generate limits_response MY_CLI example --ruby
# Verify the conversion filename 'example_limits_response.rb'
ls targets/MY_CLI/lib | grep example_limits_response.rb
../openc3.sh cli rake build VERSION=1.0.5
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.5.gem
- name: openc3.sh cli script list, run, spawn
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
docker exec -it cosmos-openc3-redis-1 sh -c "echo -e 'AUTH openc3 openc3password\nset OPENC3__TOKEN \"\$argon2id\$v=19\$m=8,t=1,p=1\$KEDp3bRbyFK3lJLMa99kzQ\$INGoDEdgRbAG/wVie/ftzh//If91eeMTQQ5HoyKcfvY\"' | redis-cli"
# list shows all the available file names
./openc3.sh cli script list | tee /dev/tty | grep "INST/procedures/stash.rb"
# spawning a script prints only a PID
./openc3.sh cli script spawn INST/procedures/checks.rb | grep -v "^\s*\d+\s*$"
# run a script that will fail and look for the failure message
./openc3.sh cli script run --wait 20 INST/procedures/checks.rb | tee /dev/tty | grep -q "script failed"
# Check the running list for the first spawned script
./openc3.sh cli script running | tee /dev/tty | grep -q "INST/procedures/checks.rb"
# run a script that will complete successfully
./openc3.sh cli script run INST/procedures/stash.rb | tee /dev/tty | grep "script complete"
# run a suite
./openc3.sh cli script run INST/procedures/my_script_suite.rb --suite MySuite | tee /dev/tty | grep "script complete"
# run a group
./openc3.sh cli script run INST2/procedures/my_script_suite.py --suite MySuite --group ExampleGroup | tee /dev/tty | grep "script complete"
# run a group setup
./openc3.sh cli script run INST/procedures/my_script_suite.rb --suite MySuite --group ExampleGroup --method setup | tee /dev/tty | grep "script complete"
# run a group teardown
./openc3.sh cli script run INST2/procedures/my_script_suite.py --suite MySuite --group ExampleGroup --method teardown | tee /dev/tty | grep "script complete"
# run a script
./openc3.sh cli script run INST/procedures/my_script_suite.rb --suite MySuite --group ExampleGroup --script script_2 | tee /dev/tty | grep "script complete"
# Removing due to write tmp/.docker_temp_3200699358: no space left on device
# - name: openc3.sh util save,load
# shell: 'script -q -e -c "bash {0}"'
# run: |
# set -e
# ./openc3.sh util save docker.io openc3inc latest
# # Verify the images were saved
# ls tmp | grep openc3-cosmos-cmd-tlm-api-latest.tar
# ls tmp | grep openc3-cosmos-script-runner-api-latest.tar
# ls tmp | grep openc3-cosmos-init-latest.tar
# ls tmp | grep openc3-operator-latest.tar
# ls tmp | grep openc3-buckets-latest.tar
# ls tmp | grep openc3-redis-latest.tar
# ls tmp | grep openc3-traefik-latest.tar
# docker image rm openc3inc/openc3-cosmos-cmd-tlm-api:latest
# docker image rm openc3inc/openc3-cosmos-script-runner-api:latest
# docker image rm openc3inc/openc3-cosmos-init:latest
# docker image rm openc3inc/openc3-operator:latest
# docker image rm openc3inc/openc3-buckets:latest
# docker image rm openc3inc/openc3-redis:latest
# docker image rm openc3inc/openc3-traefik:latest
# ./openc3.sh util load
# # Verify the images were loaded
# docker image ls | grep openc3-cosmos-cmd-tlm-api
# docker image ls | grep openc3-cosmos-script-runner-api
# docker image ls | grep openc3-cosmos-init
# docker image ls | grep openc3-operator
# docker image ls | grep openc3-buckets
# docker image ls | grep openc3-redis
# docker image ls | grep openc3-traefik
- name: Cleanup volumes
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
docker volume ls | grep openc3
./openc3.sh cleanup force
! docker volume ls | grep openc3