-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreusable-industrial-ci-with-cache.yml
More file actions
159 lines (155 loc) · 7.23 KB
/
Copy pathreusable-industrial-ci-with-cache.yml
File metadata and controls
159 lines (155 loc) · 7.23 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Reusable industrial_ci Workflow with Cache
# Reusable action to simplify dealing with ROS/ROS2 industrial_ci builds with cache
# author: Denis Štogl <denis@stoglrobotics.de>
on:
workflow_call:
inputs:
ref_for_scheduled_build:
description: 'Reference on which the repo should be checkout for scheduled build. Usually is this name of a branch or a tag.'
default: ''
required: false
type: string
upstream_workspace:
description: 'UPSTREAM_WORKSPACE variable for industrial_ci. Usually path to local .repos file.'
required: false
type: string
target_workspace:
description: 'TARGET_WORKSPACE variable for industrial_ci. If not provided, defaults to the current repo.'
required: false
default: ""
type: string
downstream_workspace:
description: 'DOWNSTREAM_WORKSPACE variable for industrial_ci. If set, downstream packages will be built and tested against this repo'
required: false
default: ''
type: string
not_test_downstream:
description: 'NOT_TEST_DOWNSTREAM variable for industrial_ci. If true, downstream packages will not be tested'
default: false
type: boolean
not_test_build:
description: 'NOT_TEST_BUILD variable for industrial_ci. If true, tests in build space will not be run.'
default: false
type: boolean
ros_distro:
description: 'ROS_DISTRO variable for industrial_ci'
required: true
type: string
ros_repo:
description: 'ROS_REPO to run for industrial_ci. Possible values: "main", "testing"'
default: 'main'
required: false
type: string
os_code_name:
description: 'OS_CODE_NAME variable for industrial_ci'
default: ''
required: false
type: string
rosdep_skip_keys:
description: 'ROSDEP_SKIP_KEYS variable for industrial_ci'
default: ''
required: false
type: string
ccache_dir:
description: 'Local path to store cache (from "github.workspace"). For standard industrial_ci configuration do not have to be changed'
default: '.ccache'
required: false
type: string
basedir:
description: 'Local path to workspace base directory to cache (from "github.workspace"). For standard industrial_ci configuration do not have to be changed'
default: '.work'
required: false
type: string
additional_debs:
description: 'Additional debs to install for the build'
default: ''
required: false
type: string
c_compiler:
description: 'C-compiler; set to clang to use clang as the C compiler'
default: ''
required: false
type: string
cxx_compiler:
description: 'C++-compiler; set to clang++ to use clang as the C compiler'
default: ''
required: false
type: string
jobs:
reusable_industrial_ci_with_cache:
name: ${{ inputs.ros_distro }} ${{ inputs.ros_repo }} ${{ inputs.os_code_name }}
runs-on: ubuntu-latest
env:
CCACHE_DIR: ${{ github.workspace }}/${{ inputs.ccache_dir }}
BASEDIR: ${{ github.workspace }}/${{ inputs.basedir }}
CACHE_PREFIX: ${{ inputs.ros_distro }}-${{ inputs.upstream_workspace }}-${{ inputs.ros_repo }}-${{ github.job }}
steps:
- name: Checkout ${{ inputs.ref }} when build is not scheduled
if: ${{ github.event_name != 'schedule' }}
uses: actions/checkout@v4
- name: Checkout ${{ inputs.ref }} on scheduled build
if: ${{ github.event_name == 'schedule' }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref_for_scheduled_build }}
- name: cache ccache
uses: pat-s/always-upload-cache@v3.0.11
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}-${{ github.run_id }}
restore-keys: |
ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}
ccache-${{ env.CACHE_PREFIX }}
- uses: 'ros-industrial/industrial_ci@master'
env:
UPSTREAM_WORKSPACE: ${{ inputs.upstream_workspace }}
TARGET_WORKSPACE: ${{ inputs.target_workspace }}
NOT_TEST_BUILD: ${{ inputs.not_test_build }}
DOWNSTREAM_WORKSPACE: ${{ inputs.downstream_workspace }}
NOT_TEST_DOWNSTREAM: ${{ inputs.not_test_downstream }}
DOCKER_IMAGE: ghcr.io/sloretz/ros:${{ inputs.ros_distro }}-ros-base
ROS_REPO: ${{ inputs.ros_repo }}
OS_CODE_NAME: ${{ inputs.os_code_name }}
ROSDEP_SKIP_KEYS: ${{ inputs.rosdep_skip_keys }}
ADDITIONAL_DEBS: ${{ inputs.additional_debs }}
CC: ${{ inputs.c_compiler }}
CXX: ${{ inputs.cxx_compiler }}
CMAKE_ARGS: -DCMAKE_CXX_FLAGS="-isystem /opt/ros/${{ inputs.ros_distro }}/include"
id: ici
- name: Download issue template for target failure # Has to be a local file
if: ${{ always() && steps.ici.outcome == 'failure' && github.event_name == 'schedule' }}
run:
wget https://raw.githubusercontent.com/ros-controls/ros2_control_ci/master/.github/issue_template_failed_ci.md -O .github/issue_template_failed_ci.md
- name: Download issue template for downstream failure # Has to be a local file
if: ${{ always() && steps.ici.outcome == 'failure' && github.event_name == 'schedule' }}
run:
wget https://raw.githubusercontent.com/ros-controls/ros2_control_ci/master/.github/issue_template_failed_ci_downstream.md -O .github/issue_template_failed_ci_downstream.md
- uses: JasonEtco/create-an-issue@v2
# `make` and so `colcon build` returns 2 on errors, while `colcon test-result` returns 1 on
# when any test failed.
if: ${{ always() && (steps.ici.outputs.build_target_workspace == '2' || steps.ici.outputs.target_test_results == '1') && github.event_name == 'schedule'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTION_NAME: ${{ inputs.ros_distro }}/${{ inputs.ros_repo }}
REF: ${{ inputs.ref_for_scheduled_build }}
URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/issue_template_failed_ci.md
- uses: JasonEtco/create-an-issue@v2
if: ${{ always() && (steps.ici.outputs.build_downstream_workspace == '2' || steps.ici.outputs.downstream_test_results == '1') && github.event_name == 'schedule'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTION_NAME: ${{ inputs.ros_distro }}/${{ inputs.ros_repo }}
REF: ${{ inputs.ref_for_scheduled_build }}
URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/issue_template_failed_ci_downstream.md
- name: prepare target_ws for cache
if: ${{ always() && ! matrix.env.CCOV }}
run: |
du -sh ${{ env.BASEDIR }}/target_ws
sudo find ${{ env.BASEDIR }}/target_ws -wholename '*/test_results/*' -delete
sudo rm -rf ${{ env.BASEDIR }}/target_ws/src
du -sh ${{ env.BASEDIR }}/target_ws