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 GHA to run TeamCity config tests on PRs editing .teamcity #9954

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/teamcity-pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: TeamCity Configuration Tests
permissions: read-all

on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/teamcity-pr-checks.yml'
- 'mmv1/third_party/terraform/!.teamcity'


jobs:
teamcity-config-tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: zulu
java-version: 17
java-package: jdk

- name: Cache Maven files
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Download TeamCity Tools
run : |
cd mmv1/third_party/terraform/.teamcity
make tools

# Running the tests twice ensures that the tests are discovered and run
- name: Run TeamCity Tests
run : |
cd mmv1/third_party/terraform/.teamcity
make test
make test
Comment on lines +45 to +46
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know the exact reason why, but if you only run this command once the tests aren't detected and the test runner reports [INFO] No tests to run.:

Screenshot 2024-02-09 at 12 13 42

Instead the logs should show something like this:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running tests.NightlyTestProjectsTests
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.164 s - in tests.NightlyTestProjectsTests
[INFO] Running tests.BuildConfigurationFeatureTests
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 s - in tests.BuildConfigurationFeatureTests
[INFO] Running tests.ContextParameterHandlingTests
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.144 s - in tests.ContextParameterHandlingTests
[INFO] Running tests.VcsTests
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in tests.VcsTests
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can see the TESTS output in the GHA run for 1bf8b76 in this line here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the basis of this behaviour is the pom.xml file, maybe this section, but I'm really not an experienced Kotlin/Java developer. Given that the pom.xml file we use strongly resembles the Azure provider team's pom.xml file, who are the SMEs for TeamCity in HashiCorp, I'd like to avoid digging into this solo.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, but it works fine locally, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It behaves the same way locally if I make my laptop's state match a GHA running in a fresh container. I do that by deleting the (gitignored) mmv1/third_party/terraform/.teamcity/target folder from my local copy of MM, a folder made in the process of running make test.

If I run make test after deleting the target folder the target folder is remade and populated and then I see the 'No tests to run' message. If I run make test a second time, when target is present from the first run, I see the expected test pass/fail output.

It's very weird but at least shows it's not a problem with GHAs vs using these files during development.

Loading