TrialSpawnerESP Fix #199
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Java CI with Gradle | |
| on: | |
| push: | |
| branches-ignore: | |
| - "dependabot/**" | |
| tags-ignore: | |
| - "**" | |
| paths: | |
| - "**.java" | |
| - "**.json" | |
| - "**.yml" | |
| - "gradle**" | |
| - "*.gradle" | |
| - "*.accesswidener" | |
| pull_request: | |
| paths: | |
| - "**.java" | |
| - "**.json" | |
| - "**.yml" | |
| - "gradle**" | |
| - "*.gradle" | |
| - "*.accesswidener" | |
| workflow_dispatch: | |
| inputs: | |
| distinct_id: | |
| required: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Echo distinct ID ${{ inputs.distinct_id }} | |
| run: echo ${{ inputs.distinct_id }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: "21" | |
| distribution: "microsoft" | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| with: | |
| build-scan-publish: true | |
| build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use" | |
| build-scan-terms-of-use-agree: "yes" | |
| cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} | |
| cache-read-only: ${{ github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/heads/1.') }} | |
| - name: Build | |
| run: ./gradlew build --stacktrace --warning-mode=fail | |
| - name: Upload to VirusTotal for analysis | |
| id: virustotal | |
| env: | |
| VIRUSTOTAL_API_KEY: ${{ secrets.VIRUSTOTAL_API_KEY }} | |
| if: ${{ env.VIRUSTOTAL_API_KEY }} | |
| uses: crazy-max/ghaction-virustotal@v4 | |
| with: | |
| vt_api_key: ${{ env.VIRUSTOTAL_API_KEY }} | |
| files: | | |
| ./build/libs/*.jar | |
| # An error in this step means that the upload failed, not that a false | |
| # positive was detected. | |
| continue-on-error: true | |
| - name: Add VirusTotal links to build summary | |
| if: ${{ steps.virustotal.outputs.analysis }} | |
| run: | | |
| echo "<details open>" >> $GITHUB_STEP_SUMMARY | |
| echo "<summary>🛡️ VirusTotal Scans</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| IFS=',' read -ra ANALYSIS <<< "${{ steps.virustotal.outputs.analysis }}" | |
| for i in "${ANALYSIS[@]}"; do | |
| filepath=${i%%=*} | |
| url=${i#*=} | |
| filename=$(basename "$filepath") | |
| echo "- [$filename]($url)" >> $GITHUB_STEP_SUMMARY | |
| done | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY | |
| - name: Run the mod and take screenshots | |
| # TODO: Migrate to Fabric Client Gametest API so this can run with configuration cache enabled | |
| run: xvfb-run --auto-servernum ./gradlew runEndToEndTest --stacktrace --warning-mode=fail --no-configuration-cache | |
| - name: Upload screenshots.zip artifact | |
| uses: actions/upload-artifact@v5 | |
| if: ${{ success() || failure() }} | |
| with: | |
| name: screenshots | |
| path: run/screenshots | |
| compression-level: 0 | |
| - name: Upload crash-reports.zip artifact | |
| uses: actions/upload-artifact@v5 | |
| if: ${{ failure() }} | |
| with: | |
| name: crash-reports | |
| path: run/crash-reports | |
| - name: Create test screenshot gallery | |
| env: | |
| IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }} | |
| if: ${{ env.IMGUR_CLIENT_ID && (success() || failure()) }} | |
| # Imgur uploads randomly fail sometimes, probably because of the low rate limit. | |
| # TODO: Find a better place to upload the screenshots. | |
| continue-on-error: true | |
| run: | | |
| echo "<details open>" >> $GITHUB_STEP_SUMMARY | |
| echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| for img in run/screenshots/*.png; do | |
| if [ -f "$img" ]; then | |
| filename=$(basename "$img") | |
| name_without_ext="${filename%.*}" | |
| # Upload to Imgur | |
| response=$(curl -s -X POST \ | |
| -H "Authorization: Client-ID $IMGUR_CLIENT_ID" \ | |
| -F "image=@$img" \ | |
| https://api.imgur.com/3/image) | |
| # Extract the URL from the response | |
| url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4) | |
| if [ ! -z "$url" ]; then | |
| # Convert underscores to spaces and capitalize first letter of each word | |
| title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1') | |
| echo "### $title" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY | |
| echo "Imgur upload response for $filename: $response" | |
| fi | |
| fi | |
| done | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY |