|
1 |
| -name: toolkit-unit-tests |
| 1 | +name: Unit tests |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
7 |
| - paths-ignore: |
8 |
| - - '**.md' |
9 | 7 | pull_request:
|
10 |
| - paths-ignore: |
11 |
| - - '**.md' |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + checks: write |
12 | 14 |
|
13 | 15 | jobs:
|
14 |
| - build: |
15 |
| - name: Build and Test |
16 |
| - strategy: |
17 |
| - matrix: |
18 |
| - runs-on: [ubuntu-latest, macos-latest, windows-latest] |
19 |
| - python-version: ['3.9', '3.10', '3.11'] # Матрица версий Python |
20 |
| - fail-fast: false |
21 |
| - runs-on: ${{ matrix.runs-on }} |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
22 | 18 |
|
23 | 19 | steps:
|
24 |
| - - name: Checkout |
| 20 | + - name: Checkout code |
25 | 21 | uses: actions/checkout@v3
|
26 | 22 |
|
27 |
| - - name: Set up Python ${{ matrix.python-version }} |
| 23 | + - name: Set up Python |
28 | 24 | uses: actions/setup-python@v4
|
29 | 25 | with:
|
30 |
| - python-version: ${{ matrix.python-version }} |
| 26 | + python-version: '3.9' |
31 | 27 |
|
32 | 28 | - name: Install dependencies
|
33 | 29 | run: |
|
34 | 30 | python -m pip install --upgrade pip
|
35 | 31 | if [ -f "requirements.txt" ]; then
|
36 |
| - pip install -r requirements.txt |
| 32 | + pip install -r requirements.txt || { echo "Dependency installation failed!"; exit 1; } |
37 | 33 | else
|
38 | 34 | echo "requirements.txt not found! Skipping dependency installation."
|
39 | 35 | fi
|
40 | 36 |
|
41 |
| - - name: Lint with flake8 |
| 37 | + - name: Run unit tests |
42 | 38 | run: |
|
43 |
| - if [ -f "setup.cfg" ] || [ -f ".flake8" ]; then |
44 |
| - pip install flake8 |
45 |
| - flake8 . |
46 |
| - else |
47 |
| - echo "No lint configuration found! Skipping linting." |
48 |
| - fi |
| 39 | + pytest --junitxml=test-results.xml || true |
| 40 | + id: run-tests |
49 | 41 |
|
50 |
| - - name: Run unit tests |
| 42 | + - name: Check test results |
| 43 | + if: steps.run-tests.outcome == 'failure' |
51 | 44 | run: |
|
52 |
| - pip install pytest |
53 |
| - pytest --junitxml=test-results.xml |
54 |
| - env: |
55 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Для доступа к секретам, если нужны |
| 45 | + echo "Tests failed! Review the logs for details." |
| 46 | + exit 1 |
56 | 47 |
|
57 | 48 | - name: Upload test results
|
58 |
| - if: always() # Выполнить этот шаг всегда, независимо от успеха предыдущих шагов |
| 49 | + if: always() |
59 | 50 | uses: actions/upload-artifact@v4
|
60 | 51 | with:
|
61 | 52 | name: test-results
|
|
0 commit comments