Skip to content

Build

Build #307

Workflow file for this run

name: Build
on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
workflow_dispatch:
inputs:
pluginJavaVersion:
description: 'JDK compatibility version of the plugin'
required: true
default: '21'
type: choice
options:
- '21'
- '17'
- '11'
- 'All'
os:
description: 'O/S'
required: true
default: 'ubuntu-24.04'
type: choice
options:
- 'ubuntu-24.04'
- 'macos-14'
- 'windows-2022'
- 'All'
jobs:
define-matrix:
name: Define matrix
runs-on: ubuntu-24.04
outputs:
os: ${{ steps.set-matrix-variables.outputs.os }}
pluginJavaVersion: ${{ steps.set-matrix-variables.outputs.pluginJavaVersion }}
steps:
- name: Set matrix variables
id: set-matrix-variables
run: |
if [[ (-z "${{ inputs.os }}") || ("${{ inputs.os }}" == "All") ]]; then
echo 'os=["ubuntu-24.04", "macos-14", "windows-2022"]' >> "$GITHUB_OUTPUT"
else
echo 'os=["${{ inputs.os }}"]' >> "$GITHUB_OUTPUT"
fi
build:
name: Build
needs: define-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
env:
SONAR_CODE_SCAN_ENABLED: (matrix.os == 'ubuntu-24.04') && (inputs.pluginJavaVersion == '21')
JDK_11_BUILD_REQUIRED: (inputs.pluginJavaVersion == '11') || (inputs.pluginJavaVersion == 'All')
JDK_17_BUILD_REQUIRED: (inputs.pluginJavaVersion == '17') || (inputs.pluginJavaVersion == 'All')
JDK_21_BUILD_REQUIRED: (inputs.pluginJavaVersion == '21') || (inputs.pluginJavaVersion == 'All')
steps:
- name: Init Ubuntu environment
if: matrix.os == 'ubuntu-24.04'
run: sudo rm -f /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/pnpm /usr/local/bin/yarn
- name: Init MacOS environment
if: matrix.os == 'macos-14'
run: sudo rm -f /opt/homebrew/bin/node /usr/local/bin/npm /usr/local/bin/pnpm /usr/bin/yarn /Users/runner/.yarn/bin/yarn
- name: Init Windows environment
if: matrix.os == 'windows-2022'
run: |
Rename-Item "C:\Program Files\nodejs" "nodejs.old" -Force
Rename-Item "C:\npm" "npm.old" -Force
Remove-Item Env:npm_config_prefix
- name: Git checkout
uses: actions/checkout@v4
env:
GIT_FETCH_DEPTH: ${{ ! env.FGP_CODE_SCAN_ENABLED }} && 1 || 0
with:
fetch-depth: env.GIT_FETCH_DEPTH
- name: Set up JDK 11
uses: actions/setup-java@v4
if: env.JDK_11_BUILD_REQUIRED
with:
distribution: temurin
java-version: '11'
architecture: x64
- name: Set up JDK 17
uses: actions/setup-java@v4
if: env.JDK_17_BUILD_REQUIRED
with:
distribution: temurin
java-version: '17'
architecture: x64
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
architecture: x64
- name: Cache Gradle's cache and wrapper
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache Sonar's cache
uses: actions/cache@v4
if: env.SONAR_CODE_SCAN_ENABLED
with:
path: |
~/.sonar/cache/
key: ${{ runner.os }}-sonar-${{ hashFiles('**/*.gradle*') }}
- name: Grant executable permission
run: chmod +x gradlew plugins/frontend-jdk*/src/integrationTest/resources/*/bin/*
- name: Build plugin for JDK 11+
if: env.JDK_11_BUILD_REQUIRED
run: ./gradlew :plugins:frontend-jdk11:build --console=plain
- name: Build plugin for JDK 17+
if: env.JDK_17_BUILD_REQUIRED
run: ./gradlew :plugins:frontend-jdk17:build --console=plain
- name: Build plugin for JDK 21+
if: env.JDK_21_BUILD_REQUIRED
env:
JDK_21_BUILD_TASK_NAME: env.FGP_CODE_SCAN_ENABLED && 'jacocoTestReport' || 'build'
run: ./gradlew :plugins:frontend-jdk21:${{ env.JDK_21_BUILD_TASK_NAME }} --console=plain
- name: Scan source code and test results
if: env.SONAR_CODE_SCAN_ENABLED
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew :plugins:frontend-jdk21:sonar --console=plain -Dorg.gradle.jvmargs=-Xmx512m -i
- name: Stop Gradle before caching
run: ./gradlew -stop