Skip to content

Commit

Permalink
Centralize shared vars for different Github actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gmunozfe committed Oct 22, 2024
1 parent dc7e511 commit 0fb4c83
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 30 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ on:
issues:
types: [opened, reopened]
jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

message:
runs-on: ubuntu-latest
runs-on: ${{ needs.shared-vars.outputs.os }}
needs: shared-vars
steps:
- uses: actions/checkout@v4
- name: Send a stream message
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pr-backporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

compute-targets:
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged }}
runs-on: ubuntu-latest
runs-on: ${{ needs.shared-vars.outputs.os }}
needs: shared-vars
outputs:
target-branches: ${{ steps.set-targets.outputs.targets }}
env:
Expand All @@ -43,8 +47,8 @@ jobs:
backporting:
if: ${{ github.event.pull_request.state == 'closed' && github.event.pull_request.merged && needs.compute-targets.outputs.target-branches != '[]' }}
name: "[${{ matrix.target-branch }}] - Backporting"
runs-on: ubuntu-latest
needs: compute-targets
runs-on: ${{ needs.shared-vars.outputs.os }}
needs: [shared-vars, compute-targets]
strategy:
matrix:
target-branch: ${{ fromJSON(needs.compute-targets.outputs.target-branches) }}
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/pr-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,44 @@ on:
- '.ci/jenkins/**'

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

kogito-downstream-build:
needs: shared-vars
concurrency:
group: pr-${{ matrix.job_name }}_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
timeout-minutes: 180
strategy:
matrix:
job_name: [ kogito-quarkus-examples, kogito-springboot-examples, serverless-workflow-examples ]
os: [ubuntu-latest]
java-version: [17]
maven-version: ['3.9.6']
include:
- job_name: kogito-quarkus-examples
repository: incubator-kie-kogito-examples
env_KOGITO_EXAMPLES_SUBFOLDER_POM: kogito-quarkus-examples/
os: ${{ needs.shared-vars.outputs.os }}
java-version: ${{ needs.shared-vars.outputs.java-version }}
maven-version: ${{ needs.shared-vars.outputs.maven-version }}
- job_name: kogito-springboot-examples
repository: incubator-kie-kogito-examples
env_KOGITO_EXAMPLES_SUBFOLDER_POM: kogito-springboot-examples/
os: ${{ needs.shared-vars.outputs.os }}
java-version: ${{ needs.shared-vars.outputs.java-version }}
maven-version: ${{ needs.shared-vars.outputs.maven-version }}
- job_name: serverless-workflow-examples
repository: incubator-kie-kogito-examples
env_KOGITO_EXAMPLES_SUBFOLDER_POM: serverless-workflow-examples/
os: ${{ needs.shared-vars.outputs.os }}
java-version: ${{ needs.shared-vars.outputs.java-version }}
maven-version: ${{ needs.shared-vars.outputs.maven-version }}
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.job_name }} (${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }})
steps:
- name: Clean Disk Space
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/ubuntu-disk-space@main
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ contains(matrix.os, 'ubuntu') }}
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pr-jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ on:
- '.github/workflows/jenkins-tests-PR.yml'

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

dsl-tests:
concurrency:
group: ${{ github.repository.name }}_dsl_tests-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
runs-on: ${{ needs.shared-vars.outputs.os }}
needs: shared-vars
name: DSL
steps:
- name: DSL tests
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/pr-kogito-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,28 @@ on:
- '.ci/jenkins/**'

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

build-chain:
needs: shared-vars
concurrency:
group: pr-kogito-apps_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
timeout-minutes: 360
strategy:
matrix:
os: [ubuntu-latest]
java-version: [17]
maven-version: ['3.9.6']
include:
- os: ${{ needs.shared-vars.outputs.os }}
java-version: ${{ needs.shared-vars.outputs.java-version }}
maven-version: ${{ needs.shared-vars.outputs.maven-version }}
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }}
steps:
- name: Clean Disk Space
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/ubuntu-disk-space@main
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ contains(matrix.os, 'ubuntu') }}
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/publish-jitexecutor-native-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ on:
required: true

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

build_jitexecutor_native:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
include:
- os: [${{ needs.shared-vars.outputs.os }}, ${{ needs.shared-vars.outputs.macos }}, ${{ needs.shared-vars.outputs.windows-os }}]

steps:
- name: Set version
Expand Down Expand Up @@ -53,7 +57,7 @@ jobs:
- name: "Set up Maven"
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: ${{ needs.shared-vars.outputs.maven-version }}

- name: Import GPG key
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -243,10 +247,10 @@ jobs:
"@
Add-Content "$env:WORKDIR_PATH\.m2\settings.xml" $contentToAdd
- name: "Set up JDK 17"
- name: "Set up JDK"
uses: actions/setup-java@v4
with:
java-version: "17"
java-version: ${{ needs.shared-vars.outputs.java-version }}
distribution: "temurin"
overwrite-settings: false

Expand All @@ -264,10 +268,10 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install make && \
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \
tar -xzf graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \
sudo mv graalvm-community-openjdk-17.0.9+9.1 /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1/Contents/Home
wget ${{ needs.shared-vars.outputs.graalvm-jdk-macos-url }} && \
tar -xzf ${{ needs.shared-vars.outputs.graalvm-jdk-macos-bin }} && \
sudo mv ${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} /Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}/Contents/Home
export PATH=${GRAALVM_HOME}/bin:$PATH
echo "${GRAALVM_HOME}/bin" >> $GITHUB_PATH && \
echo "GRAALVM_HOME=${GRAALVM_HOME}" >> $GITHUB_ENV && \
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/publish-jitexecutor-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ on:
required: true

jobs:
shared-vars:
uses: ./.github/workflows/shared-vars.yml

build_jitexecutor_native:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
include:
- os: [${{ needs.shared-vars.outputs.os }}, ${{ needs.shared-vars.outputs.macos }}, ${{ needs.shared-vars.outputs.windows-os }}]

steps:
- name: Get current date
Expand Down Expand Up @@ -54,12 +58,12 @@ jobs:
- name: "Set up Maven"
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: ${{ needs.shared-vars.outputs.maven-version }}

- name: "Set up JDK 17"
- name: "Set up JDK"
uses: actions/setup-java@v4
with:
java-version: "17"
java-version: ${{ needs.shared-vars.outputs.java-version }}
distribution: "zulu"
server-id: apache.snapshots.https
server-username: NEXUS_USER
Expand All @@ -79,10 +83,10 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install make && \
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \
tar -xzf graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz && \
sudo mv graalvm-community-openjdk-17.0.9+9.1 /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.9+9.1/Contents/Home
wget ${{ needs.shared-vars.outputs.graalvm-jdk-macos-url }} && \
tar -xzf ${{ needs.shared-vars.outputs.graalvm-jdk-macos-bin }} && \
sudo mv ${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }} /Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/${{ needs.shared-vars.outputs.graalvm-jdk-macos-vm }}/Contents/Home
export PATH=${GRAALVM_HOME}/bin:$PATH
echo "${GRAALVM_HOME}/bin" >> $GITHUB_PATH && \
echo "GRAALVM_HOME=${GRAALVM_HOME}" >> $GITHUB_ENV && \
Expand All @@ -100,7 +104,7 @@ jobs:
if: runner.os == 'Windows'
uses: graalvm/setup-graalvm@v1
with:
java-version: "17"
java-version: ${{ needs.shared-vars.outputs.java-version }}
components: "native-image"

- name: "Configure Pagefile"
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/shared-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

name: 'Shared Variables to be reused in different workflows'

on:
workflow_call:
outputs:
os:
description: 'OS to use'
value: 'ubuntu-22.04'
java-version:
description: 'Java version to use'
value: '17'
maven-version:
description: 'Maven version to use'
value: '3.9.6'
macos:
description: 'macOS to use'
value: 'macos-13'
windows-os:
description: 'windows OS to use'
value: 'windows-2022'
graalvm-jdk-macos-url:
description: 'graalvm-community-jdk for macOS URL'
value: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz'
graalvm-jdk-macos-bin:
description: 'graalvm-community-jdk for macOS binaries'
value: 'graalvm-community-jdk-17.0.9_macos-x64_bin.tar.gz'
graalvm-jdk-macos-vm:
description: 'graalvm-community-jdk for macOS VM'
value: 'graalvm-community-openjdk-17.0.9+9.1'

jobs:
set-variables:
runs-on: ubuntu-latest
steps:
- name: Set variables
run: echo "This job is set common variables for other workflows."

0 comments on commit 0fb4c83

Please sign in to comment.