Skip to content

Commit

Permalink
Update CI generation scripts and configurations. (StoglRobotics#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl authored Mar 23, 2022
1 parent 518f05d commit 2a84136
Show file tree
Hide file tree
Showing 22 changed files with 351 additions and 278 deletions.
22 changes: 21 additions & 1 deletion docs/use-cases/ros_packages/configure_repository.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,24 @@ Configure Repository
=====================
.. _uc-configure-repo:

To be documented...
Setup Repository CI configuration (GitHub)
===========================================

``setup-repository-ci`` script is used, accepting the package name and description as parameters.
The script **has to be executed** from the *main* folder of your package.

.. code-block:: bash
:caption: Usage of script for setting up new packages.
:name: setup-package-ci
setup-repository-ci "repo_name" "repo_namespace" ["first_package" "second_package" ...]
When executing the script, read all output carefully.
If you make any wrong decision or enter incorrect data, use <CTRL>+C keys to terminate the script.

The script can add setup for multiple ROS2 versions.
Simply follow the output.

After a setup is created, you should go through the files and check if they are correct.
Then try to push this to a GitHub-repository and open a PR.
You should then already see new workflows active.
10 changes: 10 additions & 0 deletions scripts/_Team_Defines.bash
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,14 @@ alias setup-robot-description=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/setup-robot-desc
alias ros2_control_setup-hardware-interface-package=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/ros2_control/setup-hardware-interface-package.bash
alias ros2_control_setup-controller-package=$RosTeamWS_FRAMEWORK_SCRIPTS_PATH/ros2_control/setup-controller-package.bash

# Team General aliases and functions
function generate_gif_from_video {

if [ -z "$1" ]; then
print_and_exit "File name has to be defined!"
fi

ffmpeg -i $1 -filter_complex "[0:v] fps=12,scale=w=960:h=-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" $1.gif
}

# END Define aliases for standard functions
13 changes: 13 additions & 0 deletions scripts/setup-ci-config.bash → scripts/setup-repository-ci.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,36 @@ if [[ "$choice" == "yes" ]]; then
CI_FORMAT="ci-format-private"
fi

# File-suffix definitions
CI_ROS_LINT="ci-ros-lint"
CI_COVERAGE="ci-coverage-build"
CI_REUSABLE_INDUSTRIAL_CI="reusable-industrial-ci-with-cache"
CI_REUSABLE_ROS_TOOLING="reusable-ros-tooling-source-build"
PRE_RELEASE="prerelease-check"

CI_ABI_COMPATIBILITY="abi-compatibility"
CI_BINARY_BUILD="binary-build"
CI_SEMI_BINARY_BUILD="semi-binary-build"
CI_SOURCE_BUILD="source-build"
CI_RHEL_BINARY_BUILD="rhel-binary-build"


# Lists for different generation stages
CI_GENERAL_FILES=(
$CI_FORMAT
$CI_ROS_LINT
$CI_COVERAGE
$CI_REUSABLE_INDUSTRIAL_CI
$CI_REUSABLE_ROS_TOOLING
$PRE_RELEASE
)

CI_DISTRIBUTION_FILES=(
$CI_ABI_COMPATIBILITY
$CI_BINARY_BUILD
$CI_SEMI_BINARY_BUILD
$CI_SOURCE_BUILD
$CI_RHEL_BINARY_BUILD
)

read -p "${RAW_TERMINAL_COLOR_BROWN}Name of the default ROS distro?${RAW_TERMINAL_COLOR_NC} [default: rolling] " default_ros_distro
Expand Down
8 changes: 4 additions & 4 deletions templates/package/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -33,13 +33,13 @@ repos:

# Python hooks
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/psf/black
rev: 21.10b0
rev: 21.12b0
hooks:
- id: black
args: ["--line-length=99"]
Expand Down Expand Up @@ -119,7 +119,7 @@ repos:

# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: 0.9.1
rev: 0.10.1
hooks:
- id: doc8
args: ['--max-line-length=100', '--ignore=D001']
Expand Down
17 changes: 17 additions & 0 deletions templates/package/CI-github_abi-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ABI Compatibility Check
on:
pull_request:
branches:
- $branch$

jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: $ROS_DISTRO$
ROS_REPO: main
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
NOT_TEST_BUILD: true
54 changes: 10 additions & 44 deletions templates/package/CI-github_binary-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: $Ros_distro$ Binary Build
# author: Denis Štogl <[email protected]>
# description: 'Build & test all dependencies from released (binary) packages.'

on:
pull_request:
branches:
Expand All @@ -8,49 +11,12 @@ on:
- $branch$
schedule:
# Run every morning to detect flakiness and broken dependencies
- cron: '13 4 * * *'
- cron: '03 1 * * *'

jobs:
$ROS_DISTRO$_binary:
name: $ROS_DISTRO$ binary build
runs-on: ubuntu-latest
strategy:
matrix:
env:
- {ROS_DISTRO: $ROS_DISTRO$, ROS_REPO: main}
- {ROS_DISTRO: $ROS_DISTRO$, ROS_REPO: testing}
env:
UPSTREAM_WORKSPACE: $NAME$-not-released.${{ matrix.env.ROS_DISTRO }}.repos
CCACHE_DIR: ${{ github.workspace }}/.ccache
BASEDIR: ${{ github.workspace }}/.work
CACHE_PREFIX: ${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}
steps:
- uses: actions/checkout@v1
# The target directory cache doesn't include the source directory because
# that comes from the checkout. See "prepare target_ws for cache" task below
- name: cache target_ws
if: ${{ ! matrix.env.CCOV }}
uses: pat-s/[email protected]
with:
path: ${{ env.BASEDIR }}/target_ws
key: target_ws-${{ env.CACHE_PREFIX }}-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}-${{ github.run_id }}
restore-keys: |
target_ws-${{ env.CACHE_PREFIX }}-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}
- name: cache ccache
uses: pat-s/[email protected]
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'
with:
config: ${{toJSON(matrix.env)}}
- 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
binary:
uses: ./.github/workflows/reusable-industrial-ci-with-cache.yml
with:
ros_distro: $ROS_DISTRO$
upstream_workspace: $NAME$-not-released.$ROS_DISTRO$.repos
ref_for_scheduled_build: $branch$
41 changes: 0 additions & 41 deletions templates/package/CI-github_ci-build-coverage.yml

This file was deleted.

32 changes: 0 additions & 32 deletions templates/package/CI-github_ci-build-source.yml

This file was deleted.

72 changes: 0 additions & 72 deletions templates/package/CI-github_ci-build.yml

This file was deleted.

3 changes: 1 addition & 2 deletions templates/package/CI-github_ci-coverage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ jobs:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ env.ROS_DISTRO }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ros-tooling/[email protected]
with:
target-ros2-distro: ${{ env.ROS_DISTRO }}
import-token: ${{ secrets.GITHUB_TOKEN }}
# build all packages listed in the meta package
# build all packages listed in the meta package
package-name:
$PKG_NAME$
vcs-repo-file-url: |
Expand Down
4 changes: 2 additions & 2 deletions templates/package/CI-github_ci-format-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.9.7
- name: Install system hooks
run: sudo apt-get install clang-format-10 cppcheck
run: sudo apt install -qq clang-format-11 cppcheck
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage manual
Expand Down
7 changes: 2 additions & 5 deletions templates/package/CI-github_ci-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ name: Format
on:
workflow_dispatch:
pull_request:
push:
branches:
- $branch$

jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: 3.9.7
- name: Install system hooks
run: sudo apt-get install clang-format-10 cppcheck
run: sudo apt install -qq clang-format-11 cppcheck
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage manual
Loading

0 comments on commit 2a84136

Please sign in to comment.