Skip to content

Commit

Permalink
Merge branch 'main' into sguequierre-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
sguequierre authored Nov 28, 2023
2 parents c2c0091 + a2c1690 commit 0793a4d
Show file tree
Hide file tree
Showing 21 changed files with 568 additions and 194 deletions.
88 changes: 50 additions & 38 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,56 @@ on:

jobs:
publish:
runs-on: [buildjet-2vcpu-ubuntu-2204-arm]
runs-on: buildjet-2vcpu-ubuntu-2204-arm
strategy:
matrix:
include:
- container: ghcr.io/seanavery/viam-cpp-base:0.0.2
TARGET: jetson
META_PATH: meta.json
- container: ghcr.io/seanavery/viam-cpp-base-pi:0.0.2
TARGET: pi
META_PATH: meta-pi.json
container:
image: ghcr.io/seanavery/viam-cpp-base:0.0.2
image: ${{ matrix.container }}
options: --platform linux/arm64

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Clean build artifacts
run: make clean

- name: Install module dependencies
run: make dep

- name: Build viam-csi binary
run: make build

- name: Build viam-csi appimage
run: make package

- name: Copy binary and appimage to bin folder and archive
run: make bin && tar czf module.tar.gz ./bin/*.AppImage

- name: Run appimage in fresh L4T instance
run: |
make image-test TARGET=jetson
make test-package TARGET=jetson
- name: Run appimage in fresh debian instance
run: |
make image-test TARGET=pi
make test-package TARGET=pi
- uses: viamrobotics/upload-module@main
if: github.event_name == 'release'
with:
module-path: module.tar.gz
platform: linux/arm64
version: ${{ github.ref_name }}
key-id: ${{ secrets.viam_key_id }}
key-value: ${{ secrets.viam_key_value }}
- name: Check out code
uses: actions/checkout@v3

- name: Set environment variables
run: |
echo "TARGET=${{ matrix.TARGET }}" >> $GITHUB_ENV
echo "META_PATH=${{ matrix.META_PATH }}" >> $GITHUB_ENV
- name: Clean build artifacts
run: make clean

- name: Install module dependencies
run: make dep

- name: Build viam-csi binary
run: make build

- name: Build viam-csi appimage
run: make package

- name: Copy binary and appimage to bin folder and archive
run: make bin && tar czf module.tar.gz ./bin/*.AppImage

- name: Run appimage in fresh instance
run: |
make image-test
make test-package
- name: Upload Module
uses: viamrobotics/upload-module@main
if: startsWith(github.ref, 'refs/tags/')
with:
meta-path: ${{ env.META_PATH }}
module-path: bin/viam-csi-latest-aarch64.AppImage
platform: linux/arm64
version: ${{ github.ref_name }}
key-id: ${{ secrets.viam_key_id }}
key-value: ${{ secrets.viam_key_value }}
69 changes: 48 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@ on:
- '*'
paths-ignore:
- 'README.md'
- 'docs/**'

jobs:
appimage:
name: AppImage Build
name: Build/Test/Upload latest
runs-on: buildjet-2vcpu-ubuntu-2204-arm
strategy:
fail-fast: false
matrix:
include:
- arch: [buildjet-2vcpu-ubuntu-2204-arm]
image: ghcr.io/seanavery/viam-cpp-base:0.0.2
platform: linux/arm64
runs-on: ${{ matrix.arch }}
- container: ghcr.io/seanavery/viam-cpp-base:0.0.2
TARGET: jetson
META_PATH: meta.json
- container: ghcr.io/seanavery/viam-cpp-base-pi:0.0.2
TARGET: pi
META_PATH: meta-pi.json
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 15
outputs:
date: ${{ steps.build_date.outputs.date }}
image: ${{ matrix.container }}
options: --platform linux/arm64

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set environment variables
run: |
echo "TARGET=${{ matrix.TARGET }}" >> $GITHUB_ENV
echo "META_PATH=${{ matrix.META_PATH }}" >> $GITHUB_ENV
- name: Clean build artifacts
run: make clean

Expand All @@ -44,15 +49,10 @@ jobs:
- name: Copy binary and appimage to bin folder
run: make bin

- name: Run appimage in fresh L4T instance
run: |
make image-test TARGET=jetson
make test-package TARGET=jetson
- name: Run appimage in fresh debian instance
- name: Run appimage in fresh instance
run: |
make image-test TARGET=pi
make test-package TARGET=pi
make image-test
make test-package
- name: Authorize GCP upload
uses: google-github-actions/auth@v1
Expand All @@ -64,8 +64,35 @@ jobs:
with:
headers: "cache-control: no-cache"
path: 'bin'
destination: 'packages.viam.com/apps/csi-camera/'
destination: 'packages.viam.com/apps/csi-camera/${{ env.TARGET }}'
glob: '*aarch64*'
parent: false
gzip: false
# TODO: Run cpp tests

- name: Get latest release version
id: get_version
run: |
apt install -y jq
LATEST_RELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "LATEST_RELEASE_VERSION=$LATEST_RELEASE" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Testing module env variables
run: |
echo "TARGET=${{ env.TARGET }}"
echo "META_PATH=${{ env.META_PATH }}"
echo "COMMIT_COUNT=${{ env.COMMIT_COUNT }}"
echo "LATEST_RELEASE_VERSION=${{ env.LATEST_RELEASE_VERSION }}"
echo "version: ${{ env.LATEST_RELEASE_VERSION }}-${{ github.ref_name }}.${{ github.run_number }}"
- name: Update module registry
uses: viamrobotics/upload-module@main
if: github.event_name == 'push'
with:
meta-path: ${{ env.META_PATH }}
module-path: bin/viam-csi-latest-aarch64.AppImage
platform: linux/arm64
version: ${{ env.LATEST_RELEASE_VERSION }}-${{ github.ref_name }}.${{ github.run_number }}
key-id: ${{ secrets.viam_key_id }}
key-value: ${{ secrets.viam_key_value }}
41 changes: 0 additions & 41 deletions .github/workflows/request.yaml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test pull request

on:
pull_request:
branches:
- '*'
paths-ignore:
- 'README.md'
- 'docs/**'

jobs:
test-package:
name: Build/Test appimage
runs-on: buildjet-2vcpu-ubuntu-2204-arm
strategy:
matrix:
include:
- container: ghcr.io/seanavery/viam-cpp-base:0.0.2
TARGET: jetson
- container: ghcr.io/seanavery/viam-cpp-base-pi:0.0.2
TARGET: pi
container:
image: ${{ matrix.container }}
options: --platform linux/arm64

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set TARGET environment variable
run: echo "TARGET=${{ matrix.TARGET }}" >> $GITHUB_ENV

- name: Clean build artifacts
run: make clean

- name: Install module dependencies
run: make dep

- name: Build viam-csi binary
run: make build

- name: Build viam-csi appimage
run: make package

- name: Copy binary and appimage to bin folder
run: make bin

- name: Run appimage in fresh instance
run: |
make image-test
make test-package
59 changes: 42 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ INSTALL_DIR := $(BUILD_DIR)/AppDir
BIN_DIR := ./bin

# Docker
BASE_NAME := viam-cpp-base
MOD_NAME := viam-csi-module
TEST_NAME := viam-csi-tests
HUB_USER := seanavery
TEST_NAME := viam-csi-test
DOCK_TAG := 0.0.1 # tag for mod/test images
BASE_TAG := 0.0.2
L4T_TAG := 35.3.1
Expand All @@ -18,11 +16,20 @@ PACK_TAG := latest

# CLI
TARGET ?= pi # [jetson,pi]
TEST_BASE ?= debian:bookworm
ifeq ($(TARGET), jetson)
TEST_BASE=nvcr.io/nvidia/l4t-base:$(L4T_TAG)
BASE_NAME=viam-cpp-base
BASE_CONFIG=./etc/Dockerfile.base
MOD_NAME=viam-csi-module-jetson
MOD_CONFIG=./etc/Dockerfile.mod
RECIPE=./viam-csi-jetson-arm64.yml
else ifeq ($(TARGET), pi)
TEST_BASE=debian:bookworm
BASE_NAME=viam-cpp-base-pi
BASE_CONFIG=./etc/Dockerfile.base.bullseye
MOD_NAME=viam-csi-module-pi
MOD_CONFIG=./etc/Dockerfile.mod.pi
RECIPE=./viam-csi-pi-arm64.yml
endif

# Module
Expand All @@ -41,7 +48,7 @@ package:
PACK_NAME=$(PACK_NAME) \
PACK_TAG=$(PACK_TAG) \
appimage-builder \
--recipe viam-csi-jetson-arm64.yml
--recipe $(RECIPE) \

# Removes all build and bin artifacts.
clean:
Expand All @@ -62,28 +69,46 @@ dep:
export DEBIAN_FRONTEND=noninteractive && \
export TZ=America/New_York && \
apt-get update && \
apt-get -y install libgtest-dev && \
apt-get install -y gstreamer1.0-tools && \
apt-get install -y libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev \
libgstreamer-plugins-bad1.0-dev
if [ "$(TARGET)" = "jetson" ]; then \
apt-get -y install libgtest-dev && \
apt-get install -y gstreamer1.0-tools && \
apt-get install -y libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev \
libgstreamer-plugins-bad1.0-dev; \
elif [ "$(TARGET)" = "pi" ]; then \
apt-get install -y --no-install-recommends software-properties-common && \
apt-add-repository 'deb http://archive.raspberrypi.org/debian/ bullseye main' && \
wget -qO - https://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - && \
apt-get -y update && \
apt-get -y install libcamera0 libgstreamer1.0-dev libgstreamer1.0-0 gstreamer1.0-x gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libgstreamer-plugins-base1.0-dev && \
apt-get -y install libgtest-dev && \
cd /usr/src/gtest && \
cmake ./ && \
make && \
apt-get install libgmock-dev && \
cd /usr/src/googletest/googlemock/ && \
cmake ./ && \
make; \
else \
echo "Unknown TARGET: $(TARGET)"; \
echo "Must be one of: jetson, pi" \
exit 1; \
fi

# Docker
# Builds docker image with viam-cpp-sdk and helpers.
image-base:
docker build -t $(BASE_NAME):$(DOCK_TAG) \
docker build -t $(BASE_NAME):$(BASE_TAG) \
--memory=16g \
--build-arg L4T_TAG=$(L4T_TAG) \
-f ./etc/Dockerfile.base.jetson ./
-f $(BASE_CONFIG) ./

# Builds docker image with viam-csi installed.
image-mod:
docker build -t $(MOD_NAME):$(DOCK_TAG) \
--build-arg BASE_TAG=$(BASE_TAG) \
--build-arg HUB_USER=$(HUB_USER) \
--build-arg BASE_NAME=$(BASE_NAME) \
-f ./etc/Dockerfile.mod ./
--build-arg BASE_IMG=ghcr.io/$(HUB_USER)/$(BASE_NAME):$(BASE_TAG) \
-f $(MOD_CONFIG) ./

# Builds raw L4T docker image with viam-csi appimage.
image-test:
Expand Down
Loading

0 comments on commit 0793a4d

Please sign in to comment.