-
Notifications
You must be signed in to change notification settings - Fork 32
154 lines (150 loc) · 6.94 KB
/
cli.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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: OpenC3 CLI Tests
# Only run on a push to master to avoid running for all the dependabot PRs
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
OPENC3_API_PASSWORD: password
jobs:
openc3-cli:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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-minio | 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
### 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.3
../openc3.sh cli validate openc3-cosmos-cli-test-1.0.3.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 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8' | 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 10 INST/procedures/checks.rb | tee /dev/tty | grep -q "script failed"
# run a script that will complete successfully
./openc3.sh cli script run INST/procedures/stash.rb | tee /dev/tty | grep "script complete"
- 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-minio-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-minio: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-minio
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