|
| 1 | +name: CI-dev-pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + paths-ignore: |
| 8 | + - "scripts/**" |
| 9 | + - "BlocksScreen/lib/ui/**" |
| 10 | + - "extras/**" |
| 11 | +jobs: |
| 12 | + ci-checks: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + python-version: ["3.11.2"] |
| 18 | + test-type: [ruff, pylint, pytest, docstrcov, security] |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + cache: pip |
| 29 | + cache-dependency-path: scripts/requirements-dev.txt |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: | |
| 33 | + echo "Installing dependencies" |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install -r scripts/requirements-dev.txt |
| 36 | +
|
| 37 | + - name: Run Test ${{ matrix.test-type }} |
| 38 | + run: | |
| 39 | + echo "Starting test runs" |
| 40 | + if [ "${{ matrix.test-type }}" == "ruff" ]; then |
| 41 | + echo "Running Formatting Test" |
| 42 | + ruff check --output-format=github --target-version=py311 --config=pyproject.toml > ruff-output.txt 2>&1 |
| 43 | + ruff format --diff --target-version=py311 --config=pyproject.toml >> ruff-output.txt 2>&1 |
| 44 | + echo "Ruff finished" |
| 45 | + fi |
| 46 | + if [ "${{ matrix.test-type }}" == "pylint" ]; then |
| 47 | + echo "Running Pylint Code Test" |
| 48 | + pylint -j$(nproc) --recursive=y BlocksScreen/ > pylint-output.txt 2>&1 |
| 49 | + echo "Pylint finished" |
| 50 | + fi |
| 51 | +
|
| 52 | + if [ "${{ matrix.test-type }}" == "pytest" ]; then |
| 53 | + if [ -d "tests/" ] && [ "$(ls -A tests/)" ]; then |
| 54 | + echo "Running Python unit tests" |
| 55 | + pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=BlocksScreen/ --cov-report=xml --cov-report=html > pytest-output.txt 2>&1 |
| 56 | + else |
| 57 | + echo "No tests directory no need to proceed with tests" |
| 58 | + fi |
| 59 | + fi |
| 60 | +
|
| 61 | + if [ "${{ matrix.test-type }}" == "docstrcov" ]; then |
| 62 | + echo "Running docstring coverage test" |
| 63 | + docstr-coverage BlocksScreen/ --exclude '.*/BlocksScreen/lib/ui/.*?$' --fail-under=80 --skip-magic --skip-init --skip-private --skip-property > docstr-cov-output.txt 2>&1 |
| 64 | + fi |
| 65 | +
|
| 66 | + if [ "${{matrix.test-type }}" == "security" ]; then |
| 67 | + echo "Running bandit security test" |
| 68 | + bandit -c pyproject.toml -r . -f json -o bandit-output.json 2>&1 |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Upload ruff artifact |
| 72 | + if: always() && matrix.test-type == 'ruff' |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: ruff-results |
| 76 | + path: ruff-output.txt |
| 77 | + |
| 78 | + - name: Upload Pylint Artifacts |
| 79 | + if: always() && matrix.test-type == 'pylint' |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: pylint-results |
| 83 | + path: pylint-output.txt |
| 84 | + |
| 85 | + - name: Upload Pytest Artifacts |
| 86 | + if: always() && matrix.test-type == 'pytest' |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: pytest-results |
| 90 | + path: | |
| 91 | + pytest-output.txt |
| 92 | + junit/test-results.xml |
| 93 | + coverage.xml |
| 94 | + htmlcov/ |
| 95 | + continue-on-error: true |
| 96 | + |
| 97 | + - name: Upload docstr coverage report |
| 98 | + if: always() && matrix.test-type == 'docstrcov' |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: docstr-coverage |
| 102 | + path: docstr-cov-output.txt |
| 103 | + |
| 104 | + - name: Upload bandit security report |
| 105 | + if: always() && matrix.test-type == 'security' |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: bandit-output |
| 109 | + path: bandit-output.json |
0 commit comments