Verify plugin for every branch #91
This file contains 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: Build | ||
on: | ||
pull_request: # all PRs | ||
push: | ||
branches: | ||
- master | ||
env: | ||
JAVA_DISTRIBUTION: "temurin" | ||
JAVA_VERSION: "17" | ||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true | ||
ACTIONS_STEP_DEBUG: true | ||
ARTIFACT_TTL: 1 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: ${{ contains(github.ref, 'refs/pull/')}} | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- { name: Fetch sources, uses: actions/checkout@v4, with: { fetch-depth: 0 } } | ||
- { name: Gradle Wrapper Validation, uses: gradle/wrapper-validation-action@v3 } | ||
- { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } } | ||
- { name: Setup Gradle, uses: gradle/actions/setup-gradle@v3, with: { gradle-home-cache-cleanup: true } } | ||
- name: Build plugin | ||
run: ./gradlew buildPlugin | ||
- { name: Upload `compiled` artifact, uses: actions/upload-artifact@v4, with: { name: compiled, path: build/classes/**/*, retention-days: "${{ env.ARTIFACT_TTL }}" } } | ||
testing: | ||
name: Test with coverage | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
- { name: Fetch sources, uses: actions/checkout@v4, with: { fetch-depth: 0 } } | ||
- { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } } | ||
- { name: Setup Gradle, uses: gradle/actions/setup-gradle@v3, with: { gradle-home-cache-cleanup: true } } | ||
- { name: Download `compiled`, uses: actions/download-artifact@v4, with: { name: compiled, path: build/classes/ } } | ||
- name: Run tests | ||
run: ./gradlew check | ||
- { name: Upload `junit-report` artifact, uses: actions/upload-artifact@v4, with: { name: junit-report, path: build/reports/junit, retention-days: "${{ env.ARTIFACT_TTL }}" } } | ||
- { name: Upload `jacoco-report` artifact, uses: actions/upload-artifact@v4, with: { name: jacoco-report, path: build/reports/jacoco, retention-days: "${{ env.ARTIFACT_TTL }}" } } | ||
analyse: | ||
name: Analyse | ||
runs-on: ubuntu-latest | ||
needs: [testing] | ||
steps: | ||
- { name: Fetch sources, uses: actions/checkout@v4, with: { fetch-depth: 0 } } | ||
- { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } } | ||
- { name: Setup Gradle, uses: gradle/actions/setup-gradle@v3, with: { gradle-home-cache-cleanup: true } } | ||
- { name: Download `junit-report`, uses: actions/download-artifact@v4, with: { name: junit-report, path: build/reports/junit } } | ||
- { name: Download `jacoco-report`, uses: actions/download-artifact@v4, with: { name: jacoco-report, path: build/reports/jacoco } } | ||
- { name: Download `compiled`, uses: actions/download-artifact@v4, with: { name: compiled, path: build/classes/ } } | ||
- run: find . | ||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Run SonarQube analysis with Quality Gates | ||
if: github.ref != 'refs/heads/master' | ||
run: ./gradlew sonar -Dsonar.branch.name=${{ github.head_ref }} | ||
env: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
- name: Run SonarQube analysis | ||
if: github.ref == 'refs/heads/master' | ||
run: ./gradlew sonar | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
SONAR_SCANNER_OPTS: "-Dsonar.qualitygate.wait=true -Dsonar.projectVersion=$CI_COMMIT_TAG" | ||
verifyPlugin: | ||
name: Verify Plugin | ||
runs-on: ubuntu-latest | ||
needs: [analyse] | ||
steps: | ||
- { name: Fetch sources, uses: actions/checkout@v4, with: { fetch-depth: 0 } } | ||
- { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } } | ||
- { name: Setup Gradle, uses: gradle/actions/setup-gradle@v3, with: { gradle-home-cache-cleanup: true } } | ||
- name: Run Plugin Verify | ||
run: ./gradlew runPluginVerifier | ||
- { name: Upload `intellij-verification-report` artifact, uses: actions/upload-artifact@v4, with: { name: intellij-verification-report, path: build/reports/pluginVerifier, retention-days: "${{ env.ARTIFACT_TTL }}" } } | ||
deploy-artifacts: | ||
name: Deploy reports | ||
needs: [testing, verifyPlugin] | ||
concurrency: | ||
group: factorio-api-completion | ||
cancel-in-progress: false | ||
permissions: | ||
pages: write | ||
id-token: write | ||
statuses: write | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
environment: | ||
name: github-pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- { name: Fetch sources, uses: actions/checkout@v4, with: { fetch-depth: 0 } } | ||
- { name: Download `junit-report`, uses: actions/download-artifact@v4, with: { name: junit-report, path: "var/${{ github.head_ref }}/reports/junit" } } | ||
- { name: Download `jacoco-report`, uses: actions/download-artifact@v4, with: { name: jacoco-report, path: "var/${{ github.head_ref }}/reports/jacoco" } } | ||
- { name: Download `intellij-verification-report`, uses: actions/download-artifact@v4, with: { name: intellij-verification-report, path: "var/${{ github.head_ref }}/reports/pluginVerifier" } } | ||
- name: Generate Directory Listings | ||
uses: jayanta525/github-pages-directory-listing@v4.0.0 | ||
with: | ||
FOLDER: "var/${{ github.head_ref }}/reports" | ||
- run: find . | ||
- name: Prepare artifact for GitHub Pages | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: var/ | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
- run: | | ||
Check failure on line 121 in .github/workflows/build.yml GitHub Actions / BuildInvalid workflow file
|
||
gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha | github.sha }} \ | ||
-f "state=success" \ | ||
-f "target_url=${{ steps.deployment.outputs.page_url }}/${{ github.head_ref }}/reports" \ | ||
-f "description=Reports on Github Pages" \ | ||
-f "context=${{ github.workflow }}" |