Build #312
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: | |
push: | |
branches: ['main'] | |
workflow_dispatch: | |
inputs: | |
os: | |
description: 'O/S' | |
required: true | |
default: 'Ubuntu' | |
type: choice | |
options: | |
- 'Linux' | |
- 'Mac' | |
- 'Windows' | |
- 'All' | |
javaVersion: | |
description: 'JDK compatibility' | |
required: true | |
default: '21' | |
type: choice | |
options: | |
- '21' | |
- '17' | |
- '11' | |
- 'All' | |
jobs: | |
define-matrix: | |
name: Define matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-environment-variables.outputs.matrix }} | |
steps: | |
- name: Set environment variables | |
id: set-environment-variables | |
run: | | |
requestedJavaVersions=${{ inputs.javaVersion }} | |
if [[ "$requestedJavaVersions" == "All" ]]; then | |
jdk21BuildRequested=true | |
jdk17BuildRequested=true | |
jdk11BuildRequested=true | |
elif [[ (-z "$requestedJavaVersions") || ("$requestedJavaVersions" == "21") ]]; then | |
jdk21BuildRequested=true | |
jdk17BuildRequested=false | |
jdk11BuildRequested=false | |
elif [[ "$requestedJavaVersions" == "17" ]]; then | |
jdk21BuildRequested=false | |
jdk17BuildRequested=true | |
jdk11BuildRequested=false | |
elif [[ "$requestedJavaVersions" == "11" ]]; then | |
jdk21BuildRequested=false | |
jdk17BuildRequested=false | |
jdk11BuildRequested=true | |
fi | |
requestedOs=${{ inputs.os }} | |
selectedOs=() | |
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Linux") ]]; then | |
selectedOs+=(Linux) | |
fi | |
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Mac") ]]; then | |
selectedOs+=(Mac) | |
fi | |
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Windows") ]]; then | |
selectedOs+=(Windows) | |
fi | |
echo "Selected OS: ${selectedOs[*]}" | |
matrix="{\"include\": [" | |
selectedOsMaxIndex=$((${#selectedOs[@]} - 1)) | |
for (( i=0; i<${#selectedOs[@]}; i++ )); do | |
case "${selectedOs[$i]}" in | |
Linux) | |
os=ubuntu-24.04 | |
name=Ubuntu | |
codeScanEnabled=$(if [[ "$jdk21BuildRequested" -eq 1 ]]; then echo true; else echo false; fi) | |
gitFetchDepth=$(if [[ "$codeScanEnabled" == true ]]; then echo 0; else echo 1; fi) | |
pluginTaskNameJdk21=$(if [[ "$codeScanEnabled" == true ]]; then echo jacocoTestReport; else echo build; fi) | |
;; | |
Mac) | |
os=macos-14 | |
name=Mac | |
codeScanEnabled=false | |
gitFetchDepth=1 | |
pluginTaskNameJdk21=build | |
;; | |
Windows) | |
os=windows-2022 | |
name=Windows | |
codeScanEnabled=false | |
gitFetchDepth=1 | |
pluginTaskNameJdk21=build | |
;; | |
esac | |
jsonProperties="{ \"os\": \"$os\", " | |
jsonProperties+="\"name\": \"$name\", " | |
jsonProperties+="\"codeScanEnabled\": $codeScanEnabled, " | |
jsonProperties+="\"gitFetchDepth\": $gitFetchDepth, " | |
jsonProperties+="\"pluginTaskNameJdk21\": \"$pluginTaskNameJdk21\", " | |
jsonProperties+="\"jdk11BuildRequested\": $jdk11BuildRequested, " | |
jsonProperties+="\"jdk17BuildRequested\": $jdk17BuildRequested, " | |
jsonProperties+="\"jdk21BuildRequested\": $jdk21BuildRequested }" | |
echo "OS: $jsonProperties" | |
matrix+=$jsonProperties | |
if [[ $i < $selectedOsMaxIndex ]]; then | |
matrix+=", " | |
fi | |
done | |
matrix+="]}" | |
echo "Matrix: $matrix" | |
echo "JDK build requests: 11=$jdk11BuildRequested" 17=$jdk17BuildRequested 21=$jdk21BuildRequested | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
run-matrix: | |
needs: define-matrix | |
strategy: | |
matrix: ${{ fromJSON(needs.define-matrix.outputs.matrix) }} | |
name: Building on ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Building parameters | |
run: | | |
echo "OS: ${{ matrix.os }}" | |
echo "Target JDKS: 11=${{ matrix.jdk11BuildRequested }}, 17=${{ matrix.jdk17BuildRequested }}, 21=${{ matrix.jdk21BuildRequested }}" | |
echo "Git fetch depth: ${{ matrix.gitFetchDepth }}" | |
echo "[JDK 21] Code scan enabled: ${{ matrix.codeScanEnabled }}" | |
echo "[JDK 21] Task name: ${{ matrix.pluginTaskNameJdk21 }}" | |
- name: Init Ubuntu environment | |
if: matrix.name == 'Ubuntu' | |
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.name == 'Mac' | |
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.name == 'Windows' | |
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 | |
with: | |
fetch-depth: matrix.gitFetchDepth | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
if: matrix.jdk11BuildRequested | |
with: | |
distribution: temurin | |
java-version: '11' | |
architecture: x64 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
if: matrix.jdk17BuildRequested | |
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: matrix.codeScanEnabled | |
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: matrix.jdk11BuildRequested | |
run: ./gradlew :plugins:frontend-jdk11:build --console=plain | |
- name: Build plugin for JDK 17+ | |
if: matrix.jdk17BuildRequested | |
run: ./gradlew :plugins:frontend-jdk17:build --console=plain | |
- name: Build plugin for JDK 21+ | |
if: matrix.jdk21BuildRequested | |
run: ./gradlew :plugins:frontend-jdk21:${{ matrix.pluginTaskNameJdk21 }} --console=plain | |
- name: Scan source code and test results | |
if: matrix.codeScanEnabled | |
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 |