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

Android custom build and test workflow artifact upload support #109

Merged
merged 15 commits into from
Jan 30, 2025

Conversation

timkimadobe
Copy link
Contributor

@timkimadobe timkimadobe commented Jan 29, 2025

Note

Because new features and breaking changes are being introduced:
The Android workflow version is planned to be incremented from 3.1.1 -> 3.2.0.
The iOS workflow version is planned to be incremented from 5.0.1 -> 5.1.0.

Description

This PR:

  1. Makes a breaking change to the Android and iOS code validation workflow to simply use a new ci-lint that caller repos can setup to chain whichever lint commands they want for their repo, instead of being prescriptive about which lint commands to use.
    • This is probably the best time to make this change since all workflows need to be updated anyways due to the breaking deprecation of action/cache
  2. Adds support for the actions/upload-artifacts action as part of the Android custom build and test workflow. This is in order to support Core's CI checks that publish JitPack versions of libraries locally and upload them as artifacts:

CircleCI:

- run:
    name: Install jitpack (identity) to maven local
    command: make identity-publish-maven-local-jitpack

...

- store_artifacts:
    path: code/identity/build/libs

See: https://github.com/adobe/aepsdk-core-android/blob/d3e61e63f80799942171e04e7d1b79a3a1a7c717/.circleci/config.yml#L46

It provides 4 passthrough params:

upload-artifacts-path:
  description: 'The path to the artifact(s) to upload. If empty, the upload-artifacts step is skipped.'
  type: string
  default: ''
upload-artifacts-name:
  description: '(Optional) Passthrough to `upload-artifacts` name. Specifies the name of the uploaded artifact(s), including the file extension if applicable. If left empty, it defaults to "artifact".'
  type: string
  default: ''
upload-artifacts-compression-level:
  description: '(Optional) Passthrough to `upload-artifacts` compression-level. Sets the compression level for uploaded artifacts. Higher values increase compression but may slow down uploads. See: https://github.com/actions/upload-artifact?tab=readme-ov-file#altering-compressions-level-speed-v-size. Defaults to 6.'
  type: string
  default: '6'
upload-artifacts-overwrite:
  description: '(Optional) Passthrough to `upload-artifacts` overwrite. When set to true, existing artifacts with the same name will be overwritten. If false, uploads will fail if an artifact with the same name already exists. Defaults to false.'
  type: boolean
  default: false

And a custom flag that controls the filename uniqueness helper:

upload-artifacts-name-timstamp:
  description: '(Optional) When set to true, a timestamp (`artifact-<TIMESTAMP>_`) is prepended to the artifact name to improve uniqueness. This is recommended when overwrite is set to false to avoid naming conflicts. Defaults to false.'
  type: boolean
  default: false

See full docs: https://github.com/actions/upload-artifact

  • If path is omitted (and the default '' is set), then the upload-artifact step will simply be skipped.
  • Artifact name can leverage the unique timestamp approach already used for preventing naming collisions for log files.

The goal is to be able to use this new support like the following:

name: Build and Test

on:
  pull_request:

jobs:
  build-core-artifact:
    name: "Build Artifacts"
    uses: timkimadobe/aepsdk-commons/.github/workflows/android-custom-command-build-and-test.yml@gha-android-3.2.0
    with:
      android-api-levels: '[29]'
      command: make core-publish-maven-local-jitpack
      upload-artifacts-path: code/core/build/libs
      upload-artifacts-name: core.aar
      upload-artifacts-name-timstamp: true
    secrets: inherit
  build-signal-artifact:
    name: "Build Artifacts"
    uses: timkimadobe/aepsdk-commons/.github/workflows/android-custom-command-build-and-test.yml@gha-android-3.2.0
    with:
      android-api-levels: '[29]'
      command: make signal-publish-maven-local-jitpack
      upload-artifacts-path: code/signal/build/libs
      upload-artifacts-name: signal.aar
      upload-artifacts-name-timstamp: true
    secrets: inherit
  build-lifecycle-artifact:
    name: "Build Artifacts"
    uses: timkimadobe/aepsdk-commons/.github/workflows/android-custom-command-build-and-test.yml@gha-android-3.2.0
    with:
      android-api-levels: '[29]'
      command: make lifecycle-publish-maven-local-jitpack
      upload-artifacts-path: code/lifecycle/build/libs
      upload-artifacts-name: lifecycle.aar
      upload-artifacts-name-timstamp: true
    secrets: inherit
  build-identity-artifact:
    name: "Build Artifacts"
    uses: timkimadobe/aepsdk-commons/.github/workflows/android-custom-command-build-and-test.yml@gha-android-3.2.0
    with:
      android-api-levels: '[29]'
      command: make identity-publish-maven-local-jitpack
      upload-artifacts-path: code/identity/build/libs
      upload-artifacts-name: identity.aar
      upload-artifacts-name-timstamp: true
    secrets: inherit
  build-and-test:
    name: "CI"
    uses: timkimadobe/aepsdk-commons/.github/workflows/android-build-and-test.yml@gha-android-3.2.0
    with:
      android-api-levels: '[29]'
      run-test-unit: true
      run-test-functional: true
      run-test-integration: true
      enable-codecov: true
      javadoc-build-path: code/core/build/dokka/javadoc
    secrets: inherit

See example usage: https://github.com/timkimadobe/aepsdk-core-android/actions/runs/13044629358

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 requested a review from praveek January 29, 2025 05:10
@@ -105,7 +105,7 @@ jobs:
uses: actions/checkout@v4.2.2

- name: Setup Dependencies
uses: adobe/aepsdk-commons/.github/actions/android-setup-dependencies-action@gha-android-3.1.1
uses: timkimadobe/aepsdk-commons/.github/actions/android-setup-dependencies-action@gha-android-3.2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you switch it back from your fork?

if [[ -z "$ARTIFACT_NAME" ]]; then
ARTIFACT_NAME="artifact"
fi
echo "ARTIFACT_FILE_NAME=artifact-${FILE_TIMESTAMP}Z_${ARTIFACT_NAME}" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you modify the logic to append this prefix only when ARTIFACT_NAME is not present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on our discussion, planning on keeping the timestamp prefix, but I also added the feature to control it using a flag along with the overwrite setting

@timkimadobe timkimadobe merged commit 27e16c0 into adobe:main Jan 30, 2025
1 check passed
@timkimadobe timkimadobe deleted the android-artifact-support branch January 30, 2025 03:00
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