Skip to content

Commit

Permalink
Fix test + Husarion 2024 + pre-commit (#100)
Browse files Browse the repository at this point in the history
* Fix test + Husarion 2024 + pre-commit

* fix camera

* add delayed controller launch

* spell fix

* revert black string processing

* Jakub suggestions

* next suggestions

* spell fix

* readme

* test_utils

* Add

* Update rosbot_gazebo/test/test_utils.py

* Update .github/workflows/bump_version.yaml

* Update rosbot_gazebo/test/test_utils.py

Co-authored-by: Jakub Delicat <[email protected]>

---------

Co-authored-by: Jakub Delicat <[email protected]>
  • Loading branch information
rafal-gorecki and delihus authored Jan 31, 2024
1 parent b8f23ed commit 2bee7c8
Show file tree
Hide file tree
Showing 44 changed files with 511 additions and 516 deletions.
110 changes: 55 additions & 55 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
---
name: Bump version
on:
workflow_dispatch:
inputs:
name:
description: Version to bump (major, minor, patch)
default: patch
required: true
pull_request:
branches: humble
types: [closed]
workflow_dispatch:
inputs:
name:
description: Version to bump (major, minor, patch)
default: patch
required: true
pull_request:
branches: humble
types: [closed]

jobs:
industrial_ci:
name: Industrial CI
uses: ./.github/workflows/industrial_ci.yaml
industrial_ci:
name: Industrial CI
uses: ./.github/workflows/industrial_ci.yaml

get-bump:
get-bump:
name: Get version bump
runs-on: ubuntu-latest
needs: industrial_ci
outputs:
bump: ${{ env.BUMP }}
steps:
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
name: Get version bump
runs-on: ubuntu-latest
needs: industrial_ci
outputs:
bump: ${{ env.BUMP }}
steps:
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
name: Get version bump
id: get-version-bump
uses: husarion-ci/[email protected]
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
run: echo "BUMP=${{ steps.get-version-bump.outputs.bump }}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "BUMP=${{ github.event.inputs.name }}" >> $GITHUB_ENV
id: get-version-bump
uses: husarion-ci/[email protected]
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
run: echo "BUMP=${{ steps.get-version-bump.outputs.bump }}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "BUMP=${{ github.event.inputs.name }}" >> $GITHUB_ENV

catkin-release:
name: Bump version
runs-on: ubuntu-latest
needs: get-bump
outputs:
new_version: ${{ steps.catkin-release.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Catkin release
id: catkin-release
uses: husarion-ci/[email protected]
with:
bump: ${{ needs.get-bump.outputs.bump }}
github_token: ${{ secrets.GH_PAT }}
git_user: action-bot
git_email: [email protected]
catkin-release:
name: Bump version
runs-on: ubuntu-latest
needs: get-bump
outputs:
new_version: ${{ steps.catkin-release.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Catkin release
id: catkin-release
uses: husarion-ci/[email protected]
with:
bump: ${{ needs.get-bump.outputs.bump }}
github_token: ${{ secrets.GH_PAT }}
git_user: action-bot
git_email: [email protected]

build-and-push-docker-image:
name: Create new docker image
runs-on: ubuntu-latest
needs: catkin-release
steps:
- name: trigger the endpoint
run: >
curl -X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.GH_PAT }}"
https://api.github.com/repos/husarion/rosbot-docker/dispatches
-d '{"event_type":"ros-package-update"}'
build-docker-image:
name: Trigger rosbot-docker to build image
runs-on: ubuntu-latest
needs: catkin-release
steps:
- name: trigger the endpoint
run: >
curl -X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.GH_PAT }}"
https://api.github.com/repos/husarion/rosbot-docker/dispatches
-d '{"event_type":"ros-package-update"}'
130 changes: 59 additions & 71 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,70 @@
---
name: Industrial CI
on:
workflow_call:
workflow_dispatch:
push:
workflow_call:
workflow_dispatch:
push:

jobs:
black:
name: Black
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Black
uses: psf/[email protected]
with:
options: --line-length=99
black:
name: Black
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Black
uses: psf/[email protected]
with:
options: --line-length=99

spellcheck:
name: Spellcheck
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Spellcheck
uses: rojopolis/[email protected]
spellcheck:
name: Spellcheck
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Spellcheck
uses: rojopolis/[email protected]

ros_industrial_ci:
name: ROS Industrial CI
runs-on: ubuntu-22.04
timeout-minutes: 30
needs:
- black
- spellcheck
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
steps:
- name: Checkout
uses: actions/checkout@v3
ros_industrial_ci:
name: ROS Industrial CI
runs-on: ubuntu-22.04
timeout-minutes: 30
needs:
- black
- spellcheck
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Act + Docker fix
run: |
sudo chown runner:docker /var/run/docker.sock
- name: Act + Docker fix
run: |
sudo chown runner:docker /var/run/docker.sock
- name: Copy to src
run: |
mkdir -p src
find . -maxdepth 1 -not -name src -not -name . -exec mv {} src/ \;
- name: Setup ROS2 Workspace and Clone Repositories
run: |
mkdir -p src
find . -maxdepth 1 -not -name src -not -name . -exec mv {} src/ \;
python3 -m pip install -U vcstool
vcs import src < src/rosbot/rosbot_hardware.repos
vcs import src < src/rosbot/rosbot_simulation.repos
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers
- name: Clone installation requirements
shell: bash
run: |
python3 -m pip install -U vcstool
vcs import src < src/rosbot/rosbot_hardware.repos &&
vcs import src < src/rosbot/rosbot_simulation.repos
# Package micro_ros_msgs does not have industrial ci and tests does not pass.
# For more information see https://github.com/micro-ROS/micro_ros_msgs/issues/7
- name: Remove tests from micro_ros_msgs
shell: bash
run: sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

- name: Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
shell: bash
run: |
cp -r src/ros2_controllers/diff_drive_controller src/
cp -r src/ros2_controllers/imu_sensor_broadcaster src/
rm -rf src/ros2_controllers
- name: Remove ign_ros2_control demo and tests
shell: bash
run: rm -rf src/gazebosim/gz_ros2_control/ign_ros2_control_demos src/gazebosim/gz_ros2_control/gz_ros2_control_tests

# Package micro_ros_msgs does not have industrial ci and tests does not pass.
# For more information see https://github.com/micro-ROS/micro_ros_msgs/issues/7
- name: Remove tests from micro_ros_msgs
shell: bash
run: sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i

- name: Running ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
DOCKER_IMAGE: ros:${{matrix.ROS_DISTRO}}-ros-base
IMMEDIATE_TEST_OUTPUT: true
- name: Running ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
DOCKER_IMAGE: ros:${{matrix.ROS_DISTRO}}-ros-base
IMMEDIATE_TEST_OUTPUT: true
98 changes: 50 additions & 48 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-xml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: name-tests-test
files: ^.*\/test\/.*$
args: [--pytest-test-first]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-xml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: name-tests-test
files: ^.*\/test\/.*$
args: [--pytest-test-first]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell *
language: python
types: [text]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell *
language: python
types: [text]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^.github|./\.yaml
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^(?!.*compose)(?!.*ekf\.yaml$).*$
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100']

- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
args: ["--line-length=99", "--experimental-string-processing"]
# Please keep this version until --experimental-string-processing come back or will be available by default
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
args: [--line-length=99, --experimental-string-processing]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["--ignore=E501,W503"] # ignore too long line and line break before binary operator,
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--ignore=E501,W503'] # ignore too long line and line break before binary operator,
# black checks it

- repo: local
hooks:
- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
entry: ament_lint_cmake
language: system
files: CMakeLists\.txt$

- repo: local
hooks:
- repo: local
hooks:
- id: ament_copyright
name: ament_copyright
description: Check if copyright notice is available in all files.
Expand All @@ -63,9 +65,9 @@ repos:
language: system

# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
args: ['--max-line-length=100', '--ignore=D001']
exclude: ^.*\/CHANGELOG\.rst/.*$
- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
args: [--max-line-length=100, --ignore=D001]
exclude: ^.*\/CHANGELOG\.rst/.*$
Loading

0 comments on commit 2bee7c8

Please sign in to comment.