Skip to content

CLOUDP-296897: Allow to select tests to run #2240

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

Merged
merged 19 commits into from
Apr 2, 2025

Conversation

igor-karpukhin
Copy link
Collaborator

@igor-karpukhin igor-karpukhin commented Mar 31, 2025

Summary

This PR introduces a new workflow that allows to selectively run tests based on Github labels
Examples:

  • test/e2e/* - runs all e2e tests
  • test/e2e/Atlas* - runs e2e tests whose Ginkgo test labels starts with Atlas
  • test/e2e/AtlasBackupSchedule - runs specific e2e test with Ginkgo label AtlasBackupSchedule
  • test/int/* - runs all integration
  • test/int/alert-* - runs integration tests whose Ginkgo test labels starts with alert-
  • test/int/alert-config - runs specific integration test with Ginkgo label alert-config

The workflow is triggered for opened, labeled and modified PR. The workflow is triggered for every labels change.

This PR doesn't break existing workflow. The previous workflow can still be triggered by applying cloud-tests label.

Proof of Work

See the workflow results

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?
  • Have you signed our CLA?

@igor-karpukhin igor-karpukhin requested a review from a team as a code owner March 31, 2025 13:39
@igor-karpukhin igor-karpukhin marked this pull request as draft March 31, 2025 13:40
Comment on lines +6 to +7
pull_request:
types: [opened, synchronize, labeled, unlabeled]
Copy link
Collaborator

@josvazg josvazg Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: Note this will never work for external contributors. For security reasons, the pull_request event uses the credentials from the contributor's fork repo, not the AKO repo. For accepting external contributions pull_request_target needs to be used instead, but in such case, when the contribution is external, a gating mechanism needs to be set in place to avoid external forks to access and peek or abuse AKO creds without us even been able to stop it (for instance, "if external, the safe-to-test label must also be present").

BTW, one current issue I had when tying to fix these external workflows is that if you have pull_request & pull_request_target both set, they will trigger and your workflows might duplicate. I guess the best way is, either make sure only one can fire at a time (pull_request only for owners and pull_request_target only for contributors) or use only pull_request_target with gating for non owners.

q: Was intended to skip external contributions? It is fine, as the CI is still broken in general for that use case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think we can drop the CI runs for PRs from forked repos for now. I'll create a follow up ticket

uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'pull_request') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: remember this if pull_request_target is added in the PR.

Comment on lines +87 to +92
./bin/ginkgo-labels > result.json
echo "Int tests to execute $(cat result.json | jq -c .int)"
echo "E2E tests to execute $(cat result.json | jq -c .e2e)"

echo "int_matrix=$(cat result.json | jq -c .int)" >> $GITHUB_OUTPUT
echo "e2e_matrix=$(cat result.json | jq -c .e2e)" >> $GITHUB_OUTPUT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: we'll need to take this into account when we split helm chart tests from e2e


# run: |
# cd ./test/e2e
# ginkgo --label-filter="${{ matrix.test }}" -r --fail-fast
Copy link
Collaborator

@josvazg josvazg Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: interesting this --fail-fast, should we be more explicit about this? I mean this means when the PR fails there might be more errors to check on the same label that failed in the CI
But I agree we probably want this to be less wasteful with CI tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed by executing the devbox

.PHONY: compute-labels
compute-labels:
mkdir -p bin
go build -o bin/ginkgo-labels tools/compute-test-labels/main.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Not for this PR, but a thought in general. Should we group all AKO dev tools in a single tool repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can think about that if there are good reasons for that. So far, nothing stops us for having tools in the /tools folder.

Comment on lines +11 to +14
func jsonDump(data interface{}) string {
r, _ := json.Marshal(data)
return string(r)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: I use this exact same code a lot when debugging, we might want to have it in a library somewhere in internal. It will be a different copy here, though.

Copy link
Collaborator

@josvazg josvazg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on a few questions, but LGTM overall.
Great job!

USE_JSON: true
run: |
make compute-labels
./bin/ginkgo-labels > result.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q why not just go run ....?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also possible, but I decided to go with the go build option

Copy link
Collaborator

@josvazg josvazg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! great job!

@igor-karpukhin igor-karpukhin merged commit 68cee29 into main Apr 2, 2025
17 checks passed
@igor-karpukhin igor-karpukhin deleted the CLOUDP-296897/selectabe-tests branch April 2, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants