Skip to content

Commit

Permalink
Added GHA job to only run PR workflow in case code has been changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kunaljubce committed Feb 25, 2024
1 parent 2ea3fa6 commit f44398c
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,54 @@ on:

jobs:

detect_code_changes:
runs-on: ubuntu-latest
outputs:
code_changes: ${{ steps.filter.outputs.code_changes }}
steps:
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
code_changes:
- 'quinn/**'
- 'tests/**'
- 'benchmarks/**'
- '.github/**'
- 'poetry.lock'
- 'pyproject.toml'
test:
runs-on: ubuntu-latest
needs: [detect_code_changes]
steps:
- uses: actions/checkout@v3
if: needs.detect_code_changes.outputs.code_changes == 'true'
with:
fetch-depth: 1

- name: Setup Java
uses: actions/setup-java@v3
if: needs.detect_code_changes.outputs.code_changes == 'true'
with:
distribution: 'zulu'
java-version: '8' # Supported by Spark 2.x & 3.x

- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v4
if: needs.detect_code_changes.outputs.code_changes == 'true'
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
if: needs.detect_code_changes.outputs.code_changes == 'true'
with:
version: 1.6.1

- name: Cache Poetry virtualenv
uses: actions/cache@v1
if: needs.detect_code_changes.outputs.code_changes == 'true'
id: cache
with:
path: ~/.virtualenvs
Expand All @@ -41,8 +64,12 @@ jobs:
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: |
needs.detect_code_changes.outputs.code_changes == 'true' &&
steps.cache.outputs.cache-hit != 'true'
run: make install_test
if: steps.cache.outputs.cache-hit != 'true'
# if: steps.cache.outputs.cache-hit != 'true'

- name: Run tests with pytest
if: needs.detect_code_changes.outputs.code_changes == 'true'
run: make test

0 comments on commit f44398c

Please sign in to comment.