Skip to content

Static code analysis #80

Static code analysis

Static code analysis #80

name: "Static code analysis"
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
# Everyday at midnight
- cron: '0 0 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
static-code-analysis-tests:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: RedHat-SP-Security/sudo-tests
path: sudo-tests
- name: Setup virtual environment
working-directory: ./sudo-tests/pytest
run: |
sudo apt-get update
# Install dependencies for python-ldap
sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev libssh-dev
pip3 install virtualenv
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r ./requirements.txt
pip3 install flake8 pycodestyle isort mypy black
- name: flake8
if: always()
working-directory: ./sudo-tests/pytest
run: source .venv/bin/activate && flake8 .
- name: pycodestyle
if: always()
working-directory: ./sudo-tests/pytest
run: source .venv/bin/activate && pycodestyle .
- name: isort
if: always()
working-directory: ./sudo-tests/pytest
run: source .venv/bin/activate && isort --check-only .
- name: black
if: always()
working-directory: ./sudo-tests/pytest
run: source .venv/bin/activate && black --check --diff .
- name: mypy
if: always()
working-directory: ./sudo-tests/pytest
run: source .venv/bin/activate && mypy --install-types --non-interactive tests
result:
name: All tests are successful
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [static-code-analysis-tests]
steps:
- name: Fail on failure
if: |
needs.static-code-analysis-tests.result != 'success'
run: exit 1