Skip to content

Commit

Permalink
Merge pull request #5 from EranBoudjnah/migrate_to_github_actions
Browse files Browse the repository at this point in the history
Migrated from Travis to Github Actions.
  • Loading branch information
EranBoudjnah committed Nov 10, 2023
2 parents 79bdbe4 + d694e61 commit 88f5d85
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 18 deletions.
17 changes: 17 additions & 0 deletions .github/actions/cache-build-paths/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Cache Build'
description: 'Cache build paths'
inputs:
key:
description: 'Cache key'
required: true
runs:
using: 'composite'
steps:
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: |
app/build
key: ${{ inputs.key }}
restore-keys: |
${{ inputs.key }}
31 changes: 31 additions & 0 deletions .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Kotlin-Linter

on:
pull_request:

jobs:
ktlint:
runs-on: macos-latest
steps:
- name: Get changed files
id: changes
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
RESPONSE=$(curl -s -X GET -G $URL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
CHANGED_KOTLIN_FILES=$(echo $RESPONSE | jq -r '.[] | .filename' | grep -E "\.kt$" | tr \'\\n\' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "Changed Kotlin files: ${CHANGED_KOTLIN_FILES}"
echo "changed_kotlin_files=${CHANGED_KOTLIN_FILES}" >> $GITHUB_ENV
- name: "checkout"
if: env.changed_kotlin_files != ''
uses: actions/checkout@v4

- name: Install ktlint
if: env.changed_kotlin_files != ''
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.50.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: run ktlint
if: env.changed_kotlin_files != ''
run: |
ktlint . '!**/build/**'
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Android CI

env:
cache-name: android-gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
setup:
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Cache build artifacts
uses: ./.github/actions/cache-build-paths
with:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Assemble with Gradle
run: ./gradlew jar

unit-tests:
needs: setup

runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Cache build artifacts
uses: ./.github/actions/cache-build-paths
with:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run unit tests
run: ./gradlew test
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

0 comments on commit 88f5d85

Please sign in to comment.