From 87f98afcee0ec2218d192bddb316bf2aa7da80dd Mon Sep 17 00:00:00 2001 From: Marcelle <53578688+m-goggins@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:10:45 -0700 Subject: [PATCH] Add python linting workflow (#2333) * add python linting workflow to orchestration * revert orchestration * test rl * [pre-commit.ci] auto fixes from pre-commit hooks * test rl part 2 * give the workflow one more shot * add workflows to all python containers * revert orchestration back * remove print statement * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/container-dibbs.yaml | 26 ++-------------- .../workflows/container-fhir-converter.yaml | 23 +++----------- .github/workflows/container-ingestion.yaml | 23 +++----------- .../workflows/container-message-parser.yaml | 22 ++----------- .../workflows/container-message-refiner.yaml | 22 ++----------- .../workflows/container-orchestration.yaml | 2 +- .../workflows/container-record-linkage.yaml | 22 ++----------- .../container-trigger-code-reference.yaml | 22 ++----------- .github/workflows/container-validation.yaml | 22 ++----------- .github/workflows/linting-python.yaml | 31 +++++++++++++++++++ 10 files changed, 58 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/linting-python.yaml diff --git a/.github/workflows/container-dibbs.yaml b/.github/workflows/container-dibbs.yaml index 4fee303aa3..ce91e9b6a1 100644 --- a/.github/workflows/container-dibbs.yaml +++ b/.github/workflows/container-dibbs.yaml @@ -26,29 +26,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest diff --git a/.github/workflows/container-fhir-converter.yaml b/.github/workflows/container-fhir-converter.yaml index 29688bbae0..20e5ffb07e 100644 --- a/.github/workflows/container-fhir-converter.yaml +++ b/.github/workflows/container-fhir-converter.yaml @@ -26,25 +26,10 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env + unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/container-ingestion.yaml b/.github/workflows/container-ingestion.yaml index 32793fffc2..aea8b1cfde 100644 --- a/.github/workflows/container-ingestion.yaml +++ b/.github/workflows/container-ingestion.yaml @@ -27,25 +27,10 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env + unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/container-message-parser.yaml b/.github/workflows/container-message-parser.yaml index bebed08cff..405c4751f5 100644 --- a/.github/workflows/container-message-parser.yaml +++ b/.github/workflows/container-message-parser.yaml @@ -27,25 +27,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/container-message-refiner.yaml b/.github/workflows/container-message-refiner.yaml index 6b67ada322..efe94703b6 100644 --- a/.github/workflows/container-message-refiner.yaml +++ b/.github/workflows/container-message-refiner.yaml @@ -27,25 +27,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/container-orchestration.yaml b/.github/workflows/container-orchestration.yaml index 0ab71accb1..7ce71c8334 100644 --- a/.github/workflows/container-orchestration.yaml +++ b/.github/workflows/container-orchestration.yaml @@ -23,7 +23,7 @@ env: CONTAINER: orchestration jobs: - orchestration-python-linting: + orchestration-python-linting: # This job is the same as the python-linting job in linting-python.yaml but does not run if using linting-python.yaml runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/container-record-linkage.yaml b/.github/workflows/container-record-linkage.yaml index 1ae0a59f2e..80c687ed45 100644 --- a/.github/workflows/container-record-linkage.yaml +++ b/.github/workflows/container-record-linkage.yaml @@ -27,25 +27,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest services: diff --git a/.github/workflows/container-trigger-code-reference.yaml b/.github/workflows/container-trigger-code-reference.yaml index ffa666e403..8e6db6ae7b 100644 --- a/.github/workflows/container-trigger-code-reference.yaml +++ b/.github/workflows/container-trigger-code-reference.yaml @@ -27,25 +27,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/container-validation.yaml b/.github/workflows/container-validation.yaml index 45ae640162..ef0e8028cc 100644 --- a/.github/workflows/container-validation.yaml +++ b/.github/workflows/container-validation.yaml @@ -27,25 +27,9 @@ env: jobs: python-linting: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}} - uses: actions/setup-python@v5 - with: - python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}} - cache: pip - - name: Install dependencies - run: | - pip install -U pip - pip install ruff==0.4.3 - - name: Run linter (ruff) - run: | - ruff check --output-format=github . - - name: Run formatter (ruff) - run: | - ruff format --check + uses: ./.github/workflows/linting-python.yaml + with: + python_runner_version: 3.11 # must be hardcoded; cannot pass in from env unit-test-python-containers: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/linting-python.yaml b/.github/workflows/linting-python.yaml new file mode 100644 index 0000000000..22683adfc1 --- /dev/null +++ b/.github/workflows/linting-python.yaml @@ -0,0 +1,31 @@ +name: Python Linting + +on: + workflow_call: + inputs: + python_runner_version: + default: 3.11 + required: true + type: number + +jobs: + python-linting: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup python ${{inputs.python_runner_version}} + uses: actions/setup-python@v5 + with: + python-version: ${{inputs.python_runner_version}} + cache: pip + - name: Install dependencies + run: | + pip install -U pip + pip install ruff==0.4.3 + - name: Run linter (ruff) + run: | + ruff check --output-format=github . + - name: Run formatter (ruff) + run: | + ruff format --check