Skip to content

Conversation

macisamuele
Copy link
Collaborator

@macisamuele macisamuele commented Jun 6, 2020

The goal of this PR is to allow development and testing of the library on systems where the Android SDK is not available.

Currently the Android dependencies are mostly needed for the sample projects, which gives an idea on how to use/integrate the library into end-user scenarios, but is not needed to test the overall library functionality.

In order to disable the inclusion/execution of the Android related tasks is sufficient to define SKIP_ANDROID environmental variable.
Anyway we want to guarantee that Android related tasks are executed on CI (almost all the public CI systems do expose CI=true environmental variable).

@macisamuele macisamuele requested a review from cortinico June 6, 2020 21:03
@cortinico cortinico added the infra PR or Issue related to project infrastructure label Jun 6, 2020
@cortinico cortinico added this to the 2.0.0 milestone Jun 6, 2020
if (System.getenv("ANDROID_SDK_ROOT") != null) {
return true;
}
// TODO: Check if `sdk.dir` property is defined in `local.properties`
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove this. If sdk.dir property is not defined in local.properties, it's up to the user to configure it. The ID or the command line will notify if the environment is misconfigured.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea of this PR is to conditionally include the projects depending on the presence of the android SDK.
The projects should be included if the Android SDK is available (ANDROID_SDK_ROOT env variable or sdk.dir property) or it's running on the CI

Considering this we need read the property to ensure that it is present.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't find official docs right now, anyway the local.properties file will be recreated if missing with content of the ANDROID_SDK_ROOT. So it's sufficient to check for the env variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated the PR reversing the logic (decide, via env variable, if android should be skipped) because there is no way to access to the content of local.properties within settings.gradle.kts.

This is relevant to me as I might define the Android SDK into the local properties file (and no env variable) and it would be annoying if Android tasks would be ignored.

About no way to access to the content, technically there is a hack that can be used (cat ... | grep sdk.dir) but it look bad enough to read a file hoping that a string is present.

So I've decided to get a different direction here.

@macisamuele macisamuele force-pushed the maci-allow-tests-without-android branch from c2ce98f to baa1b4a Compare June 9, 2020 22:49
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #134 into master will decrease coverage by 0.18%.
The diff coverage is 89.58%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #134      +/-   ##
============================================
- Coverage     74.56%   74.38%   -0.19%     
  Complexity      173      173              
============================================
  Files            11       11              
  Lines           684      687       +3     
  Branches         86       86              
============================================
+ Hits            510      511       +1     
- Misses          128      130       +2     
  Partials         46       46              
Impacted Files Coverage Δ Complexity Δ
.../main/java/com/yelp/codegen/plugin/GenerateTask.kt 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...m/yelp/codegen/plugin/GenerateTaskConfiguration.kt 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...in/src/main/java/com/yelp/codegen/SharedCodegen.kt 61.98% <55.55%> (+0.22%) 63.00 <0.00> (ø)
.../src/main/java/com/yelp/codegen/KotlinGenerator.kt 87.61% <100.00%> (ø) 88.00 <13.00> (ø)
...ugin/plugin/src/main/java/com/yelp/codegen/Main.kt 98.38% <100.00%> (ø) 4.00 <0.00> (ø)
...rc/main/java/com/yelp/codegen/utils/StringUtils.kt 100.00% <100.00%> (ø) 6.00 <2.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44ebe35...995ea19. Read the comment docs.

@macisamuele macisamuele changed the title Allow tests execution on environments there Android SDK is not installed Allow skip Android related gradle tasks Jun 10, 2020
@macisamuele macisamuele force-pushed the maci-allow-tests-without-android branch from baa1b4a to 995ea19 Compare June 10, 2020 09:25
@macisamuele
Copy link
Collaborator Author

The change is described in #134 (comment)

@macisamuele macisamuele marked this pull request as ready for review June 10, 2020 09:30
@macisamuele macisamuele merged commit dd28028 into Yelp:master Jun 10, 2020
@macisamuele macisamuele deleted the maci-allow-tests-without-android branch June 10, 2020 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra PR or Issue related to project infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants