Update Gradle Usage in CI #477
Workflow file for this run
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: | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Setup resource usage collection | |
| run: | | |
| # Create a script to log resource usage with timestamps | |
| echo 'while true; do' > monitor_resources.sh | |
| echo ' echo "$(date): Disk Usage:" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' df -h >> resource_usage.log' >> monitor_resources.sh | |
| echo ' echo "" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' echo "$(date): CPU Usage:" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' top -b -n 1 | head -n 10 >> resource_usage.log' >> monitor_resources.sh | |
| echo ' echo "" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' echo "$(date): Memory Usage:" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' free -h >> resource_usage.log' >> monitor_resources.sh | |
| echo ' echo "" >> resource_usage.log' >> monitor_resources.sh | |
| echo ' sleep 5' >> monitor_resources.sh | |
| echo 'done' >> monitor_resources.sh | |
| # Make the script executable | |
| chmod +x monitor_resources.sh | |
| # Start the script in the background | |
| nohup ./monitor_resources.sh & | |
| - name: Build with Gradle Wrapper | |
| id: gradle_build | |
| run: ./gradlew build -i || echo "Gradle build failed" > gradle_build_result.txt | |
| continue-on-error: true | |
| - name: Upload resource usage log | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: resource-usage-log | |
| path: resource_usage.log | |
| - name: Check build result | |
| if: always() | |
| run: | | |
| if [ -f gradle_build_result.txt ]; then | |
| echo "Build failed." | |
| exit 1 | |
| else | |
| echo "Build succeeded." | |
| fi | |
| dependency-submission: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Generate and submit dependency graph | |
| uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 | |
| javadoc: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Build Javadoc | |
| run: ./gradlew javadoc | |
| - name: Copy Javadocs | |
| run: mkdir javadoc && cp -r message-encoding/build/docs/javadoc javadoc/message-encoding && cp -r client/build/docs/javadoc javadoc/client | |
| - name: Copy Index Page | |
| run: cp index.html javadoc/ | |
| - name: Deploy Pages Content For solana4j | |
| uses: JamesIves/github-pages-deploy-action@v4.6.4 | |
| # https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable | |
| if: ${{ always() && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }} | |
| with: | |
| folder: javadoc |