Skip to content

Commit

Permalink
chore(actions): setup github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuNen344 committed Oct 24, 2024
1 parent eb10c8e commit 7669a4d
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/actions/avd/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "setup KVM"
description: "setup KVM group for Android Emulator"
inputs:
prepare-script:
description: "custom script to run before the main script - e.g. `./gradlew assembleDebugAndroidTest`"
required: false
script:
description: "custom script to run - e.g. `./gradlew connectedDebugAndroidTest`"
required: true
default: ""
runs:
using: "composite"
steps:
- name: setup KVM
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: 'avd-${{ runner.os }}-${{ inputs.script }}-${{ inputs.prepare-script }}'

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: prepare script
shell: bash
if: inputs.prepare-script != ''
run: |
${{ inputs.prepare-script }}
- name: run script
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ${{ inputs.script }}
17 changes: 17 additions & 0 deletions .github/actions/gradle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "setup gradle"
description: "setup gradle"
runs:
using: "composite"
steps:
- name: setup gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-cleanup: always
add-job-summary-as-pr-comment: on-failure
artifact-retention-days: 3

- name: list toolchain
shell: bash
run: |
./gradlew -q javaToolchains --no-daemon
10 changes: 10 additions & 0 deletions .github/actions/java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "setup JDK"
description: "setup JDK"
runs:
using: "composite"
steps:
- name: setup JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
36 changes: 36 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
groups:
compose:
patterns:
- "androidx.compose*"
- "androidx.constraintlayout:constraintlayout-compose*"
dagger:
patterns:
- "com.google.dagger*"
- "androidx.hilt*"
# https://docs.github.com/ja/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#open-pull-requests-limit
# default: 5
open-pull-requests-limit: 15

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 15

# https://github.com/dependabot/dependabot-core/issues/5137
- package-ecosystem: "github-actions"
directory: ".github/actions/gradle"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: ".github/actions/java"
schedule:
interval: "daily"
29 changes: 29 additions & 0 deletions .github/workflow/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: auto-merge

on:
pull_request:
types:
- opened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
enable-auto-merge:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
checks: write
pull-requests: write
repository-projects: write
if: ${{ github.actor_id == '49699333' }} # "dependabot[bot]"
steps:
- name: enable auto-merge
shell: bash
run:
gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 67 additions & 0 deletions .github/workflow/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: check

on:
pull_request:
types:
- opened
- synchronize
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

permissions:
contents: read
checks: write
pull-requests: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/java
- uses: ./.github/actions/gradle
- name: run android lint
shell: bash
run: |
./gradlew :app:lintDebug
- name: run detekt
shell: bash
run: |
./gradlew detekt
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/java
- uses: ./.github/actions/gradle
- name: unit test
shell: bash
run: |
./gradlew testDebugUnitTest
- uses: EnricoMi/publish-unit-test-result-action@v2
if: ${{ !cancelled() }}
with:
check_name: unit-test
files: |
**/test-results/**/*.xml
android-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/java
- uses: ./.github/actions/gradle
- uses: ./.github/actions/avd
with:
prepare-script: ./gradlew assembleDebug
script: ./gradlew connectedDebugAndroidTest
- uses: EnricoMi/publish-unit-test-result-action@v2
if: ${{ !cancelled() }}
with:
check_name: android-test
files: |
**/outputs/androidTest-results/connected/**/*.xml
22 changes: 22 additions & 0 deletions .github/workflow/stability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: stability

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
dependency-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/java
- uses: gradle/actions/dependency-submission@v4
with:
gradle-version: wrapper
dependency-resolution-task: 'resolveAllDependencies'
validate-wrappers: true

0 comments on commit 7669a4d

Please sign in to comment.