|
1 | | -name: PyTest |
| 1 | +name: Tests |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
|
7 | 7 | - "**.py" |
8 | 8 | - ".github/**" |
9 | 9 |
|
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | + |
10 | 14 | jobs: |
11 | | - fail_if_pr_is_draft: |
12 | | - if: github.event.pull_request.draft == true |
13 | | - runs-on: ubuntu-18.04 |
14 | | - steps: |
15 | | - - name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass. |
16 | | - run: exit 1 |
17 | | - pytest_and_doctest: |
| 15 | + Pytest: |
18 | 16 | runs-on: ${{ matrix.os }} |
19 | 17 | strategy: |
20 | 18 | matrix: |
21 | | - os: |
22 | | - - ubuntu-latest |
23 | | - - macos-latest |
24 | | - - windows-latest |
25 | | - python-version: |
26 | | - - 3.8 |
27 | | - - 3.12 |
| 19 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 20 | + python-version: [3.8, 3.12] |
28 | 21 | env: |
29 | 22 | OS: ${{ matrix.os }} |
30 | 23 | PYTHON: ${{ matrix.python-version }} |
31 | 24 | steps: |
32 | | - - uses: actions/checkout@v2 |
33 | | - - name: Set up Python ${{ matrix.python-version }} |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Set up Python |
34 | 27 | uses: actions/setup-python@v2 |
35 | 28 | with: |
36 | 29 | python-version: ${{ matrix.python-version }} |
37 | | - - name: Install dependencies |
38 | | - run: | |
39 | | - python -m pip install --upgrade pip |
40 | | - - name: Build RocketPy (without optional dependencies) |
41 | | - run: | |
42 | | - pip install . |
43 | | - - name: Import rocketpy in python and test if it works |
44 | | - run: | |
45 | | - python -c "import sys, rocketpy; print(f'{rocketpy.__name__} running on Python {sys.version}')" |
46 | | - - name: Install optional dependencies |
47 | | - run: | |
48 | | - pip install -r requirements-tests.txt |
49 | | - - name: Test with pytest |
50 | | - run: | |
51 | | - pytest --cov=rocketpy --cov-report=xml |
52 | | - cd rocketpy |
53 | | - pytest --doctest-modules --cov=rocketpy --cov-report=xml |
54 | | - - name: Upload coverage report to Codecov |
55 | | - uses: codecov/codecov-action@v3 |
| 30 | + |
| 31 | + - name: Cache Python dependencies |
| 32 | + uses: actions/cache@v2 |
| 33 | + with: |
| 34 | + path: ~/.cache/pip |
| 35 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-tests.txt') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-pip- |
| 38 | +
|
| 39 | + - name: Install rocketpy |
| 40 | + run: pip install . |
| 41 | + |
| 42 | + - name: Test importing rocketpy |
| 43 | + run: python -c "import sys, rocketpy; print(f'{rocketpy.__name__} running on Python {sys.version}')" |
| 44 | + |
| 45 | + - name: Install test dependencies |
| 46 | + run: pip install -r requirements-tests.txt |
| 47 | + |
| 48 | + - name: Run Unit Tests |
| 49 | + run: pytest tests/unit --cov=rocketpy |
| 50 | + |
| 51 | + - name: Run Integration Tests |
| 52 | + run: pytest $(find tests -maxdepth 1 -name "*.py") --cov=rocketpy --cov-append |
| 53 | + |
| 54 | + - name: Run Documentation Tests |
| 55 | + run: pytest rocketpy --doctest-modules --cov=rocketpy --cov-append |
| 56 | + |
| 57 | + - name: Run Acceptance Tests |
| 58 | + run: pytest tests/acceptance --cov=rocketpy --cov-append --cov-report=xml |
| 59 | + |
| 60 | + - name: Upload coverage to artifacts |
| 61 | + uses: actions/upload-artifact@v2 |
| 62 | + with: |
| 63 | + name: coverage |
| 64 | + path: coverage.xml |
| 65 | + |
| 66 | + CodecovUpload: |
| 67 | + needs: Pytest |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + - name: Download all coverage reports |
| 72 | + uses: actions/download-artifact@v2 |
| 73 | + - name: Upload to Codecov |
| 74 | + uses: codecov/codecov-action@v2 |
56 | 75 | with: |
57 | 76 | token: ${{ secrets.CODECOV_TOKEN }} |
58 | | - directory: ./coverage/reports/ |
59 | | - env_vars: OS,PYTHON |
60 | | - fail_ci_if_error: true |
61 | | - files: ./coverage.xml, ./rocketpy/coverage.xml |
62 | | - flags: unittests |
63 | | - name: codecov-umbrella |
64 | | - verbose: true |
| 77 | + files: | |
| 78 | + coverage.xml |
0 commit comments