|
| 1 | +name: Java CI with Gradle |
| 2 | + |
| 3 | +# This is a simplified cut of upstream's gradle workflow. |
| 4 | +# Removed some features like VT scans and image stuff. |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches-ignore: |
| 9 | + - "dependabot/**" |
| 10 | + tags-ignore: |
| 11 | + - "**" |
| 12 | + paths: |
| 13 | + - "**.java" |
| 14 | + - "**.json" |
| 15 | + - "**.yml" |
| 16 | + - "gradle**" |
| 17 | + - "*.gradle" |
| 18 | + - "*.accesswidener" |
| 19 | + pull_request: |
| 20 | + paths: |
| 21 | + - "**.java" |
| 22 | + - "**.json" |
| 23 | + - "**.yml" |
| 24 | + - "gradle**" |
| 25 | + - "*.gradle" |
| 26 | + - "*.accesswidener" |
| 27 | + workflow_dispatch: |
| 28 | + inputs: |
| 29 | + distinct_id: |
| 30 | + description: "Automatically set by the return-dispatch action (leave blank if running manually)" |
| 31 | + required: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + build: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + |
| 38 | + - name: Echo distinct ID ${{ github.event.inputs.distinct_id }} |
| 39 | + run: echo ${{ github.event.inputs.distinct_id }} |
| 40 | + |
| 41 | + - name: Checkout repository |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Set up Java 21 |
| 45 | + uses: actions/setup-java@v4 |
| 46 | + with: |
| 47 | + java-version: "21" |
| 48 | + distribution: "microsoft" |
| 49 | + |
| 50 | + - name: Grant execute permission for gradlew |
| 51 | + run: chmod +x gradlew |
| 52 | + |
| 53 | + - name: Setup Gradle |
| 54 | + uses: gradle/actions/setup-gradle@v4 |
| 55 | + with: |
| 56 | + build-scan-publish: true |
| 57 | + build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use" |
| 58 | + build-scan-terms-of-use-agree: "yes" |
| 59 | + |
| 60 | + - name: Compile Java code |
| 61 | + run: ./gradlew remapJar --stacktrace --warning-mode=fail |
| 62 | + |
| 63 | + - name: Validate JSON files |
| 64 | + run: ./gradlew spotlessJsonCheck || (echo "::error::JSON validation failed! Run './gradlew spotlessApply' to fix style issues, or check the full error message for syntax errors." && exit 1) |
| 65 | + |
| 66 | + - name: Validate Java code style |
| 67 | + run: ./gradlew spotlessJavaCheck || (echo "::error::Java code style validation failed! To fix, run 'Clean Up' and then 'Format' in Eclipse, or './gradlew spotlessApply' in the terminal." && exit 1) |
| 68 | + |
| 69 | + - name: Validate license headers |
| 70 | + run: ./gradlew spotlessLicenseHeaderCheck || (echo "::error::License headers are missing or malformed in some files! Run './gradlew spotlessApply' to fix this, or check the full error message for details." && exit 1) |
| 71 | + |
| 72 | + - name: Run unit tests |
| 73 | + run: ./gradlew test --stacktrace --warning-mode=fail |
| 74 | + |
| 75 | + - name: Validate access widener |
| 76 | + run: ./gradlew validateAccessWidener --stacktrace --warning-mode=fail |
| 77 | + |
| 78 | + - name: Build |
| 79 | + run: ./gradlew build --stacktrace --warning-mode=fail |
| 80 | + |
| 81 | + - name: Draft GitHub Release |
| 82 | + uses: softprops/action-gh-release@v2.2.2 |
| 83 | + with: |
| 84 | + draft: true |
| 85 | + files: build/libs/*.jar |
0 commit comments