Skip to content

Commit d9bf9ab

Browse files
authored
Combine native platform specific workflows and add reusable actions (#625)
The following reusable actions were created to achieve this: * [ci] Create and use Save PR Info reusable action * [ci] Create and use setting up compiler reusable action * [ci] Create and use install dependencies reusable action * [ci] Create and use selecting default build type into reusable action * [ci] Merge native specific platform workflows into single main.yml workflow file * [docs] Update README.md to reference new single workflow file
1 parent 40ecc1d commit d9bf9ab

File tree

14 files changed

+580
-1229
lines changed

14 files changed

+580
-1229
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Install Dependencies'
2+
description: 'This PR installs the dependencies needed'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
8+
- name: Install dependencies on MacOS
9+
if: runner.os == 'macOS'
10+
shell: bash
11+
run: |
12+
brew update --force
13+
if [[ "$(uname -m)" == "x86_64" ]]; then
14+
brew remove swiftlint
15+
else
16+
brew remove unxip
17+
fi
18+
# workaround for https://github.com/actions/setup-python/issues/577
19+
for pkg in $(brew list | grep '^python@'); do
20+
brew unlink "$pkg"
21+
brew link --overwrite "$pkg"
22+
done
23+
brew upgrade openssl >/dev/null 2>&1
24+
brew upgrade --force
25+
brew install ninja
26+
brew install eigen
27+
brew install boost
28+
brew install gnu-sed
29+
pip install distro pytest
30+
31+
- name: Install dependencies on Linux
32+
if: runner.os == 'Linux'
33+
shell: bash
34+
run: |
35+
# Install deps
36+
sudo apt-get update
37+
sudo apt-get install valgrind ninja-build
38+
sudo apt-get install git g++ debhelper devscripts gnupg python3 doxygen graphviz python3-sphinx
39+
sudo apt-get install -y libc6-dbg
40+
sudo apt-get install valgrind
41+
sudo apt autoremove
42+
sudo apt clean
43+
# Install libraries used by the cppyy test suite
44+
sudo apt install libeigen3-dev
45+
sudo apt install libboost-all-dev
46+
47+
48+
- name: Install dependencies on Windows
49+
if: runner.os == 'Windows'
50+
shell: powershell
51+
run: |
52+
choco install findutils
53+
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"
54+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Save PR Info'
2+
description: 'This PR saves the PR Info for the job'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
8+
- name: Save PR Info on Unix Systems
9+
if: ${{ runner.os != 'Windows' }}
10+
shell: bash
11+
run: |
12+
mkdir -p ./pr
13+
echo ${{ github.event.number }} > ./pr/NR
14+
echo ${{ github.repository }} > ./pr/REPO
15+
16+
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
17+
if [[ "$cling_on" == "ON" ]]; then
18+
export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} | tr '\t' '-')
19+
export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-')
20+
else
21+
export CLING_HASH="Repl"
22+
# May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x
23+
# which could be quite often for new releases
24+
export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-')
25+
fi
26+
27+
echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV
28+
echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV
29+
30+
- name: Save PR Info on Windows systems
31+
if: runner.os == 'Windows'
32+
shell: powershell
33+
run: |
34+
#can be found
35+
mkdir ./pr
36+
echo "${{ github.event.number }}" > ./pr/NR
37+
echo ${{ github.repository }} > ./pr/REPO
38+
39+
if ( "${{ matrix.cling }}" -imatch "On" )
40+
{
41+
$env:CLING_HASH_TEMP = ( git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} )
42+
$env:CLING_HASH = $env:CLING_HASH_TEMP -replace "\t","-"
43+
}
44+
else
45+
{
46+
$env:CLING_HASH="Repl"
47+
# May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x
48+
# which could be quite often for new releases
49+
$env:LLVM_HASH_TEMP = (git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x )
50+
$env:LLVM_HASH = $env:LLVM_HASH_TEMP -replace "\t","-"
51+
}
52+
53+
echo "CLING_HASH=$env:CLING_HASH"
54+
echo "LLVM_HASH=$env:LLVM_HASH"
55+
56+
echo "CLING_HASH=$env:CLING_HASH" >> $GITHUB_ENV
57+
echo "LLVM_HASH=$env:LLVM_HASH" >> $GITHUB_ENV
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Select Default Build Type'
2+
description: 'This action selects the default build typose'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Select default build type of Unix Systems
8+
if: runner.os != 'Windows'
9+
shell: bash
10+
run: |
11+
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
12+
echo "CODE_COVERAGE=0" >> $GITHUB_ENV
13+
echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
14+
15+
- name: Select default build type on Windows
16+
if: runner.os == 'Windows'
17+
shell: powershell
18+
run: |
19+
echo "BUILD_TYPE=Release" >> $env:GITHUB_ENV
20+
echo "CODE_COVERAGE=0" >> $env:GITHUB_ENV
21+
$env:ncpus=$([Environment]::ProcessorCount)
22+
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV
23+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: 'Setup Compiler'
2+
description: 'This PR sets up the compiler for the job'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
8+
- name: Setup Compiler on MacOS
9+
if: runner.os == 'macOS'
10+
shell: bash
11+
run: |
12+
vers="${compiler#*-}"
13+
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then
14+
brew install "gcc@$vers"
15+
echo "CC=gcc-${vers}" >> $GITHUB_ENV
16+
echo "CXX=g++-${vers}" >> $GITHUB_ENV
17+
else
18+
brew install llvm@15
19+
if [[ "$(uname -m)" == "x86_64" ]]; then
20+
echo "CC=/usr/local/opt/llvm@15/bin/clang" >> $GITHUB_ENV
21+
echo "CXX=/usr/local/opt/llvm@15/bin/clang++" >> $GITHUB_ENV
22+
else
23+
echo "CC=/opt/homebrew/opt/llvm@15/bin/clang" >> $GITHUB_ENV
24+
echo "CXX=/opt/homebrew/opt/llvm@15/bin/clang++" >> $GITHUB_ENV
25+
fi
26+
fi
27+
echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
28+
env:
29+
compiler: ${{ matrix.compiler }}
30+
31+
- name: Setup Compiler on Linux
32+
if: runner.os == 'Linux'
33+
shell: bash
34+
run: |
35+
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
36+
vers="${compiler#*-}"
37+
os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`"
38+
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then
39+
sudo apt install -y gcc-${vers} g++-${vers} lld
40+
echo "CC=gcc-${vers}" >> $GITHUB_ENV
41+
echo "CXX=g++-${vers}" >> $GITHUB_ENV
42+
else
43+
if ! sudo apt install -y clang-${vers}; then
44+
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
45+
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list
46+
sudo apt-get update
47+
sudo apt-get install -y clang-${vers}
48+
fi
49+
echo "CC=clang-${vers}" >> $GITHUB_ENV
50+
echo "CXX=clang++-${vers}" >> $GITHUB_ENV
51+
fi
52+
env:
53+
compiler: ${{ matrix.compiler }}
54+
55+
- name: Save Compiler on Windows Systems
56+
if: runner.os == 'Windows'
57+
shell: powershell
58+
run: |
59+
if ( "${{ matrix.compiler }}" -imatch "clang" )
60+
{
61+
$ver="${{ matrix.compiler }}".split("-")[1]
62+
choco install llvm --version=$ver --no-progress -my
63+
clang --version
64+
#
65+
$env:CC="clang"
66+
$env:CXX="clang++"
67+
echo "CC=clang" >> $env:GITHUB_ENV
68+
echo "CXX=clang++" >> $env:GITHUB_ENV
69+
}
70+
elseif ( "${{ matrix.compiler }}" -imatch "msvc" )
71+
{
72+
# MSVC is builtin in container image
73+
}
74+
else
75+
{
76+
echo "Unsupported compiler - fix YAML file"
77+
}

0 commit comments

Comments
 (0)