Skip to content

Commit

Permalink
Update Makefile and CI scripts to remove 'ci' folder and 'ci-' prefix. (
Browse files Browse the repository at this point in the history
#130)

* Remove 'ci' folder and 'ci-' prefix from Makefile targets

* Remove Makefile step to rename .aar file.

* Add separate 'unit-test' and 'unit-test-coverate' Makefile targets and update report locations in CircleCI config.

* Add separate 'functional-test' and 'functional-test-coverage' targets in Makefile

* Reorder CircleCi steps to save tests/artifacts before publishing CodeCov report.

* Add 'ci-' prefix to publish targets as these targets require env variables set by CI.

* Use parenthesis for Makefile variable expansion.
  • Loading branch information
kevinlind committed Feb 7, 2024
1 parent 7e293dc commit c449867
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 74 deletions.
50 changes: 24 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:

- run:
name: Lint Code
command: make lint-check
command: make lint

- android/save-gradle-cache:
cache-prefix: << parameters.gradle-cache-prefix >>
Expand Down Expand Up @@ -111,39 +111,38 @@ jobs:

- run:
name: Javadoc
command: make ci-javadoc
command: make javadoc
- store_artifacts:
path: ci/javadoc/build/reports
path: code/edge/build/dokka/javadoc

- run:
name: Build
command: make ci-build
command: make assemble-phone

- run:
name: Build App
command: make ci-build-app
command: make assemble-app

- android/run-tests:
test-command: make ci-unit-test
test-command: make unit-test-coverage

- android/save-gradle-cache:
cache-prefix: << parameters.gradle-cache-prefix >>
- android/save-build-cache:
cache-prefix: << parameters.build-cache-prefix >>

- store_artifacts:
path: code/edge/build/reports/tests

- store_test_results:
path: code/edge/build/test-results/testPhoneDebugUnitTest

# Code coverage upload using Codecov
# See options explanation here: https://docs.codecov.com/docs/codecov-uploader
- codecov/upload:
file: ci/unit-test/build/reports/jacoco/platformUnitTestJacocoReport/platformUnitTestJacocoReport.xml
file: code/edge/build/reports/coverage/test/phone/debug/report.xml
flags: unit-tests

- store_artifacts:
path: ci/unit-test/build/reports

# On test failures, the step in the Makefile to copy the reports to ci/ is not run, so store test results from build folder instead.
- store_test_results:
path: code/edge/build/test-results

functional-test:
parameters:
gradle-cache-prefix:
Expand Down Expand Up @@ -172,27 +171,26 @@ jobs:
# It should match the name seen in the "sdkmanager --list" output
system-image: system-images;android-29;default;x86
# The command to be run, while waiting for emulator startup
post-emulator-launch-assemble-command: make ci-build
post-emulator-launch-assemble-command: make assemble-phone
# The test command
test-command: make ci-functional-test
test-command: make functional-test-coverage
restore-gradle-cache-prefix: << parameters.gradle-cache-prefix >>

- android/save-build-cache:
cache-prefix: << parameters.build-cache-prefix >>

# Code coverage upload using Codecov
# See options explanation here: https://docs.codecov.com/docs/codecov-uploader
- codecov/upload:
file: ci/functional-test/build/reports/coverage/androidTest/phone/debug/connected/report.xml
flags: functional-tests

- store_artifacts:
path: ci/functional-test/build/reports
path: code/edge/build/reports/androidTests

# On test failures, the step in the Makefile to copy the reports to ci/ is not run, so store test results from build folder instead.
- store_test_results:
path: code/edge/build/outputs/androidTest-results

# Code coverage upload using Codecov
# See options explanation here: https://docs.codecov.com/docs/codecov-uploader
- codecov/upload:
file: code/edge/build/reports/coverage/androidTest/phone/debug/connected/report.xml
flags: functional-tests

integration-test:
parameters:
gradle-cache-prefix:
Expand Down Expand Up @@ -221,9 +219,9 @@ jobs:
# It should match the name seen in the "sdkmanager --list" output
system-image: system-images;android-29;default;x86
# The command to be run, while waiting for emulator startup
post-emulator-launch-assemble-command: make ci-build
post-emulator-launch-assemble-command: make assemble-phone
# The test command
test-command: make ci-upstream-integration-test
test-command: make upstream-integration-test
restore-gradle-cache-prefix: << parameters.gradle-cache-prefix >>

- android/save-build-cache:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes
echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes
- name: Publish to maven central staging repository
run: make ci-publish-main
run: make ci-publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: make ci-upstream-integration-test EDGE_ENVIRONMENT=${{ github.event.inputs.environment }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }}
script: make upstream-integration-test EDGE_ENVIRONMENT=${{ github.event.inputs.environment }} EDGE_LOCATION_HINT=${{ github.event.inputs.edge-location-hint }}

# Potential workflow solutions on job failure
- name: On failure
Expand Down
71 changes: 25 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,13 @@
EXTENSION-LIBRARY-FOLDER-NAME = edge

TEST-APP-FOLDER-NAME = app
BUILD-ASSEMBLE-LOCATION = ./ci/assemble
ROOT_DIR=$(shell git rev-parse --show-toplevel)

PROJECT_NAME = $(shell cat $(ROOT_DIR)/code/gradle.properties | grep "moduleProjectName" | cut -d'=' -f2)
AAR_NAME = $(shell cat $(ROOT_DIR)/code/gradle.properties | grep "moduleAARName" | cut -d'=' -f2)
MODULE_NAME = $(shell cat $(ROOT_DIR)/code/gradle.properties | grep "moduleName" | cut -d'=' -f2)
LIB_VERSION = $(shell cat $(ROOT_DIR)/code/gradle.properties | grep "moduleVersion" | cut -d'=' -f2)
SOURCE_FILE_DIR = $(ROOT_DIR)/code/$(PROJECT_NAME)
AAR_FILE_DIR = $(ROOT_DIR)/code/$(PROJECT_NAME)/build/outputs/aar

init:
git config core.hooksPath .githooks

clean:
(rm -rf ci)
(rm -rf $(AAR_FILE_DIR))
(./code/gradlew -p code clean)

create-ci: clean
(mkdir -p ci)

format:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) spotlessApply)
(./code/gradlew -p code/$(TEST-APP-FOLDER-NAME) spotlessApply)
Expand All @@ -45,54 +31,47 @@ format-check:
format-license:
(./code/gradlew -p code licenseFormat)

lint-check:
lint:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) lint)

unit-test:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) testPhoneDebugUnitTest)

ci-build: create-ci
(mkdir -p ci/assemble)

(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) assemblePhone)
(mv $(AAR_FILE_DIR)/$(EXTENSION-LIBRARY-FOLDER-NAME)-phone-release.aar $(AAR_FILE_DIR)/$(MODULE_NAME)-release-$(LIB_VERSION).aar)
(cp -r ./code/$(EXTENSION-LIBRARY-FOLDER-NAME)/build $(BUILD-ASSEMBLE-LOCATION))

ci-build-app:
(./code/gradlew -p code/$(TEST-APP-FOLDER-NAME) assemble)
unit-test-coverage:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) createPhoneDebugUnitTestCoverageReport)

ci-unit-test: create-ci
(mkdir -p ci/unit-test)
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) platformUnitTestJacocoReport)
(cp -r ./code/$(EXTENSION-LIBRARY-FOLDER-NAME)/build ./ci/unit-test/)
functional-test:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) uninstallPhoneDebugAndroidTest)
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) connectedPhoneDebugAndroidTest)

ci-functional-test: create-ci
(mkdir -p ci/functional-test)
functional-test-coverage:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) uninstallPhoneDebugAndroidTest)
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) connectedPhoneDebugAndroidTest platformFunctionalTestJacocoReport)
(cp -r ./code/$(EXTENSION-LIBRARY-FOLDER-NAME)/build ./ci/functional-test)
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) createPhoneDebugAndroidTestCoverageReport)

ci-upstream-integration-test:
upstream-integration-test:
(./code/gradlew -p code/upstream-integration-tests uninstallDebugAndroidTest)
(./code/gradlew -p code/upstream-integration-tests connectedDebugAndroidTest -PEDGE_ENVIRONMENT=$(EDGE_ENVIRONMENT) -PEDGE_LOCATION_HINT=$(EDGE_LOCATION_HINT))

ci-javadoc: create-ci
(mkdir -p ci/javadoc)
javadoc:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) javadocJar)
(cp -r ./code/$(EXTENSION-LIBRARY-FOLDER-NAME)/build ./ci/javadoc)

ci-generate-library-debug:
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} assemblePhoneDebug)
assemble-phone:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) assemblePhone)

ci-generate-library-release:
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} assemblePhoneRelease)
assemble-phone-debug:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) assemblePhoneDebug)

build-release:
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} clean lint assemblePhoneRelease)
assemble-phone-release:
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) assemblePhoneRelease)

assemble-app:
(./code/gradlew -p code/$(TEST-APP-FOLDER-NAME) assemble)

ci-publish-staging: clean build-release
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} publishReleasePublicationToSonatypeRepository)
ci-publish: clean assemble-phone-release
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) publishReleasePublicationToSonatypeRepository -Prelease)

ci-publish-main: clean build-release
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} publishReleasePublicationToSonatypeRepository -Prelease)
ci-publish-staging: clean assemble-phone-release
(./code/gradlew -p code/$(EXTENSION-LIBRARY-FOLDER-NAME) publishReleasePublicationToSonatypeRepository)

# usage: update-version VERSION=9.9.9 CORE-VERSION=8.8.8
# usage: update-version VERSION=9.9.9
Expand Down

0 comments on commit c449867

Please sign in to comment.