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

iOS CircleCI to GitHub Actions reusable workflow conversion #67

Merged
merged 59 commits into from
Nov 15, 2024

Conversation

timkimadobe
Copy link
Contributor

@timkimadobe timkimadobe commented Aug 8, 2024

Questions for reviewers

For the standardized build and test workflow:

  1. Are the current make rule names desired as the standard?

Important

I couldn't figure out how to get custom derived data paths working with the Codecov action, so Makefiles must remove the -resultBundlePath flag when using xcodebuild test. Ex: -resultBundlePath build/reports/iosFunctionalResults.xcresult. Is this acceptable?

  • Based on the Codecov action documentation, there doesn't seem to be a way to override the Xcode plugin's default search directory of DerivedData folder: /Users/runner/Library/Developer/Xcode/DerivedData: https://github.com/codecov/codecov-action?tab=readme-ov-file#arguments
  • An alternative is we could download/install the Codecov CLI manually (handling things like caching etc), but the issue with this approach is that each test group (ex: iOS unit, tvOS functional, etc) would all need their own individual input: options for passing their specific flags to the CLI (this input explosion would be the same if we passed options to the Codecov Action as well): https://docs.codecov.com/docs/the-codecov-cli

Description

Note

See #64 for additional context on reusable workflows

This PR:

  1. Converts CircleCI PR check workflow into GitHub Action workflow format AND
  2. Is defined as a reusable workflow so that other repos are able to take advantage of the common flow, and are able to trigger on whatever criteria they need (the intended use is on PR creation)
  3. Enables Codecov reporting on all test jobs

The goal is to reduce the amount of workflow maintenance work that needs to be done across repos (ex: action version upgrades, runner changes, iOS simulator updates, etc).

There are three new files:

ios-build-and-test.yml

Build and test (CircleCI converted to GitHub actions reusable workflow) - which has the standard PR check make commands

  • Uses new composite action which handles setup caching logic to reduce boilerplate: .github/actions/ios-setup-dependencies-action/action.yml
  • Adds job run flags so that callers can control which checks are run for their repo (each are optional, and default to false)
  • Allows for matrix of devices and OS for testing
    • Uses defaults if matrix values are not provided by the caller

ios-custom-command-build-and-test.yml

This is a modularized workflow that handles:

  • Matrix logic - checking if matrix values were passed in or not, and providing default values
  • Caching logic
  • Running the make command and passing in the following new variables for use in the context of the make rule:
    • IOS_DEVICE_NAME="${{ matrix.ios-device }}" IOS_VERSION="${{ matrix.ios }}" TVOS_DEVICE_NAME="${{ matrix.tvos-device }}" TVOS_VERSION="${{ matrix.tvos }}"

Note

This modular workflow is used by ios-build-and-test.yml to avoid repeating a lot of the same setup code, and it can also be called by repos directly if they need to use non-standard make commands.

ios-validate-code.yml

Validates the code by using the command make lint

Example caller repo usage:

name: Build and Test

on:
  pull_request:

jobs:
  build-and-test:
    name: " "
    uses: adobe/aepsdk-commons/.github/workflows/[email protected]
    with:
      ios-device-names: '["iPhone 15", "iPhone 15 Pro"]'
      ios-versions: '["18.0"]'
      tvos-device-names: '["Apple TV"]'
      tvos-versions: '["18.0", "18.1"]'
      run-test-ios-unit: true
      run-test-ios-functional: false
      run-test-ios-integration: false
      run-test-tvos-unit: true
      run-test-tvos-functional: false
      run-build-xcframework-and-app: false

Example runs

Example run (with matrix using both iOS and tvOS paths): https://github.com/timkimadobe/aepsdk-edge-ios/actions/runs/11695962501

Example run with Codecov enabled: https://github.com/timkimadobe/aepsdk-edge-ios/actions/runs/11714920884/job/32630451484

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@timkimadobe timkimadobe changed the title CircleCI to GitHub Actions reusable workflow conversion iOS CircleCI to GitHub Actions reusable workflow conversion Aug 9, 2024
@@ -0,0 +1,48 @@
name: "Setup Dependencies"
Copy link
Contributor

Choose a reason for hiding this comment

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

The setup-action is iOS specific. Can you rename it accordingly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated!

with:
path: |
Pods
SampleApps/TestApp/Pods
Copy link
Contributor

@praveek praveek Aug 19, 2024

Choose a reason for hiding this comment

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

The path changes for each repo. Can we exclude it from the cache for now and consider including it later if it becomes a concern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removed

uses: actions/[email protected]
with:
repository: adobe/aepsdk-commons
ref: main
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not default to main.

@praveek
Copy link
Contributor

praveek commented Aug 19, 2024

Thanks for the PR. I have a few more suggestions

  • Include a README that explains how an extension can adopt these reusable workflows. It should specify which make commands are required, any assumptions about folder structure, and file names.
  • Consider adding default values for device_name and os_version.
  • Since only a few extensions support tvOS, add a flag for this. The tvos tests should also check for this flag along with run_test_tvos_* flags.
  • Extend the testing script to support a matrix of device OS versions.

test-ios-integration:
runs-on: macos-latest
needs: validate-code
if: inputs.run_test_ios_integration && (inputs.github_ref == 'refs/heads/main' || inputs.github_ref == 'refs/heads/staging')
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding these checks && (inputs.github_ref == 'refs/heads/main' || inputs.github_ref == 'refs/heads/staging') makes it impossible to override the default behavior. Can we instead rely solely on a boolean value and move these checks to the caller repo?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment for build_xcframework_and_app

Update cache action to latest 4.1.2
Update save cache actions to explicitly use the save action
Update titles to sentence case
Add caching logic
Add workflow_tag input variable
Update all inputs to use hyphen for consistency
Remove github ref input and use the value auto populated in the env since it is the same value
…ry values also add descriptions of usage and formatting

Update test step run to false for all cases
Apply matrix strategy for all test steps
Use branch ref instead of tag for testing
Test using the custom command instead of rewritten job steps
Copy link
Contributor Author

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Thanks for the review @praveek! Updated based on feedback - please let me know what you think

@@ -0,0 +1,48 @@
name: "Setup Dependencies"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated!

with:
path: |
Pods
SampleApps/TestApp/Pods
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removed

with:
ios-device-names: ${{ inputs.ios-device-names }}
ios-versions: ${{ inputs.ios-versions }}
command: make unit-test-ios
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added Codecov support for each test case with some caveats - please see the main PR description under Questions for reviewers section for more details. Also added an example of the Codecov enabled run under Example runs section

jobs:
validate-code:
name: Validate Code
uses: timkimadobe/aepsdk-commons/.github/workflows/ios-validate-code.yml@ios-circleci-to-github
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! Using the major version aligned tag: gha-ios-5.0.0

@timkimadobe timkimadobe requested a review from praveek November 7, 2024 23:11
@praveek
Copy link
Contributor

praveek commented Nov 12, 2024

@timkimadobe Regarding Codecov, I noticed there is a directory argument that allows specifying custom directories. Additionally, I saw an issue where Codecov v4 does not support .xcresult-based tests. If this is the case, could you try reverting to v3 to see if it works for our use case?

@praveek
Copy link
Contributor

praveek commented Nov 12, 2024

Everything else looks good. However, the workflows contain several internal references using specific tags. Can you also create a script and release action for this repo that will find all references like the one below and replace them with the tag we are creating?

uses: adobe/aepsdk-commons/.github/actions/[email protected]

@timkimadobe
Copy link
Contributor Author

timkimadobe commented Nov 13, 2024

@timkimadobe Regarding Codecov, I noticed there is a directory argument that allows specifying custom directories. Additionally, I saw an issue where Codecov v4 does not support .xcresult-based tests. If this is the case, could you try reverting to v3 to see if it works for our use case?

Based on a test run, the v4 Codecov action looks like it does support code coverage for tests not by using the .xcresult file, but by using the Codecov CLI Xcode plugin they have which:

  1. Looks for .profdata (profile data files generated by LLVM’s coverage instrumentation)
  2. Looks for .xctest bundles (the compiled test executables)
  3. Runs xcrun llvm-cov show -instr-profile <path_to_profdata> <path_to_executable> which outputs in a Codecov supported format

But it also looks like while it does support coverage in this way out of the box, this plugin doesn't currently support overriding the default derived data directory (so I don't think using the directory input for the overall action will work in this case: https://github.com/codecov/codecov-cli/blob/a89f1080e194a8c93c1e7e9b904fa13080d287ad/codecov_cli/plugins/__init__.py#L84

Given this I was thinking the most convenient usage would be to simply align with the default DerivedData directory used by the Xcode plugin, and if we need the .xcresult in other CI steps (ex: upload artifacts, etc), we can copy it to the desired directory?

For reference, here is an example run using the default DerivedData directory with successfully uploaded coverage: https://github.com/timkimadobe/aepsdk-edge-ios/actions/runs/11714920884/job/32630451484

@timkimadobe
Copy link
Contributor Author

timkimadobe commented Nov 13, 2024

Everything else looks good. However, the workflows contain several internal references using specific tags. Can you also create a script and release action for this repo that will find all references like the one below and replace them with the tag we are creating?

uses: adobe/aepsdk-commons/.github/actions/[email protected]

Yes, I think that sounds good - I've created a separate PR for these changes:

@timkimadobe timkimadobe merged commit 5202e48 into adobe:main Nov 15, 2024
2 checks passed
@timkimadobe timkimadobe deleted the ios-circleci-to-github branch December 4, 2024 23:17
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