From c53f6465dd9a63ea48fae9c7f621bfbc1a495930 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 23 Mar 2023 20:06:44 +0300 Subject: [PATCH] DROID-1065 Project | Tech | Add license checker (#3007) --- .github/workflows/check.yml | 25 ++++++++++++++++++++++--- .github/workflows/release.yml | 18 ++++++++++++++++++ README.md | 13 ++++++++++--- app/build.gradle | 8 ++++++++ build.gradle | 6 ++++++ 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1533c105e7..ec22d6768e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,9 +1,9 @@ on: workflow_dispatch: pull_request: -# add "synchronize" in "types", in order to trigger workflow for pull request commit(s) pushes. - types: [opened] - branches: [develop] + # add "synchronize" in "types", in order to trigger workflow for pull request commit(s) pushes. + types: [ opened ] + branches: [ develop ] name: Run debug unit tests jobs: setup-android: @@ -20,6 +20,24 @@ jobs: sentry_dsn_secret: ${{ secrets.ANYTYPE_SENTRY_DSN_SECRET }} run: ./middleware2.sh $token_secret $user_secret $amplitude_secret $amplitude_secret_debug $sentry_dsn_secret + - uses: actions/checkout@master + with: + name: Setup license repository + repository: anytypeio/open + ref: refs/heads/main + path: ./open + + - name: Check licenses + run: | + cd open + python3 tools/generate.py --platform android + cd .. + sudo gem install license_finder + license_finder inherited_decisions add open/decisions.yml + license_finder --gradle-command="./gradlew \ + -Pcom.anytype.ci=true \ + -Dorg.gradle.unsafe.configuration-cache=false" + - name: Compile android test sources run: make compile_android_test_sources @@ -29,3 +47,4 @@ jobs: - name: Android test report uses: asadmansr/android-test-report-action@v1.2.0 if: ${{ always() }} # IMPORTANT: run Android Test Report regardless + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4b61a1be7..d39503aad9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,24 @@ jobs: RELEASE_STORE_PWD: ${{ secrets.RELEASE_STORE_PWD }} run: ./scripts/release/setup-store.sh $token_secret $RELEASE_KEY_ALIAS $RELEASE_KEY_PWD $RELEASE_STORE_PWD + - name: Setup license repository + uses: actions/checkout@master + with: + repository: anytypeio/open + ref: refs/heads/main + path: ./open + + - name: Check licenses + run: | + cd open + python3 tools/generate.py --platform android + cd .. + sudo gem install license_finder + license_finder inherited_decisions add open/decisions.yml + license_finder --gradle-command="./gradlew \ + -Pcom.anytype.ci=true \ + -Dorg.gradle.unsafe.configuration-cache=false" + - name: Build APKS run: ./gradlew :app:assembleRelease diff --git a/README.md b/README.md index deea333926..29a928acb5 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,21 @@ Or [download](https://download.anytype.io/) an apk for your device architecture ``` {TASK-ID} {APP AREA} | {NATURE OF CHANGE: Fix, Enhancement, Feature, Design, Documentation} | {CONCISE DESCRIPTION OF WHAT HAS BEEN DONE} ``` -App area can be `App`, `Editor`, `Sets`, `Relations`, `Auth`, `Settings`, `Analytics`, `Tech` (CI, DI, scripting, etc.), etc. -Example: *Editor | Fix | Show meaningful message when failed to open file by an existing application* +App area can be `App`, `Editor`, `Sets`, `Relations`, `Auth`, `Settings`, `Analytics`, `Tech` (CI, +DI, scripting, etc.), etc. + +Example: *Editor | Fix | Show meaningful message when failed to open file by an existing +application* ##### Git branch naming + ``` {TASK_ID or TASK_NUMBER}-ConciseDescription ``` +##### Flags - +``` +com.anytype.ci=true - for CI/CD pipeline +``` \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index f4d04daac1..8fc3242aee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,6 +7,14 @@ plugins { id "com.google.firebase.appdistribution" } +if (rootProject.ext.onCi) { + apply plugin: "com.github.hierynomus.license-report" + downloadLicenses { + dependencyConfiguration = 'all' + includeProjectDependencies = true + } +} + apply from: "$rootDir/versioning.gradle" def apikeyPropertiesFile = rootProject.file("apikeys.properties") diff --git a/build.gradle b/build.gradle index 08eb775fbc..c5a06742a8 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ buildscript { ext.version_name = '1.0' ext.version_code = 1 ext.test_runner = 'androidx.test.runner.AndroidJUnitRunner' + ext.onCi = project.properties.getOrDefault("com.anytype.ci", "false").toBoolean() def githubProperties = new Properties() def githubPropertiesFile = file("$rootDir${File.separator}github.properties") @@ -33,7 +34,12 @@ buildscript { password = githubProperties['gpr.key'] } } + } + if (ext.onCi) { + dependencies { + classpath "com.github.openkin:license-gradle-plugin:0d9582e233" + } } }