Skip to content

Add git precommit hook and github actions #3

Add git precommit hook and github actions

Add git precommit hook and github actions #3

Workflow file for this run

name: PR Checks
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Cache clang-format
uses: actions/cache@v3
id: clang-cache
with:
path: /usr/local/clang-20.1.5
key: clang-format-20.1.5
- name: Install clang-format 20.1.5 (via apt.llvm.org)
run: |
sudo apt update
sudo apt install -y wget gnupg software-properties-common
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo apt install -y clang-format-20
sudo ln -sf /usr/bin/clang-format-20 /usr/local/bin/clang-format
clang-format --version
- name: Verify clang-format installation
run: |
clang-format --version
if [ $? -ne 0 ]; then
echo "❌ clang-format installation failed"
exit 1
fi
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run spotlessCheck
run: |
echo "Running spotlessCheck..."
./gradlew spotlessCheck
if [ $? -ne 0 ]; then
echo "❌ spotlessCheck failed. Please run './gradlew spotlessApply' locally to fix formatting issues."
exit 1
fi
- name: Run detekt
run: |
echo "Running detekt..."
./gradlew detekt
if [ $? -ne 0 ]; then
echo "❌ detekt found code style issues. Please fix them locally."
exit 1
fi
- name: Run unit tests
run: |
echo "Running unit tests..."
./gradlew testDebugUnitTest
if [ $? -ne 0 ]; then
echo "❌ Unit tests failed. Please fix the failing tests locally."
exit 1
fi