Skip to content

Commit 977a8d3

Browse files
committed
ci: Improve GitHub Actions workflow readability and performance
- Create reusable composite actions for setup environment and build process - Add caching for EFA installer downloads and compiler outputs - Optimize matrix strategy with excludes for reducing job count - Add proper artifact handling with timeout management - Improve structure with better job organization - Add central workflow configuration
1 parent 92fb93f commit 977a8d3

File tree

6 files changed

+347
-174
lines changed

6 files changed

+347
-174
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: 'Configure, Build, and Test'
2+
description: 'Runs the standard configure, build, test, install sequence'
3+
inputs:
4+
sdk:
5+
description: 'SDK to use (cuda/neuron)'
6+
required: true
7+
platform-aws:
8+
description: 'Enable or disable platform aws'
9+
required: true
10+
default: 'enable'
11+
sudo:
12+
description: 'Use sudo for make install'
13+
required: false
14+
default: 'false'
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Setup ccache
20+
uses: hendrikmuhs/[email protected]
21+
with:
22+
key: ${{ runner.os }}-${{ inputs.sdk }}
23+
24+
- name: Run autogen
25+
shell: bash
26+
run: ./autogen.sh
27+
28+
- name: Configure
29+
shell: bash
30+
run: |
31+
export PATH="/usr/lib/ccache:$PATH"
32+
if [ "${{ inputs.sdk }}" == "neuron" ]
33+
then
34+
./configure --with-mpi=/opt/amazon/openmpi \
35+
--with-libfabric=/opt/amazon/efa \
36+
--enable-tests=yes \
37+
--enable-werror=yes \
38+
--enable-picky-compiler=yes \
39+
--${{ inputs.platform-aws }}-platform-aws \
40+
--enable-neuron
41+
else
42+
./configure --with-mpi=/opt/amazon/openmpi \
43+
--with-libfabric=/opt/amazon/efa \
44+
--enable-tests=yes \
45+
--enable-werror=yes \
46+
--enable-picky-compiler=yes \
47+
--${{ inputs.platform-aws }}-platform-aws \
48+
--with-cuda=/usr/local/cuda/
49+
fi
50+
51+
- name: Build
52+
shell: bash
53+
run: |
54+
export PATH="/usr/lib/ccache:$PATH"
55+
make V=1
56+
57+
- name: Test
58+
shell: bash
59+
run: make check V=1 || (cat tests/unit/test-suite.log && exit 1)
60+
61+
- name: Install
62+
shell: bash
63+
run: |
64+
if [ "${{ inputs.sudo }}" == "true" ]; then
65+
sudo make install V=1
66+
else
67+
make install V=1
68+
fi
69+
70+
- name: Distcheck
71+
shell: bash
72+
run: make distcheck V=1
73+
74+
- name: Upload config.log on failure
75+
if: failure()
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: config-logs-${{ inputs.sdk }}
79+
path: |
80+
config.log
81+
tests/unit/test-suite.log
82+
if-no-files-found: ignore
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Configure Compilers'
2+
description: 'Configures compiler toolchain based on parameters'
3+
inputs:
4+
cc:
5+
description: 'C compiler to use (gcc/clang)'
6+
required: true
7+
cc-variant:
8+
description: 'Compiler variant (latest/legacy)'
9+
required: true
10+
default: 'latest'
11+
cc-version:
12+
description: 'Compiler version'
13+
required: false
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Configure Compiler
19+
shell: bash
20+
run: |
21+
if [ "${{ inputs.cc }}" == "clang" ]; then
22+
if [ "${{ inputs.cc-variant }}" == "latest" ]; then
23+
wget https://apt.llvm.org/llvm.sh
24+
chmod +x llvm.sh
25+
sudo ./llvm.sh ${{ inputs.cc-version || '18' }}
26+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ inputs.cc-version || '18' }} 10
27+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ inputs.cc-version || '18' }} 10
28+
else
29+
sudo apt-get install -y clang
30+
fi
31+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 10
32+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 10
33+
fi
34+
35+
if [ "${{ inputs.cc }}" == "gcc" ]; then
36+
if [ "${{ inputs.cc-variant }}" == "latest" ]; then
37+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
38+
sudo apt-get install -y gcc-${{ inputs.cc-version || '13' }} g++-${{ inputs.cc-version || '13' }}
39+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.cc-version || '13' }} 10
40+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.cc-version || '13' }} 10
41+
else
42+
sudo apt-get install -y gcc g++
43+
fi
44+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 10
45+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 10
46+
fi
47+
48+
# Print out compiler versions for debugging
49+
echo "Compiler versions:"
50+
cc --version
51+
c++ --version
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: 'Setup Environment'
2+
description: 'Sets up the basic environment for builds'
3+
inputs:
4+
container-type:
5+
description: 'Container type (al2023, etc)'
6+
required: true
7+
efa-installer-version:
8+
description: 'EFA installer version'
9+
required: true
10+
default: 'latest'
11+
efa-installer-dir:
12+
description: 'EFA installer directory'
13+
required: true
14+
sdk:
15+
description: 'SDK to install (cuda/neuron)'
16+
required: true
17+
default: 'cuda'
18+
cuda-packages:
19+
description: 'CUDA packages to install'
20+
required: false
21+
default: 'cuda-cudart-devel-12-6 cuda-crt-12-6'
22+
config-manager:
23+
description: 'Configuration manager command'
24+
required: false
25+
default: 'dnf config-manager'
26+
nvidia-distro:
27+
description: 'NVIDIA distribution'
28+
required: false
29+
default: 'amzn2023'
30+
31+
runs:
32+
using: "composite"
33+
steps:
34+
- name: Install base packages
35+
shell: bash
36+
run: |
37+
if [[ "${{ inputs.container-type }}" == *"amazon"* ]]; then
38+
yum -y update && yum -y install git tar util-linux findutils yum-utils
39+
else
40+
sudo apt-get update -y
41+
sudo apt-get install -y build-essential git make
42+
fi
43+
44+
- name: Cache EFA Installer
45+
id: cache-efa-installer
46+
uses: actions/cache@v3
47+
with:
48+
path: aws-efa-installer-${{ inputs.efa-installer-version }}.tar.gz
49+
key: efa-installer-${{ inputs.efa-installer-version }}
50+
51+
- name: Fetch EFA Installer
52+
if: steps.cache-efa-installer.outputs.cache-hit != 'true'
53+
shell: bash
54+
run: |
55+
curl -O https://efa-installer.amazonaws.com/aws-efa-installer-${{ inputs.efa-installer-version }}.tar.gz
56+
57+
- name: Install EFA Installer Dependencies
58+
shell: bash
59+
run: |
60+
tar -xf aws-efa-installer-*.tar.gz
61+
if [[ "${{ inputs.container-type }}" == *"amazon"* ]]; then
62+
cd aws-efa-installer/RPMS/${{ inputs.efa-installer-dir }}/x86_64
63+
find . | grep rpm$ | xargs yum -y localinstall
64+
else
65+
pushd aws-efa-installer/
66+
sudo ./efa_installer.sh -y --skip-kmod
67+
popd
68+
fi
69+
70+
- name: Install hwloc and utilities
71+
shell: bash
72+
run: |
73+
if [[ "${{ inputs.container-type }}" == *"amazon"* ]]; then
74+
yum -y install hwloc-devel autoconf automake libtool gcc gcc-c++ git make
75+
else
76+
sudo apt-get install -y libhwloc-dev autoconf automake libtool
77+
fi
78+
79+
- name: Install CUDA
80+
if: inputs.sdk == 'cuda'
81+
shell: bash
82+
run: |
83+
if [[ "${{ inputs.container-type }}" == *"amazon"* ]]; then
84+
${{ inputs.config-manager }} --add-repo \
85+
http://developer.download.nvidia.com/compute/cuda/repos/${{ inputs.nvidia-distro }}/x86_64/cuda-${{ inputs.nvidia-distro }}.repo \
86+
--save
87+
yum -y clean expire-cache
88+
yum -y install ${{ inputs.cuda-packages }}
89+
else
90+
sudo apt-get update -y && sudo apt-get install -y wget lsb-release
91+
repo="ubuntu$(lsb_release -r | cut -d':' -f2 | xargs | sed 's/[.]//g')"
92+
wget https://developer.download.nvidia.com/compute/cuda/repos/${repo}/$(uname -m)/cuda-keyring_1.1-1_all.deb
93+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
94+
sudo apt-get update -y
95+
sudo apt-get install -y ${{ inputs.cuda-packages }}
96+
fi

.github/workflow-config.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compiler-versions": {
3+
"gcc": {
4+
"latest": "13",
5+
"default": "10"
6+
},
7+
"clang": {
8+
"latest": "18",
9+
"default": "14"
10+
}
11+
},
12+
"cuda-versions": {
13+
"latest": "12.6"
14+
},
15+
"common-apt-packages": "build-essential git libhwloc-dev make",
16+
"efa-installer": {
17+
"default": "latest"
18+
}
19+
}

0 commit comments

Comments
 (0)