-
Notifications
You must be signed in to change notification settings - Fork 9
136 lines (131 loc) · 4.55 KB
/
docker-image-creator.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
name: Container image creation
# author: "Guillem Gari <[email protected]>"
# description: |
# This workflow builds and pushes a container image to a private registry,
# then performs a simple usage test. It's triggered on pushes to ros2*,
# branches, specific tags, pull requests, or manually.
# Key features:
# - Runs on self-hosted Kubernetes runners
# - Builds and pushes Docker image on changes in monitored paths
# - Performs a non-crash test using the built image
# - Supports multiple ROS distributions (Humble, Iron, Rolling, etc.)
# - Uses dynamic versioning based on Git context
on:
push:
branches:
- ros2*
tags:
- '(humble|iron|rolling|melodic|noetic|jazzy)-[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?'
- '[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?'
pull_request:
types: [opened, reopened, synchronize]
branches:
- ros2*
workflow_dispatch:
env:
MONITORED_PATHS: >-
daly_bms
setup-container
setup-container.yaml
jobs:
build:
name: Build and upload image
runs-on:
- self-hosted
- internal-robotnik
- linux
- kubernetes
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/check-changes
id: check_changes
with:
monitored_paths: ${{ env.MONITORED_PATHS }}
- uses: ./.github/actions/set-version
id: set_version
with:
github_ref: ${{ github.ref }}
github_event_name: ${{ github.event_name }}
github_head_ref: ${{ github.head_ref }}
github_base_ref: ${{ github.base_ref }}
github_sha: ${{ github.sha }}
- name: Login to Robotnik Registry
if: steps.check_changes.outputs.has_changes == 'true'
uses: docker/login-action@v3
with:
registry: registry.robotnik.ws
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Configure docker files
if: steps.check_changes.outputs.has_changes == 'true'
run: |
yq e '.images.version = "${{ steps.set_version.outputs.version }}"' -i setup-container.yaml
setup-container/scripts/setup.sh
- name: Build image and push
if: steps.check_changes.outputs.has_changes == 'true'
run: |
cd container/cd
docker compose build --push
serial-void-non-crash-test:
name: Void serial non crash test
needs: [build]
runs-on:
- self-hosted
- internal-robotnik
- linux
- kubernetes
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/check-changes
id: check_changes
with:
monitored_paths: ${{ env.MONITORED_PATHS }}
- uses: ./.github/actions/set-version
id: set_version
with:
github_ref: ${{ github.ref }}
github_event_name: ${{ github.event_name }}
github_head_ref: ${{ github.head_ref }}
github_base_ref: ${{ github.base_ref }}
github_sha: ${{ github.sha }}
- name: Login to Robotnik Registry
if: steps.check_changes.outputs.has_changes == 'true'
uses: docker/login-action@v3
with:
registry: registry.robotnik.ws
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Configure docker files
if: steps.check_changes.outputs.has_changes == 'true'
run: |
yq e '.images.version = "${{ steps.set_version.outputs.version }}"' -i setup-container.yaml
yq e '.images.sites.local = "robotnik"' -i setup-container.yaml
setup-container/scripts/setup.sh
- name: Pull image
if: steps.check_changes.outputs.has_changes == 'true'
run: |
cd container
cd debug
docker compose pull
- name: Void run for 15 seconds
if: steps.check_changes.outputs.has_changes == 'true'
run: |
cd container
cd debug
docker compose up -d
sleep 1
docker compose exec bms sudo apt update
docker compose exec bms sudo apt install -y socat
docker compose exec --detach bms /usr/bin/socat -d -d pty,link=/tmp/vserial1,raw,echo=0 pty,link=/tmp/vserial2,raw,echo=0
timeout 15 docker compose exec bms /bin/bash -c 'ROBOT_BMS_PORT=/tmp/vserial1 STARTUP_TYPE=launch ros_launcher.sh' || exit_code=$?
if [[ $exit_code -eq 124 ]]
then
echo "No crash, test passed"
exit 0
fi
exit 1