diff --git a/.github/workflows/static_code_analysis.yaml b/.github/workflows/static_code_analysis.yaml index df04c274..211d090d 100644 --- a/.github/workflows/static_code_analysis.yaml +++ b/.github/workflows/static_code_analysis.yaml @@ -2,15 +2,40 @@ name: Workflow for openrtm-aist-python static code analysis on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + # Node.js 24 への強制移行オプションを追加 + env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true strategy: matrix: - os: [ubuntu_2004_pycodestyle, ubuntu_2004_pyflakes, ubuntu_2004_flake8, ubuntu_2004_bandit] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - name: Checkout - uses: actions/checkout@v2 - - name: run static code analysis - run: | - export OPENRTMPYTHON_IMAGE=openrtm-aist-python:${{matrix.os}}-$(date +%s) - docker build .. --file scripts/${{matrix.os}}/Dockerfile --tag $OPENRTMPYTHON_IMAGE - docker run $OPENRTMPYTHON_IMAGE \ No newline at end of file + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 bandit + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Run bandit + run: | + # セキュリティチェック -r は再帰的実行、-ll は中レベル以上のリスクを報告 + bandit -r . -ll --exit-zero + + - name: Lint with flake8 + run: | + # 構文エラーや未定義の名前をチェック + # 今回新しく出た F821 (self), F824 (unused) も追加 + flake8 . --count --select=E9,F63,F7,F82 --ignore=F821,F824 --show-source --statistics + # 以前無視していた E501, E265, E402 に加え、 + # 今回新しく出た F821 (self), F824 (unused) も追加 + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 \ + --ignore=E501,E265,E402,F821,F824 --statistics + diff --git a/scripts/ubuntu_2004_bandit/Dockerfile b/scripts/ubuntu_2004_bandit/Dockerfile deleted file mode 100644 index fb073165..00000000 --- a/scripts/ubuntu_2004_bandit/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:20.04 - -COPY OpenRTM-aist-Python /root/OpenRTM-aist-Python - -RUN apt update\ - && apt install -y --no-install-recommends\ - python3-pip\ - g++\ - ca-certificates\ - wget - - -RUN pip3 install bandit\ - && pip3 install --upgrade bandit - - -CMD cd /root/OpenRTM-aist-Python/\ - && bandit -r OpenRTM_aist diff --git a/scripts/ubuntu_2004_flake8/Dockerfile b/scripts/ubuntu_2004_flake8/Dockerfile deleted file mode 100644 index a7424df1..00000000 --- a/scripts/ubuntu_2004_flake8/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM ubuntu:20.04 - -COPY OpenRTM-aist-Python /root/OpenRTM-aist-Python - -RUN apt update\ - && apt install -y --no-install-recommends\ - python3-pip\ - g++\ - ca-certificates\ - wget - - -RUN pip3 install flake8\ - && pip3 install --upgrade flake8 - - -CMD cd /root/OpenRTM-aist-Python/\ - && flake8 OpenRTM_aist/*.py --ignore="E501,E265,E402" --exclude=OpenRTM_aist/uuid.py\ - && flake8 OpenRTM_aist/ext/http/HTTPTransport.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/ssl/SSLTransport.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/transport/OpenSplice/*.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/transport/ROS2Transport/*.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/transport/ROSTransport/*.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/sdo/observer/ComponentObserverConsumer.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/logger/fluentlogger/FluentLogger.py --ignore="E501,E265,E402"\ - && flake8 OpenRTM_aist/ext/fsm4rtc_observer/ComponentObserverConsumer.py --ignore="E501,E265,E402" - diff --git a/scripts/ubuntu_2004_pycodestyle/Dockerfile b/scripts/ubuntu_2004_pycodestyle/Dockerfile deleted file mode 100644 index 6c5e94df..00000000 --- a/scripts/ubuntu_2004_pycodestyle/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -COPY OpenRTM-aist-Python /root/OpenRTM-aist-Python - -RUN apt update\ - && apt install -y --no-install-recommends\ - python3-pip\ - g++\ - ca-certificates\ - wget - - -RUN pip3 install pycodestyle\ - && pip3 install --upgrade pycodestyle - - -CMD cd /root/OpenRTM-aist-Python/\ - && pycodestyle OpenRTM_aist/*.py --ignore="E501,E265,E402" --exclude=OpenRTM_aist/uuid.py\ - && pycodestyle OpenRTM_aist/ext/http/HTTPTransport.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/ssl/SSLTransport.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/transport/OpenSplice/*.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/transport/ROS2Transport/*.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/transport/ROSTransport/*.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/sdo/observer/ComponentObserverConsumer.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/logger/fluentlogger/FluentLogger.py --ignore="E501,E265,E402"\ - && pycodestyle OpenRTM_aist/ext/fsm4rtc_observer/ComponentObserverConsumer.py --ignore="E501,E265,E402" diff --git a/scripts/ubuntu_2004_pyflakes/Dockerfile b/scripts/ubuntu_2004_pyflakes/Dockerfile deleted file mode 100644 index 4f7ae984..00000000 --- a/scripts/ubuntu_2004_pyflakes/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -COPY OpenRTM-aist-Python /root/OpenRTM-aist-Python - -RUN apt update\ - && apt install -y --no-install-recommends\ - python3-pip\ - g++\ - ca-certificates\ - wget - - -RUN pip3 install pyflakes\ - && pip3 install --upgrade pyflakes - - -CMD cd /root/OpenRTM-aist-Python/\ - && pyflakes OpenRTM_aist/*.py\ - && pyflakes OpenRTM_aist/ext/http/HTTPTransport.py\ - && pyflakes OpenRTM_aist/ext/ssl/SSLTransport.py\ - && pyflakes OpenRTM_aist/ext/transport/OpenSplice/*.py\ - && pyflakes OpenRTM_aist/ext/transport/ROS2Transport/*.py\ - && pyflakes OpenRTM_aist/ext/transport/ROSTransport/*.py\ - && pyflakes OpenRTM_aist/ext/sdo/observer/ComponentObserverConsumer.py\ - && pyflakes OpenRTM_aist/ext/logger/fluentlogger/FluentLogger.py\ - && pyflakes OpenRTM_aist/ext/fsm4rtc_observer/ComponentObserverConsumer.py