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

Add support for triggering workspace runs through matching Git tags #434

Merged
merged 2 commits into from Jul 8, 2022

Conversation

hashimoon
Copy link
Contributor

@hashimoon hashimoon commented Jun 17, 2022

Description

This PR adds support for triggering workspace runs through a Git tag matching a regular expression. You can set the TagsRegex value on the VCSRepo object as part of the WorkspaceCreateOptions or WorkspaceUpdateOptions.

Testing plan

N/A

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" TF_ACC="1" ENABLE_BETA=1 go test -run TestWorkspacesUpdate -v ./...  -tags=integration
=== RUN   TestWorkspacesUpdate
=== RUN   TestWorkspacesUpdate/when_updating_a_subset_of_values
=== RUN   TestWorkspacesUpdate/with_valid_options
=== RUN   TestWorkspacesUpdate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value
=== RUN   TestWorkspacesUpdate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID
=== RUN   TestWorkspacesUpdate/when_an_error_is_returned_from_the_api
=== RUN   TestWorkspacesUpdate/when_options_has_an_invalid_name
=== RUN   TestWorkspacesUpdate/when_options_has_an_invalid_organization
=== RUN   TestWorkspacesUpdate/when_options_include_trigger-patterns_(behind_a_feature_flag)
=== RUN   TestWorkspacesUpdate/when_options_include_both_trigger-patterns_and_trigger-paths_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_updated
=== RUN   TestWorkspacesUpdate/when_options_include_VCSRepo_tags-regex_(behind_a_feature_flag)
=== RUN   TestWorkspacesUpdate/when_options_include_tags-regex_and_file-triggers-enabled_is_true_an_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-prefixes_an_error_is_returned
=== RUN   TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-patterns_error_is_returned
--- PASS: TestWorkspacesUpdate (16.69s)
    --- PASS: TestWorkspacesUpdate/when_updating_a_subset_of_values (0.31s)
    --- PASS: TestWorkspacesUpdate/with_valid_options (0.61s)
    --- PASS: TestWorkspacesUpdate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value (0.00s)
    --- PASS: TestWorkspacesUpdate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID (0.00s)
    --- PASS: TestWorkspacesUpdate/when_an_error_is_returned_from_the_api (0.35s)
    --- PASS: TestWorkspacesUpdate/when_options_has_an_invalid_name (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_has_an_invalid_organization (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_trigger-patterns_(behind_a_feature_flag) (1.76s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_trigger-patterns_and_trigger-paths_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_updated (1.82s)
    --- PASS: TestWorkspacesUpdate/when_options_include_VCSRepo_tags-regex_(behind_a_feature_flag) (10.09s)
    --- PASS: TestWorkspacesUpdate/when_options_include_tags-regex_and_file-triggers-enabled_is_true_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-prefixes_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesUpdate/when_options_include_both_tags-regex_and_trigger-patterns_error_is_returned (0.00s)
=== RUN   TestWorkspacesUpdateByID
=== RUN   TestWorkspacesUpdateByID/when_updating_a_subset_of_values
=== RUN   TestWorkspacesUpdateByID/with_valid_options
=== RUN   TestWorkspacesUpdateByID/when_an_error_is_returned_from_the_api
=== RUN   TestWorkspacesUpdateByID/without_a_valid_workspace_ID
--- PASS: TestWorkspacesUpdateByID (2.96s)
    --- PASS: TestWorkspacesUpdateByID/when_updating_a_subset_of_values (0.32s)
    --- PASS: TestWorkspacesUpdateByID/with_valid_options (0.61s)
    --- PASS: TestWorkspacesUpdateByID/when_an_error_is_returned_from_the_api (0.29s)
    --- PASS: TestWorkspacesUpdateByID/without_a_valid_workspace_ID (0.00s)
PASS
...

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" TF_ACC="1" ENABLE_BETA=1 go test -run TestWorkspacesCreate -v ./...  -tags=integration
=== RUN   TestWorkspacesCreate
=== RUN   TestWorkspacesCreate/with_valid_options
=== RUN   TestWorkspacesCreate/when_options_is_missing_name
=== RUN   TestWorkspacesCreate/when_options_has_an_invalid_name
=== RUN   TestWorkspacesCreate/when_options_has_an_invalid_organization
=== RUN   TestWorkspacesCreate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value
=== RUN   TestWorkspacesCreate/when_an_agent_pool_ID_is_specified_without_'agent'_execution_mode
=== RUN   TestWorkspacesCreate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID
=== RUN   TestWorkspacesCreate/when_an_error_is_returned_from_the_API
=== RUN   TestWorkspacesCreate/when_options_include_trigger-patterns_(behind_a_feature_flag)
=== RUN   TestWorkspacesCreate/when_options_include_both_non-empty_trigger-patterns_and_trigger-paths_error_is_returned
=== RUN   TestWorkspacesCreate/when_options_include_tags-regex(behind_a_feature_flag)
=== RUN   TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_trigger-patterns_error_is_returned
=== RUN   TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_trigger-prefixes_error_is_returned
=== RUN   TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_file-triggers-enabled_as_true_an_error_is_returned
=== RUN   TestWorkspacesCreate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_created
--- PASS: TestWorkspacesCreate (12.91s)
    --- PASS: TestWorkspacesCreate/with_valid_options (0.67s)
    --- PASS: TestWorkspacesCreate/when_options_is_missing_name (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_has_an_invalid_name (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_has_an_invalid_organization (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_includes_both_an_operations_value_and_an_enforcement_mode_value (0.00s)
    --- PASS: TestWorkspacesCreate/when_an_agent_pool_ID_is_specified_without_'agent'_execution_mode (0.00s)
    --- PASS: TestWorkspacesCreate/when_'agent'_execution_mode_is_specified_without_an_an_agent_pool_ID (0.00s)
    --- PASS: TestWorkspacesCreate/when_an_error_is_returned_from_the_API (0.25s)
    --- PASS: TestWorkspacesCreate/when_options_include_trigger-patterns_(behind_a_feature_flag) (1.46s)
    --- PASS: TestWorkspacesCreate/when_options_include_both_non-empty_trigger-patterns_and_trigger-paths_error_is_returned (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_include_tags-regex(behind_a_feature_flag) (7.61s)
    --- PASS: TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_trigger-patterns_error_is_returned (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_trigger-prefixes_error_is_returned (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_include_both_non-empty_tags-regex_and_file-triggers-enabled_as_true_an_error_is_returned (0.00s)
    --- PASS: TestWorkspacesCreate/when_options_include_trigger-patterns_populated_and_empty_trigger-paths_workspace_is_created (1.26s)
PASS
...

@hashicorp-cla
Copy link

hashicorp-cla commented Jun 17, 2022

CLA assistant check
All committers have signed the CLA.

@hashimoon hashimoon force-pushed the hashimoon/git-tags-support branch 4 times, most recently from 11e0418 to 6a41021 Compare June 17, 2022 18:13
@hashimoon hashimoon marked this pull request as draft June 17, 2022 20:22
@hashimoon hashimoon force-pushed the hashimoon/git-tags-support branch 4 times, most recently from 65bd1a0 to 5801fdc Compare June 27, 2022 17:13
@hashimoon hashimoon force-pushed the hashimoon/git-tags-support branch 4 times, most recently from caa9ae9 to 573e9a6 Compare July 1, 2022 20:34
@hashimoon hashimoon marked this pull request as ready for review July 5, 2022 20:27
@hashimoon hashimoon requested review from matejrisek, omarismail and a team July 5, 2022 20:27
@hashimoon hashimoon changed the title [DRAFT] Add support for triggering workspace runs through matching Git tags Add support for triggering workspace runs through matching Git tags Jul 5, 2022
brandonc
brandonc previously approved these changes Jul 5, 2022
@brandonc
Copy link
Collaborator

brandonc commented Jul 5, 2022

Before merging, please update CHANGELOG.md - we may release the next version today or tomorrow.

omarismail
omarismail previously approved these changes Jul 6, 2022
@hashimoon hashimoon dismissed stale reviews from omarismail and brandonc via 50c785d July 6, 2022 16:21
omarismail
omarismail previously approved these changes Jul 6, 2022
@hashimoon hashimoon merged commit dc641ab into main Jul 8, 2022
@hashimoon hashimoon deleted the hashimoon/git-tags-support branch July 8, 2022 15:05
@github-actions
Copy link

github-actions bot commented Jul 8, 2022

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants