|
4 | 4 | # Run on pull requests into dev or master. |
5 | 5 | pull_request: |
6 | 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. |
| 7 | + # Push to dev also triggers tests to ensure dev branch is always stable |
8 | 8 | push: |
9 | | - branches: [master] |
| 9 | + branches: [dev] |
10 | 10 |
|
11 | 11 | jobs: |
12 | 12 | test: |
13 | 13 | # * Runs unit-test matrix: |
14 | | - # - Always on pull_request (dev or master) |
15 | | - # - On push to master (after merge) |
| 14 | + # - On pull_request (to dev or master) |
| 15 | + # - On push to dev |
16 | 16 | if: | |
17 | 17 | github.event_name == 'pull_request' || |
18 | | - (github.event_name == 'push' && github.ref == 'refs/heads/master') |
| 18 | + (github.event_name == 'push' && github.ref == 'refs/heads/dev') |
19 | 19 | name: Test on Python ${{ matrix.python-version }} (beta=${{ matrix.beta }}) |
20 | 20 | runs-on: ubuntu-latest |
21 | 21 | strategy: |
|
25 | 25 | steps: |
26 | 26 | - name: Checkout repository |
27 | 27 | uses: actions/checkout@v4 |
28 | | - # For pull_request we check out the PR commit; for push we stay on the pushed ref (master). |
| 28 | + # For pull_request we check out the PR commit; for push we stay on the pushed ref (dev). |
29 | 29 | with: |
30 | 30 | ref: ${{ github.event.pull_request.head.sha }} |
31 | 31 |
|
|
34 | 34 | with: |
35 | 35 | go-version: "1.22" |
36 | 36 |
|
| 37 | + - name: Cache Go modules |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: ~/go/pkg/mod |
| 41 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-go- |
| 44 | +
|
37 | 45 | - name: Build Go parsers |
38 | 46 | run: pwsh -File ./build_goparser.ps1 |
39 | 47 | shell: bash |
|
43 | 51 | with: |
44 | 52 | python-version: ${{ matrix.python-version }} |
45 | 53 |
|
| 54 | + - name: Cache pip |
| 55 | + uses: actions/cache@v4 |
| 56 | + with: |
| 57 | + path: ~/.cache/pip |
| 58 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} |
| 59 | + restore-keys: | |
| 60 | + ${{ runner.os }}-pip- |
| 61 | +
|
46 | 62 | - name: Install dependencies |
47 | 63 | run: | |
48 | 64 | python -m pip install --upgrade pip |
|
67 | 83 |
|
68 | 84 | report: |
69 | 85 | # * 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') |
| 86 | + if: github.event_name == 'pull_request' && github.base_ref == 'master' |
73 | 87 | name: Report Coverage |
74 | 88 | runs-on: ubuntu-latest |
75 | 89 | needs: test |
@@ -104,9 +118,24 @@ jobs: |
104 | 118 |
|
105 | 119 | - name: Verify that version was not bumped |
106 | 120 | 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." |
| 121 | + echo "Checking for version changes in pyproject.toml..." |
| 122 | + DEV_PYPROJECT_VERSION=$(git show origin/dev:pyproject.toml | grep '^version = ' | awk -F'"' '{print $2}') |
| 123 | + HEAD_PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | awk -F'"' '{print $2}') |
| 124 | +
|
| 125 | + if [ "$DEV_PYPROJECT_VERSION" != "$HEAD_PYPROJECT_VERSION" ]; then |
| 126 | + echo "::error::Version in pyproject.toml was changed in a PR to dev. (dev: $DEV_PYPROJECT_VERSION, HEAD: $HEAD_PYPROJECT_VERSION)" |
109 | 127 | echo "Version bumping should only happen in a release PR to master." |
110 | 128 | exit 1 |
111 | 129 | fi |
112 | 130 | echo "Version check passed for pyproject.toml" |
| 131 | +
|
| 132 | + echo "Checking for version changes in agent_docstrings/__init__.py..." |
| 133 | + DEV_INIT_VERSION=$(git show origin/dev:agent_docstrings/__init__.py | grep '^__version__ = ' | awk -F'"' '{print $2}') |
| 134 | + HEAD_INIT_VERSION=$(grep '^__version__ = ' agent_docstrings/__init__.py | awk -F'"' '{print $2}') |
| 135 | +
|
| 136 | + if [ "$DEV_INIT_VERSION" != "$HEAD_INIT_VERSION" ]; then |
| 137 | + echo "::error::Version in agent_docstrings/__init__.py was changed in a PR to dev. (dev: $DEV_INIT_VERSION, HEAD: $HEAD_INIT_VERSION)" |
| 138 | + echo "Version bumping should only happen in a release PR to master." |
| 139 | + exit 1 |
| 140 | + fi |
| 141 | + echo "Version check passed for agent_docstrings/__init__.py" |
0 commit comments