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

Address issues in TeamCity configuration code #8560

Merged
merged 33 commits into from
Aug 9, 2023

Conversation

SarahFrench
Copy link
Contributor

@SarahFrench SarahFrench commented Aug 4, 2023

(Apologies for the size of this PR/refactor 🙏 )

To see the config changes from this PR in action, see this test project in TeamCity: https://hashicorp.teamcity.com/project/TerraformProviders_Google_SarahTestMainBranchPr8560applied

Description

This PR updates code in .teammcity/ to change:

  • General refactoring; lots of code in these files was copied from the Azure provider and either could be refactored or removed.
  • Fixed sweeper behaviour:
    • Pre-sweeper runs once, before any acc
    • Post-sweeper runs once, after all acc tests finish
    • The sweeper builds run all sweepers for all resources in one build
  • All builds will fail if running for more than 12h (this is per individual build, not across the whole build chain)
  • Builds will run even if there are no code changes since the last run
    • this will allow tests to run at the scheduled time (4am) on Sunday and Monday, despite no new commits since the last run at 4am Saturday
  • Builds will have ids reflecting the commit hash they're using
  • Add ability to run tests from 'root' directory as well as service packages. This means we do not need tests to be migrated at the same time as transitioning to the new TeamCity projects
  • Update strategy when triggering builds with a cron trigger:
    • A build chain is used to set up dependencies between build configurations within the Project instance
    • Only the post-sweeper has a cron trigger. Once it's triggered all builds 'upstream' in the build chain are triggered too.

Release Note Template for Downstream PRs (will be copied)


@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

Copy link
Contributor Author

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Added some notes to parts of the code to help with review.

@@ -10,7 +10,7 @@
var defaultStartHour = 4

// specifies the default level of parallelism per-service-package
var defaultParallelism = 12
var defaultParallelism = 20
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parallelism set to 20, matching the current test project.

I have previously mentioned how this could need reducing once tests are split into multiple packages.

@SarahFrench
Copy link
Contributor Author

SarahFrench commented Aug 9, 2023

After getting some input from @alexsomesan I realised that the dependencies can be made simpler following the recent refactor I did. Instead of defining dependencies on the build configurations themselves, I'll use code similar to this pseudocode below when I register the build configurations in the project:

sequential {
        buildType(preSweeperConfig)
        parallel {
                <all service packages + other packages>.forEach { buildConfiguration ->
                        buildType(buildConfiguration)
                }
        }
        buildType(postSweeperConfig)
}

See commit d41e116 below for this

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 11 files changed, 882 insertions(+), 238 deletions(-))
Terraform Beta: Diff ( 11 files changed, 923 insertions(+), 247 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

Comment on lines 34 to 53
// Register build configs in the project
buildType(preSweeperConfig)
(packageConfigs + servicePackageConfigs).forEach { buildConfiguration ->
buildType(buildConfiguration)
}
buildType(postSweeperConfig)

// Set up dependencies between builds using `sequential` block
// Acc test builds run in parallel
sequential {
buildType(preSweeperConfig)

parallel{
(packageConfigs + servicePackageConfigs).forEach { buildConfiguration ->
buildType(buildConfiguration)
}
}

buildType(postSweeperConfig)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is where all the build configurations are put in the Project being created, and the sequential and nested parallel block are what create dependencies between builds.

Comment on lines +28 to +30
// Add trigger to last step of build chain (post-sweeper)
val triggerConfig = NightlyTriggerConfiguration(environment, branchRef)
postSweeperConfig.addTrigger(triggerConfig)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only place where CRON triggers are defined and attached to a build.

Copy link
Member

@zli82016 zli82016 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for working hard on this. Just left a couple of refactor comments.

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Thanks for the work, @SarahFrench!

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 11 files changed, 859 insertions(+), 238 deletions(-))
Terraform Beta: Diff ( 11 files changed, 900 insertions(+), 247 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician

This comment was marked as outdated.

jeperetz pushed a commit to jeperetz/magic-modules that referenced this pull request Aug 10, 2023
* Refactor: Pass `packageName` into packageDetails constructor instead

* Refactor how nightly trigger information is passed to where build configs are made

* Remove lingering references to `"public"` environment

* Remove unnecessary assignments and func parameters

* Fix inconsistent use of `var`/`val`

* Refactor test steps into separate functions, to help with later refactoring

* Remove `DetermineWorkingDirectory` as /tests directories aren't present in Google service packages

* Remove sweeper steps from per-service build configurations

Sweepers running after each build config will clash with other running tests

* Stop setting `SWEEPER_REGIONS` when sweepers aren't in a build config

* Add ability to set build ID as git commit hash

* Refactor other script to use multiline string

* Refactor how build config ids are built

* Add pre-sweeper build and make acc tests dependent on it finishing

* Add post-sweeper and ability to make it dependent on all other builds

* Make tests run even if there are no new commits

* Add timeout failure conditon to all builds

* Increase parallelism from 12 -> 20 to match old TC project

* Make sure sweepers have parameters to configure tests

* Add ability to run tests from `google/-beta` package, and comments about need for refactoring code

* Add properties to cron trigger present in old project

* Make build step names more informative, update comment

* Fix error where two parameters called `timeout`; clarify distinction between both

* Initial refactor of how package lists made, and how used in Kotlin code

* WIP: separate addition of build configs to project

* Refactor TeamCity config to use different structure of maps as input, update how maps are generated, update tools/teamcity-generator to match

* Change how builds are triggered

Avoid duplicate builds being queued due to cron and dependency requirements. Instead trigger fewer things and let dependency relationships trigger the rest.

* Make packages.kt provide pre-migration path for sweepers

* Remove excess argument left from refactoring

* Update ignored folders in generation of packages.kt

* Simplify how dependencies are created, and remove code that's no longer needed as a result

* Combine `failureConditions` blocks

* Fix test prefix

* Refactor to reduce code repetition around sweepers
ron-gal pushed a commit to ron-gal/magic-modules that referenced this pull request Aug 17, 2023
* Refactor: Pass `packageName` into packageDetails constructor instead

* Refactor how nightly trigger information is passed to where build configs are made

* Remove lingering references to `"public"` environment

* Remove unnecessary assignments and func parameters

* Fix inconsistent use of `var`/`val`

* Refactor test steps into separate functions, to help with later refactoring

* Remove `DetermineWorkingDirectory` as /tests directories aren't present in Google service packages

* Remove sweeper steps from per-service build configurations

Sweepers running after each build config will clash with other running tests

* Stop setting `SWEEPER_REGIONS` when sweepers aren't in a build config

* Add ability to set build ID as git commit hash

* Refactor other script to use multiline string

* Refactor how build config ids are built

* Add pre-sweeper build and make acc tests dependent on it finishing

* Add post-sweeper and ability to make it dependent on all other builds

* Make tests run even if there are no new commits

* Add timeout failure conditon to all builds

* Increase parallelism from 12 -> 20 to match old TC project

* Make sure sweepers have parameters to configure tests

* Add ability to run tests from `google/-beta` package, and comments about need for refactoring code

* Add properties to cron trigger present in old project

* Make build step names more informative, update comment

* Fix error where two parameters called `timeout`; clarify distinction between both

* Initial refactor of how package lists made, and how used in Kotlin code

* WIP: separate addition of build configs to project

* Refactor TeamCity config to use different structure of maps as input, update how maps are generated, update tools/teamcity-generator to match

* Change how builds are triggered

Avoid duplicate builds being queued due to cron and dependency requirements. Instead trigger fewer things and let dependency relationships trigger the rest.

* Make packages.kt provide pre-migration path for sweepers

* Remove excess argument left from refactoring

* Update ignored folders in generation of packages.kt

* Simplify how dependencies are created, and remove code that's no longer needed as a result

* Combine `failureConditions` blocks

* Fix test prefix

* Refactor to reduce code repetition around sweepers
@SarahFrench SarahFrench deleted the clean-up-teamcity-config branch March 19, 2024 21:59
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.

4 participants