Skip to content

Commit bbadcf6

Browse files
Merge pull request #5 from viamrobotics/zp/update-params-updated
Fix action to work with new version of the CLI + add more tests
2 parents 9f76793 + 7ebf3ce commit bbadcf6

File tree

7 files changed

+59
-22
lines changed

7 files changed

+59
-22
lines changed

.github/workflows/testme.yml

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
11
on:
22
push:
3-
3+
44
jobs:
55
lint:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/setup-python@v4
9-
with:
10-
python-version: '3.10'
11-
- name: deps
12-
run: pip install ruff
13-
- uses: actions/checkout@v3
14-
- name: lint
15-
run: ruff upload.py
8+
- uses: actions/setup-python@v4
9+
with:
10+
python-version: "3.10"
11+
- name: deps
12+
run: pip install ruff
13+
- uses: actions/checkout@v3
14+
- name: lint
15+
run: ruff upload.py
1616
publish:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
20-
- name: upload
21-
uses: ./
22-
with:
23-
meta-path: test/meta.json
24-
org-id: ${{ secrets.test_org_id }}
25-
do-upload: false
26-
key-id: ${{ secrets.viam_key_id }}
27-
key-value: ${{ secrets.viam_key_value }}
19+
- uses: actions/checkout@v3
20+
- name: update-only
21+
uses: ./
22+
with:
23+
meta-path: test/meta.json
24+
do-upload: false
25+
key-id: ${{ secrets.viam_key_id }}
26+
key-value: ${{ secrets.viam_key_value }}
27+
- name: upload-with-meta-path
28+
uses: ./
29+
with:
30+
meta-path: test/meta.json
31+
module-path: test/module.tar.gz
32+
do-upload: true
33+
platform: "linux/amd64"
34+
version: "0.0.0-${{ github.run_id }}-${{ github.run_attempt }}"
35+
key-id: ${{ secrets.viam_key_id }}
36+
key-value: ${{ secrets.viam_key_value }}
37+
- name: upload-no-meta-path
38+
uses: ./
39+
with:
40+
name: upload-ci-test
41+
org-id: ${{ secrets.test_org_id }}
42+
meta-path: ''
43+
module-path: test/module.tar.gz
44+
do-upload: true
45+
do-update: false
46+
platform: "linux/amd64"
47+
version: "0.0.1-${{ github.run_id }}-${{ github.run_attempt }}"
48+
key-id: ${{ secrets.viam_key_id }}
49+
key-value: ${{ secrets.viam_key_value }}

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ inputs:
1111
name:
1212
description: name of the module. only necessary if you don't provide a metadata file. (see inputs.meta-path)
1313
org-id:
14-
description: organization id. one of org-id or namespace are required if your meta.json doesn't use a namespace
14+
description: organization id. one of org-id or namespace are required if you don't provide a metadata file. (see inputs.meta-path)
1515
namespace:
16-
description: public namespace. one of org-id or namespace are required if your meta.json doesn't use a namespace
16+
description: public namespace. one of org-id or namespace are required if you don't provide a metadata file. (see inputs.meta-path)
1717
key-id:
1818
description: ID of your auth key
1919
required: true

test/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This is a simple test module uploaded during the github action tests defined in .github/workflows/testme.yml
2+
3+
The module.tar.gz was created by running:
4+
5+
```sh
6+
tar -czf module.tar.gz ./run.sh
7+
```
8+
9+
The meta.js points to `run.sh` so the tar command must be run from the `test` directory

test/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "upload-ci-test",
2+
"module_id": "viam:upload-ci-test",
33
"visibility": "private",
44
"url": "https://github.com/viamrobotics/upload-module",
55
"description": "No-op module used for the upload CI action's self-test",

test/module.tar.gz

170 Bytes
Binary file not shown.

test/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefile
3+
echo running

upload.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def main():
3434
meta_args = ()
3535
if args.meta_path:
3636
meta_args = ('--module', args.meta_path)
37+
elif args.name:
38+
meta_args = ('--name', args.name)
39+
3740
org_args = ()
3841
if args.org_id:
3942
org_args = ('--org-id', args.org_id)
@@ -46,7 +49,7 @@ def main():
4649
subprocess.check_call([command, 'version'])
4750
subprocess.check_call([command, 'auth', 'api-key', '--key-id', args.key_id, '--key', args.key_value])
4851
if args.do_update:
49-
subprocess.check_call([command, 'module', 'update', *meta_args, *org_args])
52+
subprocess.check_call([command, 'module', 'update', *meta_args])
5053
logging.info('ran update')
5154
if args.do_upload:
5255
subprocess.check_call([command, 'module', 'upload', *meta_args, *org_args, '--platform', args.platform, '--version', args.version, args.module_path])

0 commit comments

Comments
 (0)