Skip to content

Commit

Permalink
Merge pull request #2 from johan-olsson-work/proto_workflow
Browse files Browse the repository at this point in the history
continue working on proto workflow
  • Loading branch information
johan-olsson-work authored Aug 22, 2024
2 parents bd5137c + 984d091 commit cb99ea1
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 38 deletions.
143 changes: 111 additions & 32 deletions .github/workflows/ci-cd-acap-runtime-proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,135 @@
name: Proto Build Workflow

on:
# push:
# branches:
# - "add-new-workflow" # Adjust this to match your branch name
# pull_request:
# branches:
# - "add-new-workflow" # Adjust this to match your branch name
workflow_dispatch: # This allows manual triggering
push:
branches:
- "main"
tags:
# semver, e.g. 1.2.0 (does not match 0.1.2)
- "[1-9]+.[0-9]+.[0-9]+"
# semver with prerelease info, e.g. 1.0.2-beta.1 or 1.2.3-rc.10
- "[1-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+"
# do not match prerelease starting w/ 0, e.g. 1.0.2-beta.0 or 1.2.3-rc.01
- "![1-9]+.[0-9]+.[0-9]+-[a-z]+.[0]*"
# semver with date info, e.g. 1.0.2-20221125
- "[1-9]+.[0-9]+.[0-9]+-[0-9]+"
# do not match date starting w/ 0, e.g. 1.0.2-01232023
- "![1-9]+.[0-9]+.[0-9]+-[0]*"
pull_request:
branches:
- "main"
workflow_dispatch:

jobs:
build_proto:
build_proto_image:
name: Build Proto Image
runs-on: self-hosted # Use the self-hosted runner
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create image metadata
id: meta
uses: ./.github/actions/metadata-action
with:
repository: axisecp/acap-runtime
get_version: "true"

- name: Check permissions
run: |
whoami
id
ls -l /var/lib/apt/lists/
- name: Check system info
run: |
uname -a
arch
- name: List installed packages
run: |
dpkg -l
- name: Check Docker version
run: |
docker version
docker info
- name: Build Proto image
uses: docker/build-push-action@v5
uses: ./.github/actions/docker-build-push-action
with:
context: .
file: ./Dockerfile.proto
dockerfile: ./Dockerfile.proto
push: false
load: true
tags: proto-image:latest
tags: axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles
use_qemu: true

# Optional: Print Docker images for verification
- name: List Docker images
run: docker images

# Uncomment and modify the following steps as needed
- name: Extract proto files
run: |
container_id=$(docker create axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles)
docker cp $container_id:/build/param/proto_utils ./proto_utils_param
docker cp $container_id:/build/vdo/proto_utils ./proto_utils_vdo
docker cp $container_id:/build/tf/proto_utils ./proto_utils_tf
docker rm $container_id
- name: Verify proto files
run: |
echo "Verifying proto files..."
# - name: Save Proto image
# run: |
# docker save proto-image:latest > proto-image.tar
# Check param proto files
if [ "$(ls -A ./proto_utils_param)" ]; then
echo "param proto files found:"
ls -l ./proto_utils_param
else
echo "Error: param proto files are missing"
exit 1
fi
# - name: Upload Proto image artifact
# uses: actions/upload-artifact@v4
# with:
# name: proto-image
# path: proto-image.tar
# Check vdo proto files
if [ "$(ls -A ./proto_utils_vdo)" ]; then
echo "vdo proto files found:"
ls -l ./proto_utils_vdo
else
echo "Error: vdo proto files are missing"
exit 1
fi
# Check tf proto files
if [ "$(ls -A ./proto_utils_tf)" ]; then
echo "tf proto files found:"
ls -l ./proto_utils_tf
else
echo "Error: tf proto files are missing"
exit 1
fi
echo "All proto files verified successfully"
- name: Upload proto files artifacts
uses: actions/upload-artifact@v4
with:
name: proto-files
path: |
./proto_utils_param
./proto_utils_vdo
./proto_utils_tf
- name: Push Proto image
if: success() && github.event_name != 'pull_request'
uses: ./.github/actions/docker-build-push-action
with:
dockerfile: ./Dockerfile.proto
push: false # true
tags: axisecp/acap-runtime:${{ steps.meta.outputs.version }}-protofiles
registry_user: ${{ secrets.ECOSYSTEM_SERVICE_USER_DOCKER_HUB }}
registry_token: ${{ secrets.ECOSYSTEM_ACCESS_TOKEN_DOCKER_HUB }}

# - name: Run tests on Proto image
# run: |
# # Add your test commands here

# - name: Clean up
# if: always()
# run: |
# docker image prune -af
- name: Clean up
if: always()
run: |
docker image prune -af
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: Lint codebase

on:
push:
pull_request:
# push:
# pull_request:
workflow_dispatch:

jobs:
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,3 @@ COPY apis/wrappers/vdo_proto_utils.py ./proto_utils
WORKDIR /build/param
COPY apis/keyvaluestore.proto ./
RUN mkdir ./proto_utils && python3 -m grpc_tools.protoc -I . --python_out=./proto_utils --grpc_python_out=./proto_utils keyvaluestore.proto

0 comments on commit cb99ea1

Please sign in to comment.