-
Notifications
You must be signed in to change notification settings - Fork 127
Add testmask tool for conditional CI test execution #4017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1c4de3
352c618
c2af5e1
647b7f4
194b165
a289e7f
ed8dc5b
edc1f99
e166105
8d97d8f
0fe377f
cc0c351
72275e3
08501cc
5bd2beb
77679fd
d1d7c0b
2a985f4
f5364e4
1d4dfb9
1fd2afc
3230dfc
3bec8a6
87ef57d
1d5686c
1d9726a
fc4268b
b9fcdbc
5982b8b
459f899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: 'Setup Build Environment' | ||
| description: 'Sets up the build environment with Go, Python, uv, and ruff' | ||
|
|
||
| inputs: | ||
| cache-key: | ||
| description: 'Cache key identifier for Go cache' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Create cache identifier | ||
| run: echo "${{ inputs.cache-key }}" > cache.txt | ||
| shell: bash | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache-dependency-path: | | ||
| go.sum | ||
| cache.txt | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2 | ||
| with: | ||
| version: "0.8.9" | ||
|
|
||
| - name: Install ruff (Python linter and formatter) | ||
| uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 | ||
| with: | ||
| version: "0.9.1" | ||
| args: "--version" | ||
|
|
||
| - name: Pull external libraries | ||
| run: | | ||
| go mod download | ||
| pip3 install wheel==0.45.1 | ||
| shell: bash |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,52 @@ jobs: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: gh cache delete --all --repo databricks/cli || true | ||
|
|
||
| testmask: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| targets: ${{ steps.mask1.outputs.targets || steps.mask2.outputs.targets || steps.mask3.outputs.targets }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | ||
| with: | ||
| go-version-file: tools/go.mod | ||
|
|
||
| - name: Run testmask (pull requests) | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| id: mask1 | ||
| working-directory: tools/testmask | ||
| run: | | ||
| go run . ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} | tee output.json | ||
| echo "targets=$(jq -c '.' output.json)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Run testmask (merge group) | ||
| if: ${{ github.event_name == 'merge_group' }} | ||
| id: mask2 | ||
| working-directory: tools/testmask | ||
| run: | | ||
| go run . ${{ github.event.merge_group.head_sha }} ${{ github.event.merge_group.base_sha }} | tee output.json | ||
| echo "targets=$(jq -c '.' output.json)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Run testmask (other events) | ||
| if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }} | ||
| id: mask3 | ||
| working-directory: tools/testmask | ||
| run: | | ||
| # Always run all tests | ||
| echo "targets=[\"test\"]" >> $GITHUB_OUTPUT | ||
|
|
||
| tests: | ||
| needs: cleanups | ||
| needs: | ||
| - cleanups | ||
| - testmask | ||
|
|
||
| # Only run if the target is in the list of targets from testmask | ||
| if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test') }} | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
|
|
@@ -53,37 +97,10 @@ jobs: | |
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Create deployment-specific cache identifier | ||
| run: echo "${{ matrix.deployment }}" > deployment-type.txt | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | ||
| - name: Setup build environment | ||
| uses: ./.github/actions/setup-build-environment | ||
| with: | ||
| go-version-file: go.mod | ||
| cache-dependency-path: | | ||
| go.sum | ||
| deployment-type.txt | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2 | ||
| with: | ||
| version: "0.8.9" | ||
|
|
||
| - name: Install ruff (Python linter and formatter) | ||
| uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 | ||
| with: | ||
| version: "0.9.1" | ||
| args: "--version" | ||
|
|
||
| - name: Pull external libraries | ||
| run: | | ||
| go mod download | ||
| pip3 install wheel==0.45.1 | ||
| cache-key: test-${{ matrix.deployment }} | ||
|
|
||
| - name: Run tests without coverage | ||
| # We run tests without coverage on PR, merge_group, and schedule because we don't make use of coverage information | ||
|
|
@@ -104,6 +121,131 @@ jobs: | |
| - name: Analyze slow tests | ||
| run: make slowest | ||
|
|
||
| test-exp-aitools: | ||
| needs: | ||
| - cleanups | ||
| - testmask | ||
|
|
||
| # Only run if the target is in the list of targets from testmask | ||
| if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-exp-aitools') }} | ||
| name: "make test-exp-aitools" | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-latest | ||
| - ubuntu-latest | ||
| - windows-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Setup build environment | ||
| uses: ./.github/actions/setup-build-environment | ||
| with: | ||
| cache-key: test-exp-aitools | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each job has its own build cache to avoid interference. |
||
|
|
||
| - name: Run tests | ||
| run: | | ||
| make test-exp-aitools | ||
|
|
||
| test-exp-apps-mcp: | ||
| needs: | ||
| - cleanups | ||
| - testmask | ||
|
|
||
| # Only run if the target is in the list of targets from testmask | ||
| if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-exp-apps-mcp') }} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not possible to use See https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#context-availability |
||
| name: "make test-exp-apps-mcp" | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-latest | ||
| - ubuntu-latest | ||
| # The Windows tests are broken; see https://github.com/databricks/cli/pull/4024. | ||
| # - windows-latest | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fjakobs Someone needs to take a look at these and uncomment when fixed. |
||
|
|
||
| steps: | ||
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Setup build environment | ||
| uses: ./.github/actions/setup-build-environment | ||
| with: | ||
| cache-key: test-exp-apps-mcp | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| make test-exp-apps-mcp | ||
|
|
||
| test-exp-ssh: | ||
| needs: | ||
| - cleanups | ||
| - testmask | ||
|
|
||
| # Only run if the target is in the list of targets from testmask | ||
| if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-exp-ssh') }} | ||
| name: "make test-exp-ssh" | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-latest | ||
| - ubuntu-latest | ||
| - windows-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Setup build environment | ||
| uses: ./.github/actions/setup-build-environment | ||
| with: | ||
| cache-key: test-exp-ssh | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| make test-exp-ssh | ||
|
|
||
| test-pipelines: | ||
| needs: | ||
| - cleanups | ||
| - testmask | ||
|
|
||
| # Only run if the target is in the list of targets from testmask | ||
| if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-pipelines') }} | ||
| name: "make test-pipelines" | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-latest | ||
| - ubuntu-latest | ||
| - windows-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository and submodules | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - name: Setup build environment | ||
| uses: ./.github/actions/setup-build-environment | ||
| with: | ||
| cache-key: test-pipelines | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| make test-pipelines | ||
|
|
||
| validate-generated-is-up-to-date: | ||
| needs: cleanups | ||
| runs-on: ubuntu-latest | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| default: checks fmt lint | ||
|
|
||
| # gotestsum: when go test args are used with --rerun-fails the list of packages to test must be specified by the --packages flag | ||
| PACKAGES=--packages "./acceptance/... ./libs/... ./internal/... ./cmd/... ./bundle/... ./experimental/aitools/... ./experimental/ssh/... ." | ||
| # Default packages to test (all) | ||
| TEST_PACKAGES = ./acceptance/internal ./libs/... ./internal/... ./cmd/... ./bundle/... ./experimental/aitools/... ./experimental/ssh/... . | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| # Default acceptance test filter (all) | ||
| ACCEPTANCE_TEST_FILTER = "" | ||
|
|
||
| GO_TOOL ?= go tool -modfile=tools/go.mod | ||
| GOTESTSUM_FORMAT ?= pkgname-and-test-fails | ||
|
|
@@ -55,11 +58,24 @@ links: | |
| # Checks other than 'fmt' and 'lint'; these are fast, so can be run first | ||
| checks: tidy ws links | ||
|
|
||
| test: | ||
| ${GOTESTSUM_CMD} ${PACKAGES} -- -timeout=${LOCAL_TIMEOUT} -short | ||
|
|
||
| test-slow: | ||
| ${GOTESTSUM_CMD} ${PACKAGES} -- -timeout=${LOCAL_TIMEOUT} | ||
| # Run short unit and acceptance tests (testing.Short() is true). | ||
| test: test-unit test-acc | ||
|
|
||
| # Run all unit and acceptance tests. | ||
| test-slow: test-slow-unit test-slow-acc | ||
|
|
||
| test-unit: | ||
| ${GOTESTSUM_CMD} --packages "${TEST_PACKAGES}" -- -timeout=${LOCAL_TIMEOUT} -short | ||
|
|
||
| test-slow-unit: | ||
| ${GOTESTSUM_CMD} --packages "${TEST_PACKAGES}" -- -timeout=${LOCAL_TIMEOUT} | ||
pietern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test-acc: | ||
| ${GOTESTSUM_CMD} --packages ./acceptance/... -- -timeout=${LOCAL_TIMEOUT} -short -run ${ACCEPTANCE_TEST_FILTER} | ||
|
|
||
| test-slow-acc: | ||
| ${GOTESTSUM_CMD} --packages ./acceptance/... -- -timeout=${LOCAL_TIMEOUT} -run ${ACCEPTANCE_TEST_FILTER} | ||
|
|
||
| # Updates acceptance test output (local tests) | ||
| test-update: | ||
|
|
@@ -82,7 +98,7 @@ slowest: | |
|
|
||
| cover: | ||
| rm -fr ./acceptance/build/cover/ | ||
| VERBOSE_TEST=1 CLI_GOCOVERDIR=build/cover ${GOTESTSUM_CMD} ${PACKAGES} -- -coverprofile=coverage.txt -timeout=${LOCAL_TIMEOUT} | ||
| VERBOSE_TEST=1 CLI_GOCOVERDIR=build/cover ${GOTESTSUM_CMD} --packages ${TEST_PACKAGES} -- -coverprofile=coverage.txt -timeout=${LOCAL_TIMEOUT} | ||
| rm -fr ./acceptance/build/cover-merged/ | ||
| mkdir -p acceptance/build/cover-merged/ | ||
| go tool covdata merge -i $$(printf '%s,' acceptance/build/cover/* | sed 's/,$$//') -o acceptance/build/cover-merged/ | ||
|
|
@@ -150,4 +166,16 @@ generate: | |
| $(GENKIT_BINARY) update-sdk | ||
|
|
||
|
|
||
| .PHONY: lint lintfull tidy lintcheck fmt fmtfull test cover showcover build snapshot snapshot-release schema integration integration-short acc-cover acc-showcover docs ws wsfix links checks test-update test-update-templates test-update-aws test-update-all generate-validation | ||
| .PHONY: lint lintfull tidy lintcheck fmt fmtfull test test-unit test-acc test-slow test-slow-unit test-slow-acc cover showcover build snapshot snapshot-release schema integration integration-short acc-cover acc-showcover docs ws wsfix links checks test-update test-update-templates test-update-aws test-update-all generate-validation | ||
|
|
||
| test-exp-aitools: | ||
| make test TEST_PACKAGES="./experimental/aitools/..." ACCEPTANCE_TEST_FILTER="TestAccept/idontexistyet/aitools" | ||
|
|
||
| test-exp-apps-mcp: | ||
| make test TEST_PACKAGES="./experimental/apps-mcp/..." ACCEPTANCE_TEST_FILTER="TestAccept/idontexistyet/apps-mcp" | ||
|
|
||
| test-exp-ssh: | ||
| make test TEST_PACKAGES="./experimental/ssh/..." ACCEPTANCE_TEST_FILTER="TestAccept/ssh" | ||
|
|
||
| test-pipelines: | ||
| make test TEST_PACKAGES="./cmd/pipelines/..." ACCEPTANCE_TEST_FILTER="TestAccept/pipelines" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os/exec" | ||
| "strings" | ||
| ) | ||
|
|
||
| // GetChangedFiles returns the list of files changed between two git refs. | ||
| func GetChangedFiles(headRef, baseRef string) ([]string, error) { | ||
| cmd := exec.Command("git", "diff", "--name-only", baseRef, headRef) | ||
| output, err := cmd.Output() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to get diff between %s and %s: %w", baseRef, headRef, err) | ||
| } | ||
|
|
||
| lines := strings.Split(string(output), "\n") | ||
|
|
||
| // Drop the last line (always empty) | ||
| if len(lines) > 0 { | ||
| lines = lines[:len(lines)-1] | ||
| } | ||
|
|
||
| return lines, nil | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the above step name matches the condition, but this one does not? (the pull_request is excluded in both).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another step above it for pull requests.