Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #3

Merged
merged 7 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
76 changes: 76 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# This was copied over from the moveit_studio repository.
BasedOnStyle: Google
ColumnLimit: 120
MaxEmptyLinesToKeep: 1
SortIncludes: false

Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
NamespaceIndentation: None
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false

AlignEscapedNewlinesLeft: false
AlignTrailingComments: true

AllowAllParametersOfDeclarationOnNextLine: false
ExperimentalAutoDetectBinPacking: false
ObjCSpaceBeforeProtocolList: true
Cpp11BracedListStyle: false

AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortCaseLabelsOnASingleLine: false

AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true

BinPackParameters: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true

PenaltyExcessCharacter: 50
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 1000
PenaltyBreakFirstLessLess: 10
PenaltyBreakString: 100
PenaltyReturnTypeOnItsOwnLine: 50

SpacesBeforeTrailingComments: 2
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
...
57 changes: 57 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# This was copied over from the moveit_studio repository.
#
# TODO(henningkayser): Re-enable performance-unnecessary-value-param once #214 is resolved
Checks: '-*,
performance-*,
-performance-unnecessary-value-param,
llvm-namespace-comment,
modernize-redundant-void-arg,
modernize-use-nullptr,
modernize-use-default,
modernize-use-override,
modernize-loop-convert,
readability-braces-around-statements,
readability-named-parameter,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-simplify-boolean-expr,
readability-container-size-empty,
readability-identifier-naming,
'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
CheckOptions:
- key: llvm-namespace-comment.ShortNamespaceLines
value: '10'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '2'
- key: readability-braces-around-statements.ShortStatementLines
value: '2'
# type names
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
# method names
- key: readability-identifier-naming.MethodCase
value: camelBack
# variable names
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ClassMemberSuffix
value: '_'
# const static, constexpr or global variables are camelBack (we write them as kMyConstant)
- key: readability-identifier-naming.ConstexprVariableCase
value: camelBack
- key: readability-identifier-naming.StaticConstantCase
value: camelBack
- key: readability-identifier-naming.ClassConstantCase
value: camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: camelBack
...
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
# Run if someone manually presses the button in the GitHub Actions UI
workflow_dispatch:
# Run when a PR is opened or updated
pull_request:
# Run when a commit is pushed to main
push:
branches:
- main

permissions:
# Allow reading the source code
contents: read
# Allow writing built containers to GitHub Package Registry
packages: write

jobs:
build-ws:
name: Build colcon workspace
runs-on: ubuntu-24.04
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

# Log into GitHub Container Registry so we can push an image
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build the Dockerfile and push the image to the private GitHub Container Registry on this repo
- name: Build workspace
uses: docker/build-push-action@v4
with:
context: .
# run_id is unique to a particular run of this workflow so shouldn't clobber
tags: ghcr.io/picknikrobotics/fuse:${{ github.run_id }}
push: true
# This project is small enough that caching to GitHub Actions should be fine (it has a 10GB cache limit)
cache-to: type=gha,mode=max
cache-from: type=gha

test-ws:
name: Test colcon workspace
needs:
# Ensure the test job runs after the build job finishes instead of attempting to run in parallel
- build-ws
runs-on: ubuntu-24.04
container:
# Run on the Docker image we tagged and pushed to a private repo in the job above
image: ghcr.io/picknikrobotics/fuse:${{ github.run_id }}
steps:
- name: Unit test workspace
run: |
. /opt/ros/rolling/setup.sh
. /colcon_ws/install/local_setup.sh
colcon test --event-handlers console_direct+ --retest-until-pass 3
working-directory: /colcon_ws

# `colcon test` does not actually error on failure - run `colcon test-result` to generate a summary and an error code.
- name: Display colcon test results
# Run this step even if a previous step failed
if: always()
run: colcon test-result --verbose
working-directory: /colcon_ws
29 changes: 29 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# see https://github.com/pre-commit/action

name: pre-commit

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
pre-commit:
name: Format
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install clang-format-18
run: sudo apt-get install clang-format-18
- uses: pre-commit/[email protected]
id: precommit
- name: Upload pre-commit changes
if: failure() && steps.precommit.outcome == 'failure'
uses: rhaschke/upload-git-patch-action@main
with:
name: pre-commit
15 changes: 15 additions & 0 deletions .github/workflows/ros2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ros2

on: [push, pull_request]

jobs:
industrial_ci:
strategy:
matrix:
env:
- {ROS_DISTRO: rolling, ROS_REPO: main}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: 'ros-industrial/industrial_ci@master'
env: ${{matrix.env}}
83 changes: 83 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
args: ["--unsafe"] # Fixes errors parsing custom YAML constructors like ur_description's !degrees
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: fix-byte-order-marker

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|m|proto|vert)$
# -i arg is included by default by the hook
args: ["-fallback-style=none"]

- repo: https://github.com/adrienverge/yamllint
rev: v1.27.1
hooks:
- id: yamllint
args:
[
"--no-warnings",
"--config-data",
"{extends: default, rules: {line-length: disable, braces: {max-spaces-inside: 1}}}",
]
types: [text]
files: \.(yml|yaml)$

- repo: https://github.com/tcort/markdown-link-check
rev: v3.12.2
hooks:
- id: markdown-link-check
args:
- "-c"
- "markdown-link-check-config.json"

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint
args:
- "--disabled-codes=C0301" # Disable Line too long lint
- "--suppress-decorations"

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
# Use Prettier to lint XML files because, well.. its rules are prettier than most linters, as the name implies.
# Also we use it in the UI, so it's familiar.
- id: prettier
additional_dependencies:
- "[email protected]"
- "@prettier/[email protected]"
files: \.(xml|xacro)$
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Docker setup that's used for CI.

FROM osrf/ros:rolling-desktop-full

# Install external packages.
# hadolint ignore=DL3008
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
clang-tidy \
# use cyclonedds instead of fastdds
ros-rolling-rmw-cyclonedds-cpp

# Create the colcon ws. For now, copy the source files into the workspace
# so that we don't have to deal with cloning this repo, which is private.
WORKDIR /colcon_ws/src/fuse
COPY . .
WORKDIR /colcon_ws
# hadolint ignore=SC1091
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get upgrade -y && \
. /opt/ros/rolling/setup.sh && \
rosdep install --from-paths src -y --ignore-src && \
colcon build --mixin compile-commands coverage-gcc coverage-pytest

# Set up final environment and entrypoint.
ENV RMW_IMPLEMENTATION rmw_cyclonedds_cpp
ENV CYCLONEDDS_URI /root/.ros/cyclonedds.xml
COPY dds/cyclonedds_local.xml $CYCLONEDDS_URI
COPY .clang-tidy /colcon_ws
COPY entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
RUN echo "source /entrypoint.sh" >> ~/.bashrc

ENV SHELL /bin/bash
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ tailorTestPipeline(
source_branch: 'rolling',
// Docker registry where test image is stored
docker_registry: 'https://084758475884.dkr.ecr.us-east-1.amazonaws.com/locus-tailor'
)
)
Loading
Loading