Hi folks! I am trying to take advantage of the `in...
# general
i
Hi folks! I am trying to take advantage of the
init-pants
action for github, but for some reason I cannot identify it is not running tests as I intend it to. I have two branches
branch-a
and
branch-b
so when I run locally from
branch-b
the command
pants --changed-since=origin/branch-a --changed-dependents=transitive test
it only runs tests that are dependent om my changes, this is awesome. But when I try the same using the github action, it just run the tests but it seems it is just picking all from cache, for instance, tests should fail, but they don't. Here is what my github workflow looks like:
Copy code
jobs:
  build:
    name: Perform CI Checks
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        python-version: [3.12]
    steps:
    - uses: actions/checkout@v4
      with:
        ref: branch-a
    - uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
    - uses: pantsbuild/actions/init-pants@v8
      with:
        base-branch: branch-a
        gha-cache-key: v0
        named-caches-hash: ${{ hashFiles('project_1.lock', 'project_2.lock') }}
        cache-lmdb-store: 'true'
    - name: Test
      run: |
        pants --changed-since=origin/branch-a --changed-dependents=transitive test
Any ideas on what am I doing wrong?
I figured out that when I did
Copy code
- uses: actions/checkout@v4
      with:
        ref: branch-a
I checked out
branch-a
and pants was now comparing
branch-a
to
branch-a
🤦 Changed it to the regular checkout for
branch-b
and added an additional step to fetch
branch-a
Copy code
- name: Fetch base branch
   run: git fetch origin using-pants --unshallow
This fixed it for me and looks less expensive than using a checkout with fetch-depth of zero.
b
I'm glad you fixed it!