diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 861f3213..6ce93b0f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,22 +21,16 @@ jobs: uses: ./.github/workflows/check_package.yml with: package-name: ${{ matrix.package-name }} - check_analyzers_grpc_gen: - name: Check analyzers for grpc_generator - uses: ./.github/workflows/check_analyzers.yml - with: - package-name: grpc_generator - package-base-path: tools run_unit_tests: name: Run unit tests uses: ./.github/workflows/run_unit_tests.yml - needs: [check_package, check_analyzers_grpc_gen] + needs: check_package report_test_results: name: Report test results uses: ./.github/workflows/report_test_results.yml - needs: [run_unit_tests] + needs: run_unit_tests if: always() permissions: contents: read checks: write - pull-requests: write \ No newline at end of file + pull-requests: write diff --git a/.github/workflows/check_analyzers.yml b/.github/workflows/check_analyzers.yml index 55e6504f..76e7d57f 100644 --- a/.github/workflows/check_analyzers.yml +++ b/.github/workflows/check_analyzers.yml @@ -8,7 +8,7 @@ on: default: '' required: true type: string - package-base-path: + package-basepath: description: 'The parent directory of the package to check. Defaults to packages.' default: 'packages' required: false @@ -26,7 +26,7 @@ jobs: defaults: run: # Set the working-directory for all steps in this job. - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }} steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -42,8 +42,8 @@ jobs: - name: Cache virtualenv uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: - path: ${{ inputs.package-base-path }}/${{ inputs.package-name }}/.venv - key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-base-path, inputs.package-name)) }} + path: ${{ inputs.package-basepath }}/${{ inputs.package-name }}/.venv + key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }} - name: Install ${{ inputs.package-name }} run: | if [ "${{ inputs.install-drivers }}" = "true" ]; then @@ -66,10 +66,10 @@ jobs: with: python-platform: Linux version: PATH - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }} - name: Pyright static analysis (Windows) uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 with: python-platform: Windows version: PATH - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }} diff --git a/.github/workflows/check_docs.yml b/.github/workflows/check_docs.yml index 81cdea43..69db5681 100644 --- a/.github/workflows/check_docs.yml +++ b/.github/workflows/check_docs.yml @@ -8,6 +8,11 @@ on: default: '' required: true type: string + package-basepath: + description: 'The parent directory of the package.' + default: '' + required: true + type: string jobs: check_docs: @@ -16,7 +21,7 @@ jobs: defaults: run: # Set the working-directory for all steps in this job. - working-directory: ./packages/${{ inputs.package-name }} + working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }} steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -31,7 +36,7 @@ jobs: uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: .venv - key: ${{ inputs.package-name }}-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('packages/{0}/poetry.lock', inputs.package-name)) }} + key: ${{ inputs.package-name }}-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }} - name: Install nitypes (with docs) run: poetry install -v --only main,docs - name: Generate docs @@ -40,4 +45,4 @@ jobs: uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ inputs.package-name }}-docs - path: packages/${{ inputs.package-name }}/docs/_build/ \ No newline at end of file + path: ${{ inputs.package-basepath }}/${{ inputs.package-name }}/docs/_build/ diff --git a/.github/workflows/check_package.yml b/.github/workflows/check_package.yml index 8ddbdfec..4e76d825 100644 --- a/.github/workflows/check_package.yml +++ b/.github/workflows/check_package.yml @@ -16,7 +16,7 @@ jobs: with: package-name: ${{ inputs.package-name }} check_codegen: - if: ${{ needs.get_package_info.outputs.proto-subpath != '' }} + if: ${{ needs.get_package_info.outputs.should-check-codegen == 'true' }} name: Check codegen for ${{ inputs.package-name }} needs: get_package_info uses: ./.github/workflows/check_codegen.yml @@ -25,7 +25,7 @@ jobs: proto-basepath: ${{ needs.get_package_info.outputs.proto-basepath }} proto-subpath: ${{ needs.get_package_info.outputs.proto-subpath }} proto-include-path: ${{ needs.get_package_info.outputs.proto-include-path }} - output-basepath: ./packages/${{ inputs.package-name }}/src + output-basepath: ./${{ needs.get_package_info.outputs.package-basepath }}/${{ inputs.package-name }}/src output-format: ${{ needs.get_package_info.outputs.output-format }} check_analyzers: name: Check analyzers for ${{ inputs.package-name }} @@ -33,9 +33,13 @@ jobs: uses: ./.github/workflows/check_analyzers.yml with: package-name: ${{ inputs.package-name }} + package-basepath: ${{ needs.get_package_info.outputs.package-basepath }} install-drivers: ${{ needs.get_package_info.outputs.install-drivers == 'true' }} check_docs: + if: ${{ needs.get_package_info.outputs.should-check-docs == 'true' }} name: Check docs for ${{ inputs.package-name }} + needs: get_package_info uses: ./.github/workflows/check_docs.yml with: - package-name: ${{ inputs.package-name }} \ No newline at end of file + package-name: ${{ inputs.package-name }} + package-basepath: ${{ needs.get_package_info.outputs.package-basepath }} diff --git a/.github/workflows/get_package_info.yml b/.github/workflows/get_package_info.yml index 772c0794..b1544d28 100644 --- a/.github/workflows/get_package_info.yml +++ b/.github/workflows/get_package_info.yml @@ -9,6 +9,9 @@ on: required: true type: string outputs: + package-basepath: + description: 'The parent directory of the package.' + value: ${{ jobs.get_package_info.outputs.package-basepath }} proto-basepath: description: 'Base path for proto files.' value: ${{ jobs.get_package_info.outputs.proto-basepath }} @@ -24,17 +27,30 @@ on: install-drivers: description: 'Whether to install drivers extra' value: ${{ jobs.get_package_info.outputs.install-drivers }} + should-check-codegen: + description: 'Whether to check protobuf code generation' + value: ${{ jobs.get_package_info.outputs.should-check-codegen }} + should-check-docs: + description: 'Whether to check documentation generation' + value: ${{ jobs.get_package_info.outputs.should-check-docs }} + should-run-tests: + description: 'Whether to run automated tests' + value: ${{ jobs.get_package_info.outputs.should-run-tests }} jobs: get_package_info: name: Get package info for ${{ inputs.package-name }} runs-on: ubuntu-latest outputs: + package-basepath: ${{ steps.parse_json.outputs.package-basepath }} proto-basepath: ${{ steps.parse_json.outputs.proto-basepath }} proto-subpath: ${{ steps.parse_json.outputs.proto-subpath }} proto-include-path: ${{ steps.parse_json.outputs.proto-include-path }} output-format: ${{ steps.parse_json.outputs.output-format }} install-drivers: ${{ steps.parse_json.outputs.install-drivers }} + should-check-codegen: ${{ steps.parse_json.outputs.should-check-codegen }} + should-check-docs: ${{ steps.parse_json.outputs.should-check-docs }} + should-run-tests: ${{ steps.parse_json.outputs.should-run-tests }} steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -48,8 +64,40 @@ jobs: exit 1 fi echo "Package info: $info" - echo "proto-basepath=$(echo $info | jq -r '."proto-basepath"')" >> $GITHUB_OUTPUT - echo "proto-subpath=$(echo $info | jq -r '."proto-subpath"')" >> $GITHUB_OUTPUT - echo "proto-include-path=$(echo $info | jq -r '."proto-include-path"')" >> $GITHUB_OUTPUT - echo "output-format=$(echo $info | jq -r '."output-format"')" >> $GITHUB_OUTPUT - echo "install-drivers=$(echo $info | jq -r '."install-drivers"')" >> $GITHUB_OUTPUT \ No newline at end of file + package_basepath=$(echo $info | jq -r '."package-basepath"') + proto_basepath=$(echo $info | jq -r '."proto-basepath"') + proto_subpath=$(echo $info | jq -r '."proto-subpath"') + proto_include_path=$(echo $info | jq -r '."proto-include-path"') + output_format=$(echo $info | jq -r '."output-format"') + install_drivers=$(echo $info | jq -r '."install-drivers"') + + should_check_codegen=false + if [ "${proto_subpath}" != "null" ] + then + should_check_codegen=true + fi + + should_check_docs=false + if [ -d "${GITHUB_WORKSPACE}/${package_basepath}/${{ inputs.package-name }}/docs" ] + then + should_check_docs=true + fi + + should_run_tests=false + if [ -d "${GITHUB_WORKSPACE}/${package_basepath}/${{ inputs.package-name }}/tests" ] + then + should_run_tests=true + fi + + echo "package-basepath=${package_basepath}" >> $GITHUB_OUTPUT + echo "proto-basepath="${proto_basepath} >> $GITHUB_OUTPUT + echo "proto-subpath=${proto_subpath}" >> $GITHUB_OUTPUT + echo "proto-include-path=${proto_include_path}" >> $GITHUB_OUTPUT + echo "output-format=${output_format}" >> $GITHUB_OUTPUT + echo "install-drivers=${install_drivers}" >> $GITHUB_OUTPUT + echo "should-check-codegen=${should_check_codegen}" >> $GITHUB_OUTPUT + echo "should-check-docs=${should_check_docs}" >> $GITHUB_OUTPUT + echo "should-run-tests=${should_run_tests}" >> $GITHUB_OUTPUT + - name: Show package info + run: | + echo "${{ toJSON(steps.parse_json.outputs) }}" diff --git a/packages.json b/packages.json index c5a666f9..d3c2c878 100644 --- a/packages.json +++ b/packages.json @@ -1,87 +1,130 @@ { + "grpc_generator": { + "package-basepath": "tools", + "proto-basepath": null, + "proto-subpath": null, + "proto-include-path": null, + "output-format": null, + "install-drivers": null + }, "ni.datamonikers.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/datamonikers/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni-grpc-extensions" : { - "proto-subpath": "", - "output-format": "" + "package-basepath": "packages", + "proto-basepath": null, + "proto-subpath": null, + "proto-include-path": null, + "output-format": null, + "install-drivers": null }, "ni.grpcdevice.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./proto", "proto-subpath": ".", "proto-include-path": "./proto", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.discovery.v1.client": { - "proto-subpath": "", - "output-format": "" + "package-basepath": "packages", + "proto-basepath": null, + "proto-subpath": null, + "proto-include-path": null, + "output-format": null, + "install-drivers": null }, "ni.measurementlink.discovery.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink/discovery/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.measurement.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink/measurement/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.measurement.v2.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink/measurement/v2", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.pinmap.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink/pinmap/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurementlink.sessionmanagement.v1.client": { - "proto-subpath": "", - "output-format": "", + "package-basepath": "packages", + "proto-basepath": null, + "proto-subpath": null, + "proto-include-path": null, + "output-format": null, "install-drivers": true }, "ni.measurementlink.sessionmanagement.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurementlink/sessionmanagement/v1", "proto-include-path": "./third_party/ni-apis/ni/grpcdevice/v1", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurements.data.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurements/data/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.measurements.metadata.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/measurements/metadata/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "subpackage" + "output-format": "subpackage", + "install-drivers": null }, "ni.panels.v1.proto": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/panels/v1", "proto-include-path": "./third_party/ni-apis", - "output-format": "submodule" + "output-format": "submodule", + "install-drivers": null }, "ni.protobuf.types": { + "package-basepath": "packages", "proto-basepath": "./third_party/ni-apis", "proto-subpath": "ni/protobuf/types", "proto-include-path": "./third_party/ni-apis", - "output-format": "submodule" + "output-format": "submodule", + "install-drivers": null } -} \ No newline at end of file +}