|
1 | | -name: CI |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: [master] |
6 | | - pull_request_target: |
7 | | - branches: [master] |
8 | | - |
9 | | -jobs: |
10 | | - test: |
11 | | - name: Test on Python ${{ matrix.python-version }} (beta=${{ matrix.beta }}) |
12 | | - runs-on: ubuntu-latest |
13 | | - strategy: |
14 | | - matrix: |
15 | | - python-version: ["3.10", "3.11", "3.12", "3.13"] |
16 | | - beta: [false, true] |
17 | | - steps: |
18 | | - - name: Checkout repository |
19 | | - uses: actions/checkout@v4 |
20 | | - with: |
21 | | - ref: ${{ github.event.pull_request.head.sha }} |
22 | | - |
23 | | - - name: Set up Go |
24 | | - uses: actions/setup-go@v5 |
25 | | - with: |
26 | | - go-version: "1.22" |
27 | | - |
28 | | - - name: Build Go parsers |
29 | | - run: pwsh -File ./build_goparser.ps1 |
30 | | - shell: bash |
31 | | - |
32 | | - - name: Set up Python ${{ matrix.python-version }} |
33 | | - uses: actions/setup-python@v5 |
34 | | - with: |
35 | | - python-version: ${{ matrix.python-version }} |
36 | | - |
37 | | - - name: Install dependencies |
38 | | - run: | |
39 | | - python -m pip install --upgrade pip |
40 | | - pip install .[dev] |
41 | | -
|
42 | | - - name: CLI smoke test |
43 | | - run: | |
44 | | - agent-docstrings --version |
45 | | - if [ "${{ matrix.beta }}" = "true" ]; then |
46 | | - agent-docstrings --beta --version |
47 | | - fi |
48 | | -
|
49 | | - - name: Run tests with coverage |
50 | | - run: | |
51 | | - pytest --cov=agent_docstrings --cov-report=xml --cov-report=term-missing |
52 | | -
|
53 | | - - name: Upload coverage artifact |
54 | | - uses: actions/upload-artifact@v4 |
55 | | - with: |
56 | | - name: coverage-${{ matrix.python-version }}-${{ matrix.beta }} |
57 | | - path: coverage.xml |
58 | | - |
59 | | - report: |
60 | | - name: Report Coverage |
61 | | - runs-on: ubuntu-latest |
62 | | - needs: test |
63 | | - steps: |
64 | | - - name: Checkout repository |
65 | | - uses: actions/checkout@v4 |
66 | | - |
67 | | - - name: Download all coverage artifacts |
68 | | - uses: actions/download-artifact@v4 |
69 | | - with: |
70 | | - path: coverage-artifacts |
71 | | - pattern: coverage-* |
72 | | - merge-multiple: true |
73 | | - |
74 | | - - name: Upload coverage to Codecov |
75 | | - uses: codecov/codecov-action@v5 |
76 | | - with: |
77 | | - token: ${{ secrets.CODECOV_TOKEN }} |
78 | | - directory: ./coverage-artifacts/ |
79 | | - fail_ci_if_error: false |
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on pull requests into dev or master. |
| 5 | + pull_request: |
| 6 | + branches: [master, dev] |
| 7 | + # After a PR is merged, the merge commit is pushed to master; we still want tests + coverage once on the resulting commit. |
| 8 | + push: |
| 9 | + branches: [master] |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + # * Runs unit-test matrix: |
| 14 | + # - Always on pull_request (dev or master) |
| 15 | + # - On push to master (after merge) |
| 16 | + if: | |
| 17 | + github.event_name == 'pull_request' || |
| 18 | + (github.event_name == 'push' && github.ref == 'refs/heads/master') |
| 19 | + name: Test on Python ${{ matrix.python-version }} (beta=${{ matrix.beta }}) |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 24 | + beta: [false, true] |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + # For pull_request we check out the PR commit; for push we stay on the pushed ref (master). |
| 29 | + with: |
| 30 | + ref: ${{ github.event.pull_request.head.sha }} |
| 31 | + |
| 32 | + - name: Set up Go |
| 33 | + uses: actions/setup-go@v5 |
| 34 | + with: |
| 35 | + go-version: "1.22" |
| 36 | + |
| 37 | + - name: Build Go parsers |
| 38 | + run: pwsh -File ./build_goparser.ps1 |
| 39 | + shell: bash |
| 40 | + |
| 41 | + - name: Set up Python ${{ matrix.python-version }} |
| 42 | + uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: ${{ matrix.python-version }} |
| 45 | + |
| 46 | + - name: Install dependencies |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip |
| 49 | + pip install .[dev] |
| 50 | +
|
| 51 | + - name: CLI smoke test |
| 52 | + run: | |
| 53 | + agent-docstrings --version |
| 54 | + if [ "${{ matrix.beta }}" = "true" ]; then |
| 55 | + agent-docstrings --beta --version |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: Run tests with coverage |
| 59 | + run: | |
| 60 | + pytest --cov=agent_docstrings --cov-report=xml --cov-report=term-missing |
| 61 | +
|
| 62 | + - name: Upload coverage artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: coverage-${{ matrix.python-version }}-${{ matrix.beta }} |
| 66 | + path: coverage.xml |
| 67 | + |
| 68 | + report: |
| 69 | + # * Only for master: either in PR to master (so reviewers see comment) or after merge push to master. |
| 70 | + if: | |
| 71 | + (github.event_name == 'pull_request' && github.base_ref == 'master') || |
| 72 | + (github.event_name == 'push' && github.ref == 'refs/heads/master') |
| 73 | + name: Report Coverage |
| 74 | + runs-on: ubuntu-latest |
| 75 | + needs: test |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@v4 |
| 79 | + |
| 80 | + - name: Download all coverage artifacts |
| 81 | + uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + path: coverage-artifacts |
| 84 | + pattern: coverage-* |
| 85 | + merge-multiple: true |
| 86 | + |
| 87 | + - name: Upload coverage to Codecov |
| 88 | + uses: codecov/codecov-action@v5 |
| 89 | + with: |
| 90 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 91 | + directory: ./coverage-artifacts/ |
| 92 | + fail_ci_if_error: false |
| 93 | + |
| 94 | + check-version: |
| 95 | + # * Only on PRs into dev: prevent accidental version bumps. |
| 96 | + if: github.event_name == 'pull_request' && github.base_ref == 'dev' |
| 97 | + name: Check for accidental version bump |
| 98 | + runs-on: ubuntu-latest |
| 99 | + steps: |
| 100 | + - name: Checkout repository |
| 101 | + uses: actions/checkout@v4 |
| 102 | + with: |
| 103 | + fetch-depth: 0 |
| 104 | + |
| 105 | + - name: Verify that version was not bumped |
| 106 | + run: | |
| 107 | + if ! git diff --quiet origin/dev HEAD -- pyproject.toml; then |
| 108 | + echo "::error::Version in pyproject.toml was changed in a PR to dev." |
| 109 | + echo "Version bumping should only happen in a release PR to master." |
| 110 | + exit 1 |
| 111 | + fi |
| 112 | + echo "Version check passed for pyproject.toml" |
0 commit comments