diff --git a/.github/workflows/testme.yml b/.github/workflows/testme.yml index 16c97e7..36bfec8 100644 --- a/.github/workflows/testme.yml +++ b/.github/workflows/testme.yml @@ -1,27 +1,49 @@ on: push: - + jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: deps - run: pip install ruff - - uses: actions/checkout@v3 - - name: lint - run: ruff upload.py + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: deps + run: pip install ruff + - uses: actions/checkout@v3 + - name: lint + run: ruff upload.py publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: upload - uses: ./ - with: - meta-path: test/meta.json - org-id: ${{ secrets.test_org_id }} - do-upload: false - key-id: ${{ secrets.viam_key_id }} - key-value: ${{ secrets.viam_key_value }} + - uses: actions/checkout@v3 + - name: update-only + uses: ./ + with: + meta-path: test/meta.json + do-upload: false + key-id: ${{ secrets.viam_key_id }} + key-value: ${{ secrets.viam_key_value }} + - name: upload-with-meta-path + uses: ./ + with: + meta-path: test/meta.json + module-path: test/module.tar.gz + do-upload: true + platform: "linux/amd64" + version: "0.0.0-${{ github.run_id }}-${{ github.run_attempt }}" + key-id: ${{ secrets.viam_key_id }} + key-value: ${{ secrets.viam_key_value }} + - name: upload-no-meta-path + uses: ./ + with: + name: upload-ci-test + org-id: ${{ secrets.test_org_id }} + meta-path: '' + module-path: test/module.tar.gz + do-upload: true + do-update: false + platform: "linux/amd64" + version: "0.0.1-${{ github.run_id }}-${{ github.run_attempt }}" + key-id: ${{ secrets.viam_key_id }} + key-value: ${{ secrets.viam_key_value }} diff --git a/action.yml b/action.yml index 8fb6daa..0d1d5dc 100644 --- a/action.yml +++ b/action.yml @@ -11,9 +11,9 @@ inputs: name: description: name of the module. only necessary if you don't provide a metadata file. (see inputs.meta-path) org-id: - description: organization id. one of org-id or namespace are required if your meta.json doesn't use a namespace + description: organization id. one of org-id or namespace are required if you don't provide a metadata file. (see inputs.meta-path) namespace: - description: public namespace. one of org-id or namespace are required if your meta.json doesn't use a namespace + description: public namespace. one of org-id or namespace are required if you don't provide a metadata file. (see inputs.meta-path) key-id: description: ID of your auth key required: true diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..e94b610 --- /dev/null +++ b/test/README.md @@ -0,0 +1,9 @@ +This is a simple test module uploaded during the github action tests defined in .github/workflows/testme.yml + +The module.tar.gz was created by running: + +```sh +tar -czf module.tar.gz ./run.sh +``` + +The meta.js points to `run.sh` so the tar command must be run from the `test` directory diff --git a/test/meta.json b/test/meta.json index 59538e3..5b4643f 100644 --- a/test/meta.json +++ b/test/meta.json @@ -1,5 +1,5 @@ { - "name": "upload-ci-test", + "module_id": "viam:upload-ci-test", "visibility": "private", "url": "https://github.com/viamrobotics/upload-module", "description": "No-op module used for the upload CI action's self-test", diff --git a/test/module.tar.gz b/test/module.tar.gz new file mode 100644 index 0000000..6dd98cb Binary files /dev/null and b/test/module.tar.gz differ diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 0000000..53e495d --- /dev/null +++ b/test/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -euo pipefile +echo running diff --git a/upload.py b/upload.py index 287adad..af859f7 100755 --- a/upload.py +++ b/upload.py @@ -34,6 +34,9 @@ def main(): meta_args = () if args.meta_path: meta_args = ('--module', args.meta_path) + elif args.name: + meta_args = ('--name', args.name) + org_args = () if args.org_id: org_args = ('--org-id', args.org_id) @@ -46,7 +49,7 @@ def main(): subprocess.check_call([command, 'version']) subprocess.check_call([command, 'auth', 'api-key', '--key-id', args.key_id, '--key', args.key_value]) if args.do_update: - subprocess.check_call([command, 'module', 'update', *meta_args, *org_args]) + subprocess.check_call([command, 'module', 'update', *meta_args]) logging.info('ran update') if args.do_upload: subprocess.check_call([command, 'module', 'upload', *meta_args, *org_args, '--platform', args.platform, '--version', args.version, args.module_path])