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

RUMM-1204 Linter not run for carthage builds #450

Conversation

buranmert
Copy link
Contributor

@buranmert buranmert commented Mar 26, 2021

What and why?

Datadog.xcodeproj has Run linter build phase.
Our SPM&cocoapods users don't see xcodeproj but our carthage users build the framework from it.

They don't need to lint our framework's source.

How?

Skip linting for carthage

carthage passes CARTHAGE=YES flag to xcodebuild, our Run linter build phase checks this flag and it skips linting for carthage builds.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference

@buranmert buranmert self-assigned this Mar 26, 2021
@buranmert buranmert requested a review from a team as a code owner March 26, 2021 18:03
@buranmert buranmert force-pushed the buranmert/RUMM-1204-no-linter-for-carthage branch 4 times, most recently from 72f0621 to afa856c Compare March 26, 2021 18:45
@buranmert
Copy link
Contributor Author

I succeeded to fail in CI ✅
I'm reverting the change in Datadog.swift 🔙

Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

Using $CARTHAGE == YES to exclude linter for Carthage builds looks good 👌, but the changes made to bitrise.yml introduce very odd setup:

  • the run_unit_tests step may fail due to linter issue in SDK code or tests,
  • the run_unit_tests step may fail due to linter issue in other tools code or tests (e.g. bad formatting in api-surface tests),
  • as we retry run_unit_tests step upon failure, it will be run twice on linter issue.

If we want to run linter only once on CI, this should be run as part of run_linter step, not run_unit_tests. Excluding linter from run_unit_tests sounds OK, but in this PR we're removing the entire run_linter.

bitrise.yml Outdated
Comment on lines 41 to 55
- swiftlint@0.8.0:
title: Lint Sources/*
inputs:
- strict: 'yes'
- lint_config_file: "$BITRISE_SOURCE_DIR/tools/lint/sources.swiftlint.yml"
- linting_path: "$BITRISE_SOURCE_DIR"
- reporter: emoji
- swiftlint@0.8.0:
title: Lint Tests/*
is_always_run: true
inputs:
- strict: 'yes'
- linting_path: "$BITRISE_SOURCE_DIR"
- lint_config_file: "$BITRISE_SOURCE_DIR/tools/lint/tests.swiftlint.yml"
- reporter: emoji
Copy link
Member

Choose a reason for hiding this comment

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

Those steps were linting more than SDK code, see linter configuration:

# tools/lint/sources.swiftlint.yml:

  - instrumented-tests/http-server-mock/Sources
  - tools/api-surface/Sources
  - tools/api-surface/Fixtures/Sources
  - tools/rum-models-generator/Sources
  - tools/rum-models-generator/Tests/rum-models-generator-coreTests/Fixtures/Output # lint generation fixture
  - dependency-manager-tests/carthage/CTProject
  - dependency-manager-tests/cocoapods/CPProject
  - dependency-manager-tests/spm/SPMProject

# tools/lint/tests.swiftlint.yml:

  - instrumented-tests/http-server-mock/Tests
  - tools/api-surface/Tests
  - tools/rum-models-generator/Tests
  - dependency-manager-tests/carthage/CTProjectTests
  - dependency-manager-tests/carthage/CTProjectUITests
  - dependency-manager-tests/cocoapods/CTProjectTests
  - dependency-manager-tests/cocoapods/CTProjectUITests
  - dependency-manager-tests/spm/SPMProjectTests
  - dependency-manager-tests/spm/SPMProjectUITests

Now, these sources are lint as part of "Run unit tests for Datadog - iOS Simulator" which is wrong (we shouldn't fail SDK tests due to linter issue in rum-models-generator tool).

@buranmert buranmert force-pushed the buranmert/RUMM-1204-no-linter-for-carthage branch from a52d30d to d9b5d2c Compare March 29, 2021 09:39
@buranmert buranmert requested a review from ncreated March 29, 2021 09:40
If CARTHAGE flag is set for xcodebuild,
build phase is skipped
@buranmert buranmert force-pushed the buranmert/RUMM-1204-no-linter-for-carthage branch from d9b5d2c to 807ca7c Compare March 29, 2021 10:39
Copy link
Member

@ncreated ncreated left a comment

Choose a reason for hiding this comment

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

👍 as an optimisation, we could also skip running linter from Xcode build on CI. That might give us ~30s boost to the job time.

@ncreated ncreated changed the base branch from master to ncreated/RUMM-1222-enforce-up-to-date-version-of-swiftlint March 30, 2021 11:49
@ncreated ncreated merged commit 176aeb0 into ncreated/RUMM-1222-enforce-up-to-date-version-of-swiftlint Mar 30, 2021
@ncreated ncreated deleted the buranmert/RUMM-1204-no-linter-for-carthage branch March 30, 2021 11:50
@buranmert buranmert mentioned this pull request Apr 12, 2021
3 tasks
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.

2 participants