Skip to content

Commit

Permalink
[CI/CD] Fix Python test workflow (#2695)
Browse files Browse the repository at this point in the history
Do not install pip, setuptools and wheel via sudo but into the runner's default user environment. This fixes the safety check about a vulnerability in an older setuptools version.

Exclude the build/ directory with mypy, which solves the duplicate module error.

Run job with distro matrix instead of defining two identical jobs for Focal and Jammy.

Signed-off-by: MichaIng <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
MichaIng and github-actions[bot] authored Jan 29, 2023
1 parent 08a5b75 commit a4f0997
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
34 changes: 8 additions & 26 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,26 @@ concurrency:
cancel-in-progress: true

jobs:
focal:
test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-20.04
strategy:
matrix:
dist: ['ubuntu-20.04', 'ubuntu-22.04']
runs-on: ${{ matrix.dist }}
name: "Test on ${{ matrix.dist }}"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: sudo apt-get -q update
- run: sudo DEBIAN_FRONTEND="noninteractive" apt-get -qq --no-install-recommends dist-upgrade
- run: sudo DEBIAN_FRONTEND="noninteractive" apt-get -qq --no-install-recommends install
curl gcc ffmpeg libcurl4-openssl-dev libssl-dev motion v4l-utils
- run: sudo python3 -m pip install --upgrade pip setuptools wheel
- run: python3 -m pip install --upgrade pip setuptools wheel
- run: python3 -m pip install --upgrade build mypy pytest safety
- run: python3 -m build
- run: python3 -m pip install .
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
- run: pytest --ignore=tests/test_utils/test_mjpeg.py
--ignore=tests/test_utils/test_rtmp.py .
- run: pytest --fixtures tests/test_utils/test_mjpeg.py || true
- run: pytest --fixtures tests/test_utils/test_rtmp.py || true
- run: pytest . || pytest --doctest-modules . || true
- run: safety check
jammy:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: sudo apt-get -q update
- run: sudo DEBIAN_FRONTEND="noninteractive" apt-get -qq --no-install-recommends dist-upgrade
- run: sudo DEBIAN_FRONTEND="noninteractive" apt-get -qq --no-install-recommends install
curl gcc ffmpeg libcurl4-openssl-dev libssl-dev motion v4l-utils
- run: sudo python3 -m pip install --upgrade pip setuptools wheel
- run: python3 -m pip install --upgrade build mypy pytest safety
- run: python3 -m build
- run: python3 -m pip install .
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
- run: mypy --ignore-missing-imports --install-types --non-interactive --exclude build/ . || true
- run: pytest --ignore=tests/test_utils/test_mjpeg.py
--ignore=tests/test_utils/test_rtmp.py .
- run: pytest --fixtures tests/test_utils/test_mjpeg.py || true
Expand Down
2 changes: 1 addition & 1 deletion motioneye/locale/motioneye.js.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-24 01:38+0000\n"
"POT-Creation-Date: 2023-01-29 18:08+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
6 changes: 3 additions & 3 deletions motioneye/locale/motioneye.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Translations template for PROJECT.
# Copyright (C) 2022 ORGANIZATION
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-11-24 01:38+0000\n"
"POT-Creation-Date: 2023-01-29 18:08+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down

0 comments on commit a4f0997

Please sign in to comment.