diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index c51f8ed7b0..8feec8a9d6 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -3,14 +3,38 @@ on: branches: - main pull_request: - paths: - - library_generation/** workflow_dispatch: name: verify_library_generation jobs: - integration_tests: + should-run-library-generation-tests: runs-on: ubuntu-22.04 + outputs: + should_run: ${{ steps.get_changed_directories.outputs.should_run }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: get changed directories in the pull request + id: get_changed_directories + shell: bash + run: | + set -ex + git checkout "${base_ref}" + git checkout "${head_ref}" + changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" + if [[ ${changed_directories} =~ "library_generation/" ]]; then + echo "should_run=true" >> $GITHUB_OUTPUT + else + echo "should_run=false" >> $GITHUB_OUTPUT + fi + env: + base_ref: ${{ github.event.pull_request.base.ref }} + head_ref: ${{ github.event.pull_request.head.ref }} + library-generation-integration-tests: + runs-on: ubuntu-22.04 + needs: should-run-library-generation-tests + if: needs.should-run-library-generation-tests.outputs.should_run == 'true' steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -41,12 +65,14 @@ jobs: run: | set -x python -m unittest library_generation/test/integration_tests.py - unit_tests: + library-generation-unit-tests: + runs-on: ${{ matrix.os }} + needs: should-run-library-generation-tests + if: needs.should-run-library-generation-tests.outputs.should_run == 'true' strategy: matrix: java: [ 8 ] os: [ ubuntu-22.04, macos-12 ] - runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: install utils (macos) @@ -88,8 +114,10 @@ jobs: run: | set -x python -m unittest discover -s library_generation/test/ -p "*unit_tests.py" - lint-shell: + library-generation-lint-shell: runs-on: ubuntu-22.04 + needs: should-run-library-generation-tests + if: needs.should-run-library-generation-tests.outputs.should_run == 'true' steps: - uses: actions/checkout@v4 - name: Run ShellCheck @@ -98,8 +126,10 @@ jobs: scandir: 'library_generation' format: tty severity: error - lint-python: + library-generation-lint-python: runs-on: ubuntu-22.04 + needs: should-run-library-generation-tests + if: needs.should-run-library-generation-tests.outputs.should_run == 'true' steps: - uses: actions/checkout@v4 - name: install python dependencies