[#39] Optimize the workflow to generate the "sample" project before executing CI actions #191
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code analysis, test and generate sample project | |
on: | |
pull_request: | |
types: [ opened, synchronize, reopened, ready_for_review ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
generate_sample: | |
name: Generate the sample project | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
submodules: "recursive" | |
# # To avoid code change in git when refreshing the "sample" project | |
# - name: Preserve the ArkanaKeys | |
# run: mv -f ./sample/ios/ArkanaKeys ../ | |
# - name: Remove the old sample project | |
# run: rm -rf sample | |
# - name: Generate the new sample project | |
# run: ./make.sh --bundle-id co.nimblehq.kmm.template --bundle-id-staging co.nimblehq.kmm.template.staging --project-name sample --ios-version 14.0 | |
# - name: Restore the previous ArkanaKeys's keys | |
# run: | | |
# rm -rf ./sample/ios/ArkanaKeys | |
# mv -f ../ArkanaKeys ./sample/ios | |
# - id: changes | |
# name: Check for changes in the sample project | |
# run: | | |
# count=$(git status sample --porcelain | wc -l) | |
# echo "count=$count" >> $GITHUB_OUTPUT | |
# - name: Commit & push the sample project changes | |
# if: steps.changes.outputs.count > 0 | |
# run: | | |
# git config user.name team-nimblehq | |
# git config user.email [email protected] | |
# git add sample | |
# git commit -m "[Chore] Generate & update sample project" | |
# git push | |
android_test: | |
needs: [generate_sample] | |
name: Run Android code analysis and tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: ./sample | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 100 | |
submodules: "recursive" | |
- name: Set up Java JDK | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache Gradle | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches/modules-* | |
~/.gradle/caches/jars-* | |
~/.gradle/caches/build-cache-* | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Decode buildKonfig properties | |
run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties | |
- name: Run Detekt | |
run: ./gradlew detekt | |
- name: Run Lint | |
run: ./gradlew lint | |
- name: Run unit tests with Kover | |
run: ./gradlew koverXMLReport | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.7' | |
bundler-cache: true | |
- name: Run Danger to wrap up the review | |
env: | |
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
bundle install | |
bundle exec danger --danger_id=danger_android | |
ios_test: | |
needs: [generate_sample] | |
name: Run iOS code analysis and tests | |
runs-on: macos-latest | |
defaults: | |
run: | |
working-directory: ./sample/ios | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 100 | |
submodules: "recursive" | |
- name: Set up cache | |
uses: actions/cache@v3 | |
id: bunlderCache | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Set up Java JDK | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Bundle install | |
run: bundle install | |
- name: Cache Pods | |
uses: actions/cache@v3 | |
id: cocoapodCache | |
with: | |
path: Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
# - name: Decode buildKonfig properties | |
# working-directory: ./sample | |
# run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties | |
# - name: Generate KMM frameworks for Cocoapods | |
# run: | | |
# cd .. | |
# ./gradlew generateDummyFramework | |
- name: Install Pods Dependencies | |
run: bundle exec pod install | |
# - name: Build and Test | |
# run: bundle exec fastlane buildAndTest | |
# env: | |
# CI: true | |
# - name: Clean up previous code coverage report | |
# run: bundle exec fastlane cleanUpOutput | |
- name: \[Workaround\] Running Danger SwiftFormat from non-root directory | |
run: | | |
gem which danger | |
gem which danger-swiftformat | |
# Insert a map operator in the "find_swift_files" method to remove "sample/ios/" prefix from all files. | |
sed -i '' "s/.uniq/.uniq.map { |file| file.partition('sample\/ios\/').last }/g" '/Users/luongvo/.rvm/gems/ruby-3.0.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/plugin.rb' | |
- name: Run Danger to wrap up the review | |
env: | |
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: bundle exec danger --danger_id=danger_ios |