diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d5da287..299a5a9 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -3,7 +3,31 @@ on: - pull_request jobs: + changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + sf: ${{ steps.filter.outputs.sf }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + sf: + - pennylane_sf/** + - tests/** + - .pylintrc + - Makefile + - requirements-ci.txt + - requirements.txt + - setup.py black: + needs: changes + if: ${{ needs.changes.outputs.sf == 'true' }} runs-on: ubuntu-latest steps: - uses: dorny/paths-filter@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0278d26..7f65d87 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,31 @@ on: pull_request: jobs: + changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + sf: ${{ steps.filter.outputs.sf }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + sf: + - pennylane_sf/** + - tests/** + - .pylintrc + - Makefile + - requirements-ci.txt + - requirements.txt + - setup.py tests: + needs: changes + if: ${{ needs.changes.outputs.sf == 'true' }} runs-on: ubuntu-latest strategy: matrix: @@ -21,34 +45,18 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - sf: - - pennylane_sf/** - - tests/** - - .pylintrc - - Makefile - - requirements-ci.txt - - requirements.txt - - setup.py - name: Install dependencies - if: steps.filter.outputs.sf == 'true' run: | python -m pip install --upgrade pip pip install -r requirements-ci.txt pip install wheel pytest pytest-cov pytest-mock --upgrade - name: Install Plugin - if: steps.filter.outputs.sf == 'true' run: | python setup.py bdist_wheel pip install dist/PennyLane*.whl - name: Run tests - if: steps.filter.outputs.sf == 'true' run: python -m pytest tests --cov=pennylane_sf --cov-report=term-missing --cov-report=xml -p no:warnings --tb=native - name: Upload coverage to Codecov - if: steps.filter.outputs.sf == 'true' uses: codecov/codecov-action@v1 with: file: ./coverage.xml