|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["**"] |
| 6 | + pull_request: |
| 7 | + branches: ["**"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + name: Lint and Type Check |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 2 |
| 18 | + |
| 19 | + - name: Set up Python 3.11 |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: "3.11" |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install -e ".[dev]" |
| 28 | +
|
| 29 | + - name: Run flake8 |
| 30 | + run: | |
| 31 | + python -m flake8 fmd_api/ tests/ --count --show-source --statistics |
| 32 | +
|
| 33 | + - name: Run mypy |
| 34 | + run: | |
| 35 | + python -m mypy fmd_api/ |
| 36 | +
|
| 37 | + test: |
| 38 | + name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + os: [ubuntu-latest, windows-latest] |
| 44 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout code |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + fetch-depth: 2 |
| 51 | + |
| 52 | + - name: Set up Python ${{ matrix.python-version }} |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: ${{ matrix.python-version }} |
| 56 | + |
| 57 | + - name: Install dependencies |
| 58 | + run: | |
| 59 | + python -m pip install --upgrade pip |
| 60 | + pip install -e ".[dev]" |
| 61 | +
|
| 62 | + - name: Run unit tests with coverage |
| 63 | + run: | |
| 64 | + python -m pytest tests/unit --cov=fmd_api --cov-branch --cov-report=xml --cov-report=term -v |
| 65 | +
|
| 66 | + - name: Upload coverage to Codecov |
| 67 | + uses: codecov/codecov-action@v5 |
| 68 | + with: |
| 69 | + files: ./coverage.xml |
| 70 | + flags: unittests |
| 71 | + name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} |
| 72 | + fail_ci_if_error: false |
| 73 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 74 | + |
| 75 | + - name: Run functional tests (if credentials available) |
| 76 | + # Skip on PRs from forks where secrets aren't available |
| 77 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository |
| 78 | + continue-on-error: true |
| 79 | + run: | |
| 80 | + python -m pytest tests/functional -v |
| 81 | + env: |
| 82 | + # Optional: set up test credentials as repository secrets |
| 83 | + FMD_BASE_URL: ${{ secrets.FMD_BASE_URL }} |
| 84 | + FMD_ID: ${{ secrets.FMD_ID }} |
| 85 | + FMD_PASSWORD: ${{ secrets.FMD_PASSWORD }} |
0 commit comments