From c7eb1abad86879e3e6c9e2ce5194ff739e5bc6d7 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 12 Apr 2025 03:55:05 +0200 Subject: [PATCH] ci: split jobs --- .github/workflows/tests.yml | 66 ++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef1355c..b667eba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,8 +7,10 @@ on: branches: [master] jobs: - build-test: + build: runs-on: ubuntu-latest + outputs: + cache-key: ${{ steps.cache-key-generator.outputs.key }} steps: - name: Checkout code @@ -20,26 +22,82 @@ jobs: distribution: 'temurin' java-version: '21' + - name: Generate cache key + id: cache-key-generator + run: echo "key=gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}" >> $GITHUB_OUTPUT + - name: Cache Gradle dependencies uses: actions/cache@v3 with: path: | ~/.gradle/caches ~/.gradle/wrapper - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + key: ${{ steps.cache-key-generator.outputs.key }} restore-keys: | gradle-${{ runner.os }}- - name: Grant execute permission to Gradle wrapper run: chmod +x gradlew - - name: Lint + lint: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Restore Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ needs.build.outputs.cache-key }} + restore-keys: | + gradle-${{ runner.os }}- + + - name: Grant execute permission to Gradle wrapper + run: chmod +x gradlew + + - name: Run lint run: ./gradlew ktlintCheck + test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Restore Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ needs.build.outputs.cache-key }} + restore-keys: | + gradle-${{ runner.os }}- + + - name: Grant execute permission to Gradle wrapper + run: chmod +x gradlew + - name: Start CI Docker Compose services run: ./gradlew composeUp -Pci - - name: Test + - name: Run tests run: ./gradlew test -x composeUp --no-daemon - name: Upload test reports