Skip to content
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

Triggers based on changes to TestSource #4007

Open
gberche-orange opened this issue Jun 8, 2023 · 1 comment
Open

Triggers based on changes to TestSource #4007

gberche-orange opened this issue Jun 8, 2023 · 1 comment
Assignees
Labels
feature-request 🚀 New feature request

Comments

@gberche-orange
Copy link
Contributor

gberche-orange commented Jun 8, 2023

Is your feature request related to a problem? Please describe.

As a testkube test author,
In order to get feedback on changes to my test content when I commit and push them in git
I need to be able to configure a TestTrigger against a TestSource

Describe the solution you'd like

apiVersion: tests.testkube.io/v1
kind: TestTrigger
metadata:
  name: Kubernetes object name
  namespace: Kubernetes object namespace
spec:
  source: # trigger test based on changes to TestSource
    kind: TestSource
    # Any commits that contain the string [ci skip] will be ignored. This allows you to commit to your repository without triggering a new version.
    name: my-git-repo
    paths: # Optional. If specified (as a list of glob patterns), only changes to the specified files will trigger 
    ignore_paths: # Optional. The inverse of paths; changes to the specified files are ignored.
    tag_filter: # Optional. If specified, the resource will only trigger when new commits that have a tag matching the expression that have been made against the branch. Patterns are [glob(7)](http://man7.org/linux/man-pages/man7/glob.7.html) compatible (as in, bash compatible).
   tag_regex: # Optional. If specified, the resource will only detect commits that have a tag matching the expression that have been made against the branch. Patterns are [grep](https://www.gnu.org/software/grep/manual/grep.html) compatible (extended matching enabled, matches entire lines only). Ignored if tag_filter is also specified.

Note that the paths, ignore_paths, tag_filter and tag_regexp are inspired from similar triggers in https://github.com/concourse/git-resource built upon long year of CI/CD experience, including triggering tests from git changes

Note the tag_filter and tag_regexp would require an additional field on the TestSource resource:

  • fetch_tags: Optional. If true the flag --tags will be used to fetch all tags in the repository. If false no tags will be fetched.

Meta data about the conditions that Triggered the test is mounted in /triggers

Specifically the TestSource last change is available in /trigger/source similar to https://github.com/concourse/git-resource#additional-files-populated

.git/committer: For committer notification on failed builds. This special file .git/committer which is populated with the email address of the author of the last commit. This can be used together with an email resource like [mdomke/concourse-email-resource](https://github.com/mdomke/concourse-email-resource) to notify the committer in an on_failure step.

.git/ref: Version reference detected and checked out. It will usually contain the commit SHA-1 ref, but also the detected tag name when using tag_filter or tag_regex.

.git/short_ref: Short (first seven characters) of the .git/ref. Can be templated with short_ref_format parameter.

.git/commit_message: For publishing the Git commit message on successful builds.

.git/commit_timestamp: For tagging builds with a timestamp.

.git/describe_ref: Version reference detected and checked out. Can be templated with describe_ref_options parameter. By default, it will contain the <latest annoted git tag>-<the number of commit since the tag>-g<short_ref> (eg. v1.6.2-1-g13dfd7b). If the repo was never tagged before, this falls back to a short commit SHA-1 ref.

Describe alternatives you've considered

Writing a new TestKube flux controller as suggested in #3026 to trigger TestKube tests based on Flux Source controller notifications. This would also solve the issue to trigger upon Flux kustomization changes #3712

This would leverage Flux GitRepository https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1/gitrepositories.md might speed up implementation of this feature

Flux GitRepository properly supports the path/excludePath feature above, plus inclusion of nested git repos, optimized git clones, submodules, etc...

Support for tag rexgexp is being discussed in fluxcd/source-controller#341

@vsukhin
Copy link
Collaborator

vsukhin commented Sep 27, 2023

@gberche-orange really interesting feature. going to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request 🚀 New feature request
Projects
Status: 🏗 In progress
Development

No branches or pull requests

2 participants