|
| 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 }} |
0 commit comments