Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use canon in CI #57

Merged
merged 14 commits into from
Nov 12, 2024
44 changes: 44 additions & 0 deletions .github/actions/build-module/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Build Module'
description: 'Builds the viamrtsp module using Docker'
inputs:
target_os:
description: 'Target OS'
required: true
target_arch:
description: 'Target architecture'
required: true
docker_image:
description: 'Docker image to use for building'
required: true
runs:
using: 'composite'
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.23 # match go.mod

- name: Pull Docker image
run: docker pull ${{ inputs.docker_image }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so using with: and including a docker image in the other workflows makes that an input here? i'm not familiar with inputs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think of it as params and args

params being what's defined above in inputs:

and with: being the args passed along

shell: bash

- name: Build and package using Docker
run: |
docker run --rm \
-e TARGET_OS=${{ inputs.target_os }} \
-e TARGET_ARCH=${{ inputs.target_arch }} \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
${{ inputs.docker_image }} \
sh -c "make module"
shell: bash

- name: Verify module.tar.gz exists recursively
run: |
if find . -name module.tar.gz | grep -q .; then
echo "module.tar.gz exists"
else
echo "module.tar.gz does not exist"
exit 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the goal here is just to report if module.tar.gz exists? will this cause the workflow to fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had this in for debugging but decided to keep it since it made sanity checking the existence of the make module module.tar.gz artifact easier. I think we can remove though it's not critical

fi
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will there be issues that you were using setup-go@v2 and now in action.yml you're using setup-go@v3?

Copy link
Collaborator Author

@hexbabe hexbabe Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point we don't need to bump it

reverted to v2

- name: Build module
uses: ./.github/actions/build-module
with:
go-version: 1.21

- name: Build viamrtsp binary
run: |
TARGET_OS=android TARGET_ARCH=arm64 make
target_os: android
target_arch: arm64
docker_image: ghcr.io/viamrobotics/antique2:amd64-cache
24 changes: 15 additions & 9 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Integration test using mediamtx

on: [push, pull_request]
on:
push:
paths-ignore:
- 'README.md'
pull_request:
paths-ignore:
- 'README.md'

jobs:
build-and-test:
Expand All @@ -11,10 +17,12 @@ jobs:
arch: amd64
mediamtx_url: https://github.com/bluenviron/mediamtx/releases/download/v1.9.0/mediamtx_v1.9.0_linux_amd64.tar.gz
viam_server_url: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-stable-x86_64.AppImage
docker_image: ghcr.io/viamrobotics/antique2:amd64-cache
- runner: buildjet-8vcpu-ubuntu-2204-arm
arch: arm64
mediamtx_url: https://github.com/bluenviron/mediamtx/releases/download/v1.9.0/mediamtx_v1.9.0_linux_arm64v8.tar.gz
viam_server_url: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-stable-aarch64.AppImage
docker_image: ghcr.io/viamrobotics/antique2:arm64-cache
config:
- name: "h264"
codec: "libx264"
Expand All @@ -29,11 +37,13 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
- name: Build module
uses: ./.github/actions/build-module
with:
go-version: 1.21.13

target_os: linux
target_arch: ${{ matrix.platform.arch }}
docker_image: ${{ matrix.platform.docker_image }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't still need the go version? does docker already use a specific version so you don't need it here?

Copy link
Collaborator Author

@hexbabe hexbabe Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We specify using: 'composite' in the action.yml, so the setup go action carries over to the environment of the main workflow


- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -51,10 +61,6 @@ jobs:
- name: Run fake RTSP camera
run: ffmpeg -re -f lavfi -i testsrc=size=640x480:rate=30 -vcodec ${{ matrix.config.codec }} ${{ matrix.config.extra_ffmpeg_args }} -pix_fmt yuv420p -f rtsp -rtsp_transport tcp rtsp://0.0.0.0:8554/live.stream &

- name: Build viamrtsp binary
run: |
TARGET_OS=linux TARGET_ARCH=${{ matrix.platform.arch }} make module

- name: Install viam-server
run: |
wget ${{ matrix.platform.viam_server_url }} -O viam-server
Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,32 @@ jobs:
runner: ubuntu-latest
target_os: linux
target_arch: amd64
docker_image: ghcr.io/viamrobotics/antique2:amd64-cache
- platform: linux/arm64
runner: buildjet-8vcpu-ubuntu-2204-arm
target_os: linux
target_arch: arm64
docker_image: ghcr.io/viamrobotics/antique2:arm64-cache
- platform: android/arm64
runner: ubuntu-latest
target_os: android
target_arch: arm64
docker_image: ghcr.io/viamrobotics/antique2:amd64-cache

runs-on: ${{ matrix.runner }}

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
- name: Build module
uses: ./.github/actions/build-module
with:
go-version: 1.21.13

- name: Install canon (only for non-Android platforms)
if: ${{ matrix.target_os != 'android' }}
run: |
export PATH="$(go env GOPATH)/bin:$PATH"
go install github.com/viamrobotics/[email protected]

- name: Build and package
run: |
if [ "${{ matrix.target_os }}" != "android" ]; then
canon --profile viam-rtsp-antique
fi
TARGET_OS=${{ matrix.target_os }} TARGET_ARCH=${{ matrix.target_arch }} make module
target_os: ${{ matrix.target_os }}
target_arch: ${{ matrix.target_arch }}
docker_image: ${{ matrix.docker_image }}

- name: Upload viamrtsp module to registry
uses: viamrobotics/upload-module@main
uses: viamrobotics/upload-module@v1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what the docs recommend

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know, I've been using main

with:
meta-path: meta.json
module-path: module.tar.gz
Expand Down
Loading