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

[#448] [Part2] sample yaml file for codemagic #489

Merged
merged 15 commits into from
Jul 27, 2023

Conversation

lydiasama
Copy link
Contributor

@lydiasama lydiasama commented Jul 14, 2023

What happened 👀

I'll split the task into 2 parts:
Part 1 :

  • Initial codemagic.yaml
  • Implement unit test step for template-compose and template-xml when opening PR and Push.

Part 2 :

  • Set up Firebase Distribution to project
  • Iimplement deploy to Firebase Distribution step
  • Move the codemagic.yaml file to .codemagic directory
  • Add the Readme.md file

Insight 📝

We will have 2 codemagic.yaml files:

  1. In the root directory, which contains specific template-compose and template-xml to run the workflow.
  2. In the .cicdtemplate, which supports only single project as it will be used when creating the new project.

To access the Codemagic console:

  1. Login Github with [email protected]
  2. Go to https://codemagic.io/start/ then select signin from Github

No-Goes for template-xml

As we deprecated the template-xml, I didn't implement the deploy script for template-xml to Firebase.

Github Environment Secrets and Variables setup

  1. The google-services.json for production and staging are created at the Github environment template-compose :

SCR-25660718-qycr

  1. I created the Codemagic Environment backup value to our template's Github environment Codemagic environment:

SCR-25660718-ntef

Codemagic Environment Variables

Created the Codemagic Environment by the following:

SCR-25660719-kpmg

Dynamic Version Code

For the dynamic version code, we have 2 alternatives to achieve:

  1. Get the Codemagic's environment variable BUILD_NUMBER directly on the build.gragle:

    versionCode = System.getenv("BUILD_NUMBER")?.toInt() ?: Versions.ANDROID_VERSION_CODE

    And in the codemagic.yaml will be the simple build command:

```
./gradlew assembleStagingDebug
```

**Pros**: Easy as it requires just 1 line of code.
**Cons**: It can confuse developers because the `BUILD_NUMBER` property is only from Codemagic, but we have both Codemagic and Github action in our template.
  1. Get the version code from versionCode argument from the build command line:
```kotlin
val getVersionCode: () -> Int = {
    if (project.hasProperty("versionCode")) {
        (project.property("versionCode") as String).toInt()
    } else {
        Versions.ANDROID_VERSION_CODE
    }
}
```

And in the codemagic.yaml will be the build command with -PversionCode argument:

```
./gradlew assembleStagingDebug -PversionCode=$BUILD_NUMBER
```

**Pros**: 
- All CD workflow can use the same build command line to build the apk with `-PversionCode`. 
- The usage of `BUILD_NUMBER` will be only inside of `codemagic.yaml` which it belongs to Codemagic's environment variable. So no confusion is created. 👍🏻 

**Cons**: It creates a few more lines on the `build.gradle` file.

💡 Thus, from the pros and cons above, I selected option 2.

📖 The document about build versioning on Codemagic can be found here.

🙏🏻 Special Thanks: @AVI5HEK for helping me review the Codemagic environment setup.

Proof Of Work 📹

Screenshot 2566-07-19 at 12 25 43 PM

Production build:

SCR-25660717-njgs

Staging build:

SCR-25660717-njde

@lydiasama lydiasama self-assigned this Jul 14, 2023
@lydiasama lydiasama marked this pull request as draft July 14, 2023 06:54
@lydiasama lydiasama changed the base branch from develop to feature/448-sample-yaml-file-for-codemagic July 14, 2023 06:54
@github-actions
Copy link

github-actions bot commented Jul 14, 2023

3 Warnings
⚠️ Uh oh! Your project is under 80% coverage!
⚠️ template-compose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml#L2 - The application adaptive icon is missing a monochrome tag
⚠️ template-compose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml#L2 - The application adaptive roundIcon is missing a monochrome tag

Kover report for template-xml:

🧛 Template - XML Unit Tests Code Coverage: 34.51%

Coverage of Modified Files:

File Coverage

Modified Files Not Found In Coverage Report:

README.md
Versions.kt
build.gradle.kts
build.gradle.kts
codemagic.yaml
codemagic.yaml
deploy_staging_and_production_to_firebase_app_distribution.yml
review_pull_request.yml
review_pull_request.yml
run_detekt_and_unit_tests.yml
run_detekt_and_unit_tests.yml

Codebase cunningly covered by count Shroud 🧛

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 62.39%

Coverage of Modified Files:

File Coverage

Modified Files Not Found In Coverage Report:

README.md
Versions.kt
build.gradle.kts
build.gradle.kts
codemagic.yaml
codemagic.yaml
deploy_staging_and_production_to_firebase_app_distribution.yml
review_pull_request.yml
review_pull_request.yml
run_detekt_and_unit_tests.yml
run_detekt_and_unit_tests.yml

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@lydiasama lydiasama force-pushed the feature/448-part2-sample-yaml-file-for-codemagic branch 5 times, most recently from d709f2e to 2841531 Compare July 14, 2023 11:55
@lydiasama lydiasama added this to the 3.22.0 milestone Jul 14, 2023
@lydiasama lydiasama marked this pull request as ready for review July 14, 2023 11:57
@lydiasama lydiasama changed the title WIP - [#448] [Part2] sample yaml file for codemagic [#448] [Part2] sample yaml file for codemagic Jul 14, 2023
@lydiasama lydiasama force-pushed the feature/448-part2-sample-yaml-file-for-codemagic branch 4 times, most recently from 9b3950e to 281fbb3 Compare July 17, 2023 08:04
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 05:31 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 05:31 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 05:59 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 05:59 — with GitHub Actions Inactive
Copy link
Member

@luongvo luongvo left a comment

Choose a reason for hiding this comment

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

The rest looks good 👍

.cicdtemplate/.github/workflows/review_pull_request.yml Outdated Show resolved Hide resolved
.github/workflows/review_pull_request.yml Outdated Show resolved Hide resolved
codemagic.yaml Outdated Show resolved Hide resolved
codemagic.yaml Outdated Show resolved Hide resolved
.cicdtemplate/.codemagic/codemagic.yaml Outdated Show resolved Hide resolved
.cicdtemplate/.codemagic/codemagic.yaml Outdated Show resolved Hide resolved
codemagic.yaml Outdated Show resolved Hide resolved
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 09:50 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 19, 2023 09:50 — with GitHub Actions Inactive
@lydiasama lydiasama requested a review from luongvo July 19, 2023 09:52
Copy link
Member

@luongvo luongvo left a comment

Choose a reason for hiding this comment

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

Some more issues related to what in .cicdtemplate, then it would be good @lydiasama 💪

@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 05:32 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 05:32 — with GitHub Actions Inactive
@lydiasama lydiasama requested a review from luongvo July 20, 2023 05:33
@lydiasama
Copy link
Contributor Author

lydiasama commented Jul 20, 2023

@ryan-conway Let me keep the codemagic.yaml file in the root directory as well so that we can test run at the Codemagic console. 🙏🏻
So we will have 2 codemagic file:

  1. In the root directory which contain specific template-compose and template-xml to run the workflow.
  2. In the .cicdtemplate which support only single project as it will be used when creating the new project.

@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 05:37 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 05:38 — with GitHub Actions Inactive
Copy link
Member

@luongvo luongvo left a comment

Choose a reason for hiding this comment

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

2 files left need to be updated 🏃

@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 06:37 — with GitHub Actions Inactive
@lydiasama lydiasama temporarily deployed to template-compose July 20, 2023 06:38 — with GitHub Actions Inactive
@lydiasama lydiasama requested a review from luongvo July 20, 2023 06:38
Base automatically changed from feature/448-sample-yaml-file-for-codemagic to develop July 27, 2023 03:10
@ryan-conway ryan-conway temporarily deployed to template-compose July 27, 2023 03:10 — with GitHub Actions Inactive
@ryan-conway ryan-conway merged commit c6cc06d into develop Jul 27, 2023
@ryan-conway ryan-conway deleted the feature/448-part2-sample-yaml-file-for-codemagic branch July 27, 2023 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants