From 9a9dbb23d578b5f5ecf9a0ac2691483a690bd8eb Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Tue, 24 Jun 2025 11:18:24 -0500 Subject: [PATCH 1/3] Initial submission of workflow files with simplified CI. Signed-off-by: Michael Johansen Fix the working directory setting. Signed-off-by: Michael Johansen Specify working directory for pyright. Signed-off-by: Michael Johansen I put the input in the wrong spot. Signed-off-by: Michael Johansen Remove unused workflows. They will be added in later. Signed-off-by: Michael Johansen --- .github/workflows/CI.yml | 17 ++++++ .github/workflows/PR.yml | 22 ++++++++ .github/workflows/check_ni_protobuf_types.yml | 53 +++++++++++++++++++ .github/workflows/check_ni_pythonpanel_v1.yml | 53 +++++++++++++++++++ .../src/ni/protobuf/__init__.py | 1 + .../src/ni/protobuf/types/placeholder.py | 1 + .../tests/test_placeholder.py | 5 ++ .../src/ni/pythonpanel/v1/__init__.py | 1 + .../tests/test_placeholder.py | 5 ++ 9 files changed, 158 insertions(+) create mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/PR.yml create mode 100644 .github/workflows/check_ni_protobuf_types.yml create mode 100644 .github/workflows/check_ni_pythonpanel_v1.yml create mode 100644 packages/ni.protobuf.types/src/ni/protobuf/__init__.py create mode 100644 packages/ni.protobuf.types/src/ni/protobuf/types/placeholder.py create mode 100644 packages/ni.protobuf.types/tests/test_placeholder.py create mode 100644 packages/ni.pythonpanel.v1.proto/src/ni/pythonpanel/v1/__init__.py create mode 100644 packages/ni.pythonpanel.v1.proto/tests/test_placeholder.py diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..9baadf68 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: + - main + - 'releases/**' + workflow_call: + workflow_dispatch: + +jobs: + check_ni_protobuf_types: + name: Check ni.protobuf.types + uses: ./.github/workflows/check_ni_protobuf_types.yml + check_ni_pythonpanel_v1_proto: + name: Check ni.pythonpanel.v1.proto + uses: ./.github/workflows/check_ni_pythonpanel_v1.yml diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml new file mode 100644 index 00000000..2886cc3b --- /dev/null +++ b/.github/workflows/PR.yml @@ -0,0 +1,22 @@ +name: PR + +on: + pull_request: + branches: + - main + - 'releases/**' + workflow_call: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + run_ci: + name: Run CI + uses: ./.github/workflows/CI.yml + permissions: + contents: read + checks: write + pull-requests: write \ No newline at end of file diff --git a/.github/workflows/check_ni_protobuf_types.yml b/.github/workflows/check_ni_protobuf_types.yml new file mode 100644 index 00000000..267b4670 --- /dev/null +++ b/.github/workflows/check_ni_protobuf_types.yml @@ -0,0 +1,53 @@ +name: Check ni.protobuf.types + +on: + workflow_call: + workflow_dispatch: + +jobs: + check_package: + name: Check ni.protobuf.types + runs-on: ubuntu-latest + defaults: + run: + # Set the working-directory for all steps in this job. + working-directory: ./packages/ni.protobuf.types + steps: + - name: Check out repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set up Python + uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 + id: setup-python + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 + - name: Check for lock changes + run: poetry check --lock + - name: Cache virtualenv + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: packages/ni.protobuf.types/.venv + key: ni.protobuf.types-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/ni.protobuf.types/poetry.lock') }} + - name: Install ni.protobuf.types + run: poetry install -v + - name: Lint + run: poetry run ni-python-styleguide lint + - name: Mypy static analysis (Linux) + run: poetry run mypy + - name: Mypy static analysis (Windows) + run: poetry run mypy --platform win32 + - name: Bandit security checks + run: poetry run bandit -c pyproject.toml -r src/ni/protobuf + - name: Add virtualenv to the path for pyright-action + run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - name: Pyright static analysis (Linux) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Linux + version: PATH + working-directory: ./packages/ni.protobuf.types + - name: Pyright static analysis (Windows) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Windows + version: PATH + working-directory: ./packages/ni.protobuf.types diff --git a/.github/workflows/check_ni_pythonpanel_v1.yml b/.github/workflows/check_ni_pythonpanel_v1.yml new file mode 100644 index 00000000..8205e297 --- /dev/null +++ b/.github/workflows/check_ni_pythonpanel_v1.yml @@ -0,0 +1,53 @@ +name: Check ni.pythonpanel.v1.proto + +on: + workflow_call: + workflow_dispatch: + +jobs: + check_package: + name: Check ni.pythonpanel.v1.proto + runs-on: ubuntu-latest + defaults: + run: + # Set the working-directory for all steps in this job. + working-directory: ./packages/ni.pythonpanel.v1.proto + steps: + - name: Check out repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set up Python + uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 + id: setup-python + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 + - name: Check for lock changes + run: poetry check --lock + - name: Cache virtualenv + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: .venv + key: ni.pythonpanel.v1.proto-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} + - name: Install ni.pythonpanel.v1.proto + run: poetry install -v + - name: Lint + run: poetry run ni-python-styleguide lint + - name: Mypy static analysis (Linux) + run: poetry run mypy + - name: Mypy static analysis (Windows) + run: poetry run mypy --platform win32 + - name: Bandit security checks + run: poetry run bandit -c pyproject.toml -r src/ni/pythonpanel/v1 + - name: Add virtualenv to the path for pyright-action + run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - name: Pyright static analysis (Linux) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Linux + version: PATH + working-directory: ./packages/ni.pythonpanel.v1.proto + - name: Pyright static analysis (Windows) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Windows + version: PATH + working-directory: ./packages/ni.pythonpanel.v1.proto diff --git a/packages/ni.protobuf.types/src/ni/protobuf/__init__.py b/packages/ni.protobuf.types/src/ni/protobuf/__init__.py new file mode 100644 index 00000000..1a5e2f46 --- /dev/null +++ b/packages/ni.protobuf.types/src/ni/protobuf/__init__.py @@ -0,0 +1 @@ +"""Package for ni.protobuf.types.""" diff --git a/packages/ni.protobuf.types/src/ni/protobuf/types/placeholder.py b/packages/ni.protobuf.types/src/ni/protobuf/types/placeholder.py new file mode 100644 index 00000000..0fa6b227 --- /dev/null +++ b/packages/ni.protobuf.types/src/ni/protobuf/types/placeholder.py @@ -0,0 +1 @@ +"""This is a placeholder file for the package while we implement code generation.""" diff --git a/packages/ni.protobuf.types/tests/test_placeholder.py b/packages/ni.protobuf.types/tests/test_placeholder.py new file mode 100644 index 00000000..de29cbcf --- /dev/null +++ b/packages/ni.protobuf.types/tests/test_placeholder.py @@ -0,0 +1,5 @@ +"""Tests for the ni.protobuf.types package.""" + + +def test___placeholder() -> None: + pass diff --git a/packages/ni.pythonpanel.v1.proto/src/ni/pythonpanel/v1/__init__.py b/packages/ni.pythonpanel.v1.proto/src/ni/pythonpanel/v1/__init__.py new file mode 100644 index 00000000..133c0e6c --- /dev/null +++ b/packages/ni.pythonpanel.v1.proto/src/ni/pythonpanel/v1/__init__.py @@ -0,0 +1 @@ +"""Package for ni.pythonpanel.v1.proto.""" diff --git a/packages/ni.pythonpanel.v1.proto/tests/test_placeholder.py b/packages/ni.pythonpanel.v1.proto/tests/test_placeholder.py new file mode 100644 index 00000000..37d9b66d --- /dev/null +++ b/packages/ni.pythonpanel.v1.proto/tests/test_placeholder.py @@ -0,0 +1,5 @@ +"""Tests for the ni.pythonpanel.v1.proto package.""" + + +def test___placeholder() -> None: + pass From 541295487dec4086af08f13030097a09a3f7ba1c Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Tue, 24 Jun 2025 14:25:38 -0500 Subject: [PATCH 2/3] Try shortening the path passed to bandit to see if we can combine check yml files. Signed-off-by: Michael Johansen --- .github/workflows/check_ni_protobuf_types.yml | 2 +- .github/workflows/check_ni_pythonpanel_v1.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_ni_protobuf_types.yml b/.github/workflows/check_ni_protobuf_types.yml index 267b4670..d1dbb985 100644 --- a/.github/workflows/check_ni_protobuf_types.yml +++ b/.github/workflows/check_ni_protobuf_types.yml @@ -36,7 +36,7 @@ jobs: - name: Mypy static analysis (Windows) run: poetry run mypy --platform win32 - name: Bandit security checks - run: poetry run bandit -c pyproject.toml -r src/ni/protobuf + run: poetry run bandit -c pyproject.toml -r src/ni - name: Add virtualenv to the path for pyright-action run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH - name: Pyright static analysis (Linux) diff --git a/.github/workflows/check_ni_pythonpanel_v1.yml b/.github/workflows/check_ni_pythonpanel_v1.yml index 8205e297..69055e85 100644 --- a/.github/workflows/check_ni_pythonpanel_v1.yml +++ b/.github/workflows/check_ni_pythonpanel_v1.yml @@ -36,7 +36,7 @@ jobs: - name: Mypy static analysis (Windows) run: poetry run mypy --platform win32 - name: Bandit security checks - run: poetry run bandit -c pyproject.toml -r src/ni/pythonpanel/v1 + run: poetry run bandit -c pyproject.toml -r src/ni - name: Add virtualenv to the path for pyright-action run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH - name: Pyright static analysis (Linux) From f48c3edfa7895fc6220cb9935f6c0e0613b231f1 Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Tue, 24 Jun 2025 14:34:09 -0500 Subject: [PATCH 3/3] Combine check_*.yml into a single check_package.yml file with an input. Signed-off-by: Michael Johansen --- .github/workflows/CI.yml | 8 ++- .github/workflows/check_ni_pythonpanel_v1.yml | 53 ------------------- ...i_protobuf_types.yml => check_package.yml} | 24 +++++---- 3 files changed, 21 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/check_ni_pythonpanel_v1.yml rename .github/workflows/{check_ni_protobuf_types.yml => check_package.yml} (68%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9baadf68..df5c8116 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,7 +11,11 @@ on: jobs: check_ni_protobuf_types: name: Check ni.protobuf.types - uses: ./.github/workflows/check_ni_protobuf_types.yml + uses: ./.github/workflows/check_package.yml + with: + package_name: ni.protobuf.types check_ni_pythonpanel_v1_proto: name: Check ni.pythonpanel.v1.proto - uses: ./.github/workflows/check_ni_pythonpanel_v1.yml + uses: ./.github/workflows/check_package.yml + with: + package_name: ni.pythonpanel.v1.proto diff --git a/.github/workflows/check_ni_pythonpanel_v1.yml b/.github/workflows/check_ni_pythonpanel_v1.yml deleted file mode 100644 index 69055e85..00000000 --- a/.github/workflows/check_ni_pythonpanel_v1.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Check ni.pythonpanel.v1.proto - -on: - workflow_call: - workflow_dispatch: - -jobs: - check_package: - name: Check ni.pythonpanel.v1.proto - runs-on: ubuntu-latest - defaults: - run: - # Set the working-directory for all steps in this job. - working-directory: ./packages/ni.pythonpanel.v1.proto - steps: - - name: Check out repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Set up Python - uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 - id: setup-python - - name: Set up Poetry - uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1 - - name: Check for lock changes - run: poetry check --lock - - name: Cache virtualenv - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - with: - path: .venv - key: ni.pythonpanel.v1.proto-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - - name: Install ni.pythonpanel.v1.proto - run: poetry install -v - - name: Lint - run: poetry run ni-python-styleguide lint - - name: Mypy static analysis (Linux) - run: poetry run mypy - - name: Mypy static analysis (Windows) - run: poetry run mypy --platform win32 - - name: Bandit security checks - run: poetry run bandit -c pyproject.toml -r src/ni - - name: Add virtualenv to the path for pyright-action - run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH - - name: Pyright static analysis (Linux) - uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 - with: - python-platform: Linux - version: PATH - working-directory: ./packages/ni.pythonpanel.v1.proto - - name: Pyright static analysis (Windows) - uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 - with: - python-platform: Windows - version: PATH - working-directory: ./packages/ni.pythonpanel.v1.proto diff --git a/.github/workflows/check_ni_protobuf_types.yml b/.github/workflows/check_package.yml similarity index 68% rename from .github/workflows/check_ni_protobuf_types.yml rename to .github/workflows/check_package.yml index d1dbb985..54c43ae7 100644 --- a/.github/workflows/check_ni_protobuf_types.yml +++ b/.github/workflows/check_package.yml @@ -1,17 +1,23 @@ -name: Check ni.protobuf.types +name: Check Package on: workflow_call: + inputs: + package_name: + description: 'The name of the package to check.' + default: '' + required: true + type: string workflow_dispatch: jobs: check_package: - name: Check ni.protobuf.types + name: Check ${{ inputs.package_name }} runs-on: ubuntu-latest defaults: run: # Set the working-directory for all steps in this job. - working-directory: ./packages/ni.protobuf.types + working-directory: ./packages/${{ inputs.package_name }} steps: - name: Check out repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -25,9 +31,9 @@ jobs: - name: Cache virtualenv uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 with: - path: packages/ni.protobuf.types/.venv - key: ni.protobuf.types-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/ni.protobuf.types/poetry.lock') }} - - name: Install ni.protobuf.types + path: packages/${{ inputs.package_name }}/.venv + key: ${{ inputs.package_name }}-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/${{ inputs.package_name }}/poetry.lock') }} + - name: Install ${{ inputs.package_name }} run: poetry install -v - name: Lint run: poetry run ni-python-styleguide lint @@ -36,7 +42,7 @@ jobs: - name: Mypy static analysis (Windows) run: poetry run mypy --platform win32 - name: Bandit security checks - run: poetry run bandit -c pyproject.toml -r src/ni + run: poetry run bandit -c pyproject.toml -r src/ - name: Add virtualenv to the path for pyright-action run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH - name: Pyright static analysis (Linux) @@ -44,10 +50,10 @@ jobs: with: python-platform: Linux version: PATH - working-directory: ./packages/ni.protobuf.types + working-directory: ./packages/${{ inputs.package_name }} - name: Pyright static analysis (Windows) uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 with: python-platform: Windows version: PATH - working-directory: ./packages/ni.protobuf.types + working-directory: ./packages/${{ inputs.package_name }}