Skip to content

Commit

Permalink
chore: improve ci performance
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus8448 committed Feb 20, 2024
1 parent ec0db79 commit 69dcde3
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 350 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CodeQL

on:
workflow_run:
workflows: [ Commit ]
types:
- completed

jobs:
codeql:
runs-on: ubuntu-22.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Cache gradle dependencies
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}-${{github.ref_name}}

- name: Initialize build environment
run: ./gradlew

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java

- name: Build
run: ./gradlew assemble -x checkLicenses --no-daemon

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
199 changes: 17 additions & 182 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,217 +5,52 @@ on:
branches: [ 'minecraft/*' ]

jobs:
validate-wrapper:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

initialize:
needs: validate-wrapper
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: gradle/wrapper-validation-action@v2

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Cache gradle dependencies
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}-${{github.ref_name}}
restore-keys: |
${{ runner.os }}-gradle-${{github.ref_name}}-
${{ runner.os }}-gradle-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}
${{ runner.os }}-gradle-
- name: Initialize caches
run: ./gradlew --no-daemon
- name: Initialize build environment
run: ./gradlew

license-headers:
needs: initialize
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Restore gradle cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}

- name: License headers
run: ./gradlew checkLicenses --no-daemon

build:
needs: initialize
runs-on: ubuntu-22.04

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

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Restore gradle cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}
- name: Check license headers
run: ./gradlew checkLicenses

- name: Build
run: ./gradlew assemble testClasses -x checkLicenses --no-daemon

- name: Cache build output
uses: actions/cache/save@v4
with:
path: |
.gradle/
!.gradle/loom-cache
build/
key: ${{ runner.os }}-build-${{ github.sha }}

analysis:
needs: initialize
runs-on: ubuntu-22.04
permissions:
security-events: write

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

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Restore gradle cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java

- name: Build
run: ./gradlew assemble testClasses -x checkLicenses --no-daemon

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

test:
needs: build
runs-on: ubuntu-22.04

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

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Restore gradle cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}

- name: Restore cached build output
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
.gradle/
!.gradle/loom-cache
build/
key: ${{ runner.os }}-build-${{ github.sha }}
id: build
if: ${{ !cancelled() }}
run: ./gradlew assemble testClasses -x checkLicenses

- name: Test
run: ./gradlew test --no-daemon

publish:
needs: [test, license-headers, analysis]
runs-on: ubuntu-22.04

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

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Restore gradle cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{github.ref_name}}-${{ hashFiles('gradle/gradle-wrapper.properties', 'settings.gradle.kts', 'build.gradle.kts', 'gradle.properties') }}

- name: Restore cached build output
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
.gradle/
!.gradle/loom-cache
build/
key: ${{ runner.os }}-build-${{ github.sha }}
if: ${{ steps.build.outcome == 'success' && !cancelled() }}
run: ./gradlew test -x checkLicenses

- name: Publish
run: ./gradlew publish -x test --no-daemon
if: ${{ github.repository == 'TeamGalacticraft/MachineLib' && success() }}
run: ./gradlew publish
env:
BUILD_NUMBER: ${{ github.run_number }}
NEXUS_REPOSITORY_URL: ${{ secrets.NEXUS_RELEASE_URL }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
Loading

0 comments on commit 69dcde3

Please sign in to comment.