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

CircleCI iOS Setup #50

Closed
escakot opened this issue Sep 17, 2021 · 5 comments
Closed

CircleCI iOS Setup #50

escakot opened this issue Sep 17, 2021 · 5 comments

Comments

@escakot
Copy link

escakot commented Sep 17, 2021

The thing

We have a monorepo project for our iOS and macOS app. Under the Tests tab, it's only showing the Test Service mac-pro-server while our ios-pos project never shows up.

The tests results are definitely getting reported properly because both Test Services are showing results under the Test Runs tab. However, the ios-pos Test Service doesn't show the git branch name.

I have them setup with the below envVars using Xcodegen:

iOS Environment
"DD_TEST_RUNNER": $(DD_TEST_RUNNER)
"DATADOG_CLIENT_TOKEN": $(DATADOG_CLIENT_TOKEN)
"DD_SERVICE": "ios-pos"
"DD_ENV": "$(DD_ENV)"
"SRCROOT": "$(SRCROOT)"
macOS Environment
"DD_TEST_RUNNER": $(DD_TEST_RUNNER)
"DATADOG_CLIENT_TOKEN": $(DATADOG_CLIENT_TOKEN)
"DD_SERVICE": "mac-pro-server"
"DD_ENV": "$(DD_ENV)"
"SRCROOT": "$(SRCROOT)"

They are both using the same Client Tokens and same Environment variables except for the DD_SERVICE var.
Is there something wrong with my setup? Any help on fixing this is greatly appreciated!

@nachoBonafonte
Copy link
Contributor

Hi Errol,

The testing framework tries to fetch Git metadata using the local .git folder on the project. In some cases that is not possible like when running on a physical device( where the source code is not on the device), if the .git folder is not located in
SRCROOT or a parent of it, or if there is a bug in the framework code (which might be the issue here, because you say that only branch information is missing).

For those cases there is a section in the docs: here where it documents the environment variables also needed to use depending on your CI provider. That you don’t mention in the environment variables you are using, so you should also add.

There is a subsection there where it says: Additional Git configuration for physical device testing: , if you set those environment variables the git information will be recovered form the environment variables of your CI provider instead of the local git folder and should fox your issues.

Let me know if it works.

Thanks

@escakot
Copy link
Author

escakot commented Sep 17, 2021

Hi Ignacio,

Thanks for the quick response.

We are only using Simulator on CircleCI so the CIRCLE_BRANCH env var is available. The .git folder should be there as well. It might be a bug on the backend rather than the Swift SDK. If you need more info, let me know and I'll try to provide it. Datadog is a lifesaver and we look forward to using this new tool!

Folder structure
.git/
Project.xcworkspace/
iOS/
  iOS-Project.xcodeproj/
  Sources/
  Tests/
macOS/
  macOS-Project.xcodeproj/
  Sources/
  Tests/
Shared/  # Source code that both projects use
  Sources/
  Tests/ # Test below exists here

This is an image of what we see on DD for the same test. iOS reports much later because it takes longer to build and has more tests.
98912881-BF05-4F64-9F9B-DC534188363B

@nachoBonafonte
Copy link
Contributor

Ok, then if you are using CircleCI then you should also set the following environment variables as you did with the others, so the framework can access to them on iOS:

"CIRCLECI": $(CIRCLECI)
"CIRCLE_WORKING_DIRECTORY"= $(CIRCLE_WORKING_DIRECTORY)
"CIRCLE_BUILD_NUM"= $(CIRCLE_BUILD_NUM)
"CIRCLE_BUILD_URL"= $(CIRCLE_BUILD_URL)
"CIRCLE_WORKFLOW_ID"= $(CIRCLE_WORKFLOW_ID)
"CIRCLE_PROJECT_REPONAME"= $(CIRCLE_PROJECT_REPONAME)
"CIRCLE_SHA1"= $(CIRCLE_SHA1)
"CIRCLE_REPOSITORY_URL"= $(CIRCLE_REPOSITORY_URL)
"CIRCLE_BRANCH"= $(CIRCLE_BRANCH)
"CIRCLE_TAG"= $(CIRCLE_TAG)

Even when the env var are accessible in the system if you don't add them to the project, iOS processes cannot access them (macOS processes can, but not iOS).

With this change you should be able to have the complete git information, and you will also get information about the CircleCI process and a URL to access the CircleCI pipeline workflow directly.

Also, be sure you select your main target in Expand variables based on (or Target for Variable Expansion if using test plans) as shown here

Please let me know if it solves your issues.

@escakot
Copy link
Author

escakot commented Sep 17, 2021

Yes, CircleCI just finished running and it's reporting correctly!

Thank you very much for your help.

@escakot escakot closed this as completed Sep 17, 2021
@escakot escakot changed the title Monorepo Branch Reporting CircleCI iOS Setup Sep 17, 2021
@nachoBonafonte
Copy link
Contributor

I am glad it worked. Please don't hesitate in reporting any problem or feedback you can have with the tool.

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

No branches or pull requests

2 participants