Skip to content

Commit e913acb

Browse files
authored
Add python linter to CI check (#18)
* Add python linter to CI check Signed-off-by: jparisu <javierparis@eprosima.com> * refactor configurations in workflows Signed-off-by: jparisu <javierparis@eprosima.com> * remove test file Signed-off-by: jparisu <javierparis@eprosima.com> Signed-off-by: jparisu <javierparis@eprosima.com>
1 parent 2775018 commit e913acb

9 files changed

Lines changed: 60 additions & 10 deletions

File tree

.github/actions/install-python-packages/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ runs:
1919
setuptools \
2020
gcovr==5.0 \
2121
pyyaml \
22-
jsonschema
22+
jsonschema \
23+
flake8 \
24+
flake8-quotes
2325
shell: bash

.github/workflows/build_dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676

7777
- name: Fetch repositories
7878
run: |
79-
vcs import src < src/dev-utils/.github/workflows/ci.repos
79+
vcs import src < src/dev-utils/.github/workflows/configurations/ci.repos
8080
cd src/fastdds && git checkout ${{ inputs.fastdds_branch }} && cd ../..
8181
8282
- name: Build workspace
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
max-line-length = 99
3+
max-doc-length = 300
4+
statistics = True
5+
max-complexity = 10
6+
count = True
File renamed without changes.

.github/workflows/test.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ jobs:
105105

106106
- name: Build workspace
107107
run: |
108-
cat src/dev-utils/.github/workflows/coverage_colcon.meta
108+
cat src/dev-utils/.github/workflows/configurations/coverage_colcon.meta
109109
source /home/runner/work/fastdds/install/setup.bash
110110
colcon build \
111111
--event-handlers=console_direct+ \
112-
--metas src/dev-utils/.github/workflows/coverage_colcon.meta \
112+
--metas src/dev-utils/.github/workflows/configurations/coverage_colcon.meta \
113113
--mixin coverage-gcc asan-gcc
114114
115115
- name: Run tests
@@ -203,7 +203,7 @@ jobs:
203203
source /home/runner/work/fastdds/install/setup.bash
204204
colcon build \
205205
--event-handlers=console_direct+ \
206-
--metas src/dev-utils/.github/workflows/asan_colcon.meta
206+
--metas src/dev-utils/.github/workflows/configurations/asan_colcon.meta
207207
208208
- name: Run tests
209209
run: |
@@ -270,7 +270,7 @@ jobs:
270270
source /home/runner/work/fastdds/install/setup.bash
271271
colcon build \
272272
--event-handlers=console_direct+ \
273-
--metas src/dev-utils/.github/workflows/tsan_colcon.meta
273+
--metas src/dev-utils/.github/workflows/configurations/tsan_colcon.meta
274274
275275
- name: Run tests
276276
run: |
@@ -490,11 +490,11 @@ jobs:
490490

491491
- name: Build workspace
492492
run: |
493-
cat src/dev-utils/.github/workflows/coverage_colcon.meta
493+
cat src/dev-utils/.github/workflows/configurations/coverage_colcon.meta
494494
source /home/runner/work/fastdds/install/setup.bash
495495
colcon build \
496496
--event-handlers=console_direct+ \
497-
--metas src/dev-utils/.github/workflows/coverage_colcon.meta \
497+
--metas src/dev-utils/.github/workflows/configurations/coverage_colcon.meta \
498498
--mixin coverage-gcc asan-gcc
499499
500500
- name: Run tests
@@ -542,11 +542,11 @@ jobs:
542542

543543
- name: Build workspace
544544
run: |
545-
cat src/dev-utils/.github/workflows/clang_colcon.meta
545+
cat src/dev-utils/.github/workflows/configurations/clang_colcon.meta
546546
source /home/runner/work/fastdds/install/setup.bash
547547
colcon build \
548548
--event-handlers=console_direct+ \
549-
--metas src/dev-utils/.github/workflows/clang_colcon.meta
549+
--metas src/dev-utils/.github/workflows/configurations/clang_colcon.meta
550550
551551
- name: Run clang-tidy
552552
run: |
@@ -637,3 +637,45 @@ jobs:
637637
with:
638638
name: uncrustify_results
639639
path: uncrustify_results.xml
640+
641+
###########################################################
642+
# PYTHON LINTER
643+
python-linter:
644+
runs-on: ubuntu-latest
645+
steps:
646+
- name: Sync eProsima/dev-utils repository
647+
uses: actions/checkout@v2
648+
with:
649+
path: src/dev-utils
650+
651+
- name: Fetch all branches and tags
652+
run: |
653+
cd src/dev-utils
654+
git fetch --prune --unshallow
655+
656+
- name: Install apt packages
657+
uses: ./src/dev-utils/.github/actions/install-apt-packages
658+
659+
- name: Install Python packages
660+
uses: ./src/dev-utils/.github/actions/install-python-packages
661+
662+
- name: Get difference
663+
run: |
664+
cd src/dev-utils
665+
echo "MODIFIED_FILES=$(git diff --name-only origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} | grep -e '\.py' | tr '\n' ' ')" >> $GITHUB_ENV
666+
667+
- name: Check difference
668+
run: |
669+
cd src/dev-utils
670+
if [[ -z "${MODIFIED_FILES}" ]]
671+
then
672+
touch empty.py
673+
echo "MODIFIED_FILES=empty.py" >> $GITHUB_ENV
674+
fi
675+
echo ${MODIFIED_FILES}
676+
677+
- name: Check flake8 linter
678+
run: |
679+
cd src/dev-utils
680+
python3 -m flake8 --config ./.github/workflows/configurations/setup.cfg ${MODIFIED_FILES}
681+
if: always()

0 commit comments

Comments
 (0)