Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hashemmm96 committed Nov 4, 2024
1 parent 537743d commit b726ac0
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 93 deletions.
54 changes: 54 additions & 0 deletions .github/actions/build-firmware/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Firmware
description: Build the Rover's firmware

outputs:
release:
description: release zip file
value: ${{ steps.release.outputs.release }}

runs:
using: composite
steps:
- name: Cache python venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('requirements.txt') }}

- name: Cache meson subprojects
uses: actions/cache@v4
with:
path: subprojects
key: meson-${{ runner.os }}-${{ hashFiles('subprojects/*.wrap') }}-${{ hashFiles('subprojects/packagefiles/**') }}

# Will run pip
- name: Bootstrap build
run: ./scripts/bootstrap.sh
shell: bash

- name: Activate python venv
run: |
source .venv/bin/activate
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
shell: bash

- name: Build source
run: meson compile -C build
shell: bash

- name: Run tests
run: meson test -v -C build
shell: bash

- name: Check source
run: meson compile -C build check
shell: bash

- name: Build documentation
run: meson compile -C build docs
shell: bash

- run: echo "release=$(ls build/rover-release*.zip)" >> $GITHUB_OUTPUT
id: release
shell: bash
45 changes: 45 additions & 0 deletions .github/actions/build-gateway/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build ROS gateway
description: Build the Rover's ROS gateway

inputs:
push:
description: push the docker container to GHCR
required: false

ros_distro:
description: target ROS distro name
required: false
default: ''

tags:
description: docker container tags, space separated
default: ''

runs:
using: composite
steps:
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}

# Set up builder outside of script to use this action's built-in caching
- uses: docker/setup-buildx-action@v3
id: builder
with:
platforms: linux/amd64,linux/arm64

- run: |
echo "PUSH=${{ inputs.push }}" >> "$GITHUB_ENV"
shell: bash
if: ${{ inputs.push }}
- name: Build docker image
run: ./scripts/build-ros-gateway.sh
shell: bash
env:
ROS_DISTRO: ${{ inputs.ros_distro }}
PLATFORMS: ${{ steps.builder.outputs.platforms }}
DOCKER_BUILDER: ${{ steps.builder.outputs.name }}
VERSION_TAGS: ${{ inputs.tags }}
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build

on:
push:
branches: ["main"]
pull_request:

jobs:
firmware:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Build firmware
uses: ./.github/actions/build-firmware

ros-gateway:
strategy:
matrix:
ros_distro: [humble, jazzy]

runs-on: ubuntu-24.04

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Build ROS gateway
uses: ./.github/actions/build-gateway
with:
ros_distro: ${{ matrix.ros_distro }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81 changes: 0 additions & 81 deletions .github/workflows/ci.yaml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

permissions:
contents: write

jobs:
firmware:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Build firmware
id: build
uses: ./.github/actions/build-firmware

- name: Release
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.build.outputs.release }}
fail_on_unmatched_files: true
generate_release_notes: true

ros-gateway:
strategy:
matrix:
ros_distro: [humble, jazzy]

runs-on: ubuntu-24.04

permissions:
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Build ROS gateway
uses: ./.github/actions/build-gateway
with:
push: true
ros_distro: ${{ matrix.ros_distro }}
tags: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 17 additions & 12 deletions scripts/build-ros-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ args:
--push push containers
default env vars:
ROS_DISTRO=jazzy
PLATFORMS=linux/amd64,linux/arm64
PACKAGE_BASENAME=ghcr.io/canedudev/rover/ros-gateway
BUILDER=ced-rover-builder
BUILD_CONTEXT=.
DOCKERFILE=./ros-gateway/Dockerfile
VERSION_TAG=latest
ROS_DISTRO=jazzy ROS distro codename to build
PLATFORMS=linux/amd64,linux/arm64 Target platforms
PACKAGE_BASENAME=ghcr.io/canedudev/rover/ros-gateway Docker container base name
BUILDER=ced-rover-builder Docker buildx builder
BUILD_CONTEXT=. Docker build context
DOCKERFILE=./ros-gateway/Dockerfile Path to dockerfile
VERSION_TAGS= Space separated tags
EOF

}
Expand Down Expand Up @@ -57,10 +57,15 @@ ROS_DISTRO="${ROS_DISTRO:-jazzy}"
BUILDER="${BUILDER:-ced-rover-builder}"
BUILD_CONTEXT="${BUILD_CONTEXT:-.}"
DOCKERFILE="${DOCKERFILE:-ros-gateway/Dockerfile}"
VERSION_TAG="${VERSION_TAG:-latest}"

PACKAGE="${PACKAGE_BASENAME}-${ROS_DISTRO}"
TAG="${PACKAGE}:${VERSION_TAG}"
VERSION_TAGS="${VERSION_TAGS:-}"

if [[ -n ${VERSION_TAGS} ]]; then
TAG_ARGS=("--tag" "${PACKAGE}:latest")
for tag in ${VERSION_TAGS}; do
TAG_ARGS+=("--tag" "${PACKAGE}:${tag}")
done
fi

CI_ARGS=()
if [[ -n ${CI} ]]; then
Expand All @@ -87,5 +92,5 @@ docker buildx --builder "${BUILDER}" build \
-f "${DOCKERFILE}" \
--platform "${PLATFORMS}" \
--build-arg ROS_DISTRO="${ROS_DISTRO}" \
--tag "${TAG}" \
"${OUTPUT_ARGS[@]}" "${CI_ARGS[@]}" "${BUILD_CONTEXT}"
"${TAG_ARGS[@]}" "${OUTPUT_ARGS[@]}" "${CI_ARGS[@]}" \
"${BUILD_CONTEXT}"

0 comments on commit b726ac0

Please sign in to comment.