Skip to content

[#39] Optimize the workflow to generate the "sample" project before executing CI actions #149

[#39] Optimize the workflow to generate the "sample" project before executing CI actions

[#39] Optimize the workflow to generate the "sample" project before executing CI actions #149

Workflow file for this run

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:
test:
name: Code analysis, test and generate sample project
runs-on: macos-latest
timeout-minutes: 30
defaults:
run:
working-directory: ./sample
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 100
ref: ${{ github.head_ref }}
submodules: "recursive"
# Generate working project
- name: Remove the old sample project
working-directory: ./
run: rm -rf sample
- name: Generate the new sample project
working-directory: ./
run: ./make.sh --bundle-id co.nimblehq.kmm.template --bundle-id-staging co.nimblehq.kmm.template.staging --project-name sample --ios-version 14.0
# Run code analytics and tests
- 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
uses: MeilCli/danger-action@v5
with:
plugins_file: 'sample/Gemfile'
install_path: 'vendor/bundle'
danger_file: 'sample/Dangerfile'
danger_id: 'danger-pr'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Submit the sample project changes
- 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