[#5] [iOS] Setup CI: Github Actions #157
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: Test and code analysis | |
on: | |
pull_request: | |
types: [ opened, synchronize, reopened, ready_for_review ] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v3 | |
- name: Set up 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: 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.DANGER_GITHUB_API_TOKEN }} | |
run: bundle exec danger | |
ios_test: | |
name: Running iOS tests | |
runs-on: macos-latest | |
defaults: | |
run: | |
working-directory: ./sample/ios | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
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: Setup Java JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Remove the old sample project | |
run: rm -rf sample | |
working-directory: ./ | |
- name: Generate the new sample project | |
run: sh make.sh --bundle-id co.nimble.kmm.sample --bundle-id-staging co.nimble.kmm.sample.staging --project-name sample --ios-version 14.0 | |
working-directory: ./ | |
- name: Bundle install | |
run: bundle install --path vendor/bundle | |
- 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: 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: Run Danger to wrap up the review | |
env: | |
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: bundle exec danger | |
generate_sample_project: | |
# The job "generate_sample_project" identify that the job "test" must complete successfully | |
# before this "generate_sample_project" job will run | |
needs: [test, ios_test] | |
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" | |
- name: Remove the old sample project | |
run: rm -rf sample | |
- name: Generate the new sample project | |
run: ./make.sh --bundle-id co.nimble.kmm.sample --bundle-id-staging co.nimble.kmm.sample.staging --project-name sample --ios-version 14.0 | |
- 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 |