Skip to content

Commit f5db5f6

Browse files
mjohanse-emrMichael Johansen
andauthored
Add a workflow that checks that codegen is up-to-date. (#16)
* Add a workflow that checks that codegen is up-to-date. Signed-off-by: Michael Johansen <[email protected]> * Add git clean flags back in. Signed-off-by: Michael Johansen <[email protected]> * Used the wrong package name in the job title. Signed-off-by: Michael Johansen <[email protected]> * Fix comment. Signed-off-by: Michael Johansen <[email protected]> * Update the working directory for the git diff call so it actually sees diffs. Signed-off-by: Michael Johansen <[email protected]> * Try setting to ./ to get it to use the root dir. Signed-off-by: Michael Johansen <[email protected]> * Add a path argument to the diff command instead of using working-directory. Signed-off-by: Michael Johansen <[email protected]> * Try using the github_workspace env variable for the working-directory. Signed-off-by: Michael Johansen <[email protected]> * Maybe . will do it. Signed-off-by: Michael Johansen <[email protected]> * Remove default working directory and explicitly specify it where needed. Signed-off-by: Michael Johansen <[email protected]> * Try manually changing one of the codegen files to see if diff is failing because the latest change just added files. Signed-off-by: Michael Johansen <[email protected]> * Revert change to generated file. Signed-off-by: Michael Johansen <[email protected]> * Go back to using default run dir. Make a generated file change to make sure the diff still works. * Try and handle untracked files by doing a git add and diffing staged. Signed-off-by: Michael Johansen <[email protected]> * Fix the working directory. Signed-off-by: Michael Johansen <[email protected]> * Revert codegened file change. Signed-off-by: Michael Johansen <[email protected]> * Get rid of cleanup step since each job runs in a separate docker container. Signed-off-by: Michael Johansen <[email protected]> * Rename workflow file and apply other review feedback. Signed-off-by: Michael Johansen <[email protected]> * Make proto-basepth optional. Signed-off-by: Michael Johansen <[email protected]> * Token change to get this PR to re-merge. Signed-off-by: Michael Johansen <[email protected]> --------- Signed-off-by: Michael Johansen <[email protected]> Co-authored-by: Michael Johansen <[email protected]>
1 parent b5941f1 commit f5db5f6

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

.github/workflows/CI.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12+
check_codegen_ni_protobuf_types:
13+
name: Check codegen up-to-date for ni.protobuf.types
14+
uses: ./.github/workflows/check_codegen.yml
15+
with:
16+
proto-subpath: ni/protobuf/types
17+
output-basepath: ../../packages/ni.protobuf.types/src
18+
output-format: submodule
1219
check_ni_protobuf_types:
1320
name: Check ni.protobuf.types
1421
uses: ./.github/workflows/check_package.yml
22+
needs: [check_codegen_ni_protobuf_types]
1523
with:
1624
package-name: ni.protobuf.types
1725
check_ni_pythonpanel_v1_proto:
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Check codegen up to date
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
proto-basepath:
7+
description: 'The base path for proto files used for generation.'
8+
default: '../../third_party/ni-apis'
9+
type: string
10+
proto-subpath:
11+
description: 'The path to proto files relative to proto-base-path.'
12+
default: ''
13+
required: true
14+
type: string
15+
output-basepath:
16+
description: 'The base output path for codegened files.'
17+
default: ''
18+
required: true
19+
type: string
20+
output-format:
21+
description: 'The format for the generated stubs. Options are submodule and subpackage.'
22+
default: ''
23+
required: true
24+
type: string
25+
26+
jobs:
27+
check_codegen:
28+
name: Check codegen up to date
29+
runs-on: ubuntu-latest
30+
defaults:
31+
run:
32+
# Set the working-directory for all steps in this job.
33+
working-directory: ./tools/grpc_generator
34+
steps:
35+
- name: Check out repo
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
with:
38+
submodules: true
39+
- name: Set up Python
40+
uses: ni/python-actions/setup-python@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
41+
id: setup-python
42+
- name: Set up Poetry
43+
uses: ni/python-actions/setup-poetry@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
44+
- name: Check for lock changes
45+
run: poetry check --lock
46+
- name: Cache virtualenv
47+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
48+
with:
49+
path: tools/grpc_generator/.venv
50+
key: grpc_generator-only-main-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('tools/grpc_generator/poetry.lock') }}
51+
- name: Install grpc_generator
52+
run: poetry install -v --only main
53+
- name: Generate gRPC stubs
54+
run: |
55+
poetry run grpc-generator --proto-basepath ${{ inputs.proto-basepath }} --proto-subpath ${{ inputs.proto-subpath }} --output-basepath ${{ inputs.output-basepath }} --output-format ${{ inputs.output-format }}
56+
- name: Check for out-of-date gRPC stubs
57+
run: |
58+
git add ${{ inputs.output-basepath }}
59+
git diff --exit-code --staged ${{ inputs.output-basepath }}
60+
git diff --exit-code ${{ inputs.output-basepath }}

.github/workflows/check_package.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
default: ''
99
required: true
1010
type: string
11-
workflow_dispatch:
1211

1312
jobs:
1413
check_package:

0 commit comments

Comments
 (0)