CI/CD Using Github Actions is updated. #6
Workflow file for this run
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: BuildLLVM | |
on: | |
push: | |
branches: | |
- release/13.x | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
build_on_OSs: | |
name: Build LLVM on ${{ matrix.platform.name }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- name: macos-11-release | |
os_type: macos | |
os_name: macos-11 | |
arch: x86_64 | |
build_type: Release | |
- name: macos-11-debug | |
os_type: macos | |
os_name: macos-11 | |
arch: x86_64 | |
build_type: Debug | |
- name: ubuntu-latest-release | |
os_type: ubuntu | |
os_name: ubuntu-latest | |
build_type: Release | |
- name: ubuntu-latest-debug | |
os_type: ubuntu | |
os_name: ubuntu-latest | |
build_type: Debug | |
- name: windows-latest-release | |
os_type: windows | |
os_name: windows-latest | |
build_type: Release | |
- name: windows-latest-debug | |
os_type: windows | |
os_name: windows-latest | |
build_type: Debug | |
- name: manylinux2014-release | |
os_type: manylinux | |
os_name: ubuntu-latest | |
container_image: quay.io/pypa/manylinux2014_x86_64 | |
build_type: Release | |
# We don't build on manylinux2014-debug platform because the the machine runs out of space while building it | |
runs-on: ${{ matrix.platform.os_name }} | |
container: | |
image: ${{ matrix.platform.container_image || '' }} | |
steps: | |
- name: Free up some space for Debug builds | |
if : matrix.platform.build_type == 'Debug' | |
shell: bash | |
run: | | |
rm -rf /opt/hostedtoolcache | |
rm -rf /usr/share/dotnet | |
rm -rf /usr/local/share/dotnet | |
- name: Checkout LLVM | |
uses: actions/checkout@v3 | |
- name: Set MSVC as the default compiler on Windows | |
if: matrix.platform.os_type == 'windows' | |
uses: ilammy/[email protected] | |
- name: Upgrade gcc on ManyLinux | |
if: matrix.platform.os_type == 'manylinux' | |
shell: bash | |
run: | | |
yum install -y centos-release-scl | |
yum install -y devtoolset-11 | |
scl enable devtoolset-11 bash | |
echo "/opt/rh/devtoolset-11/root/usr/bin" >> $GITHUB_PATH | |
- name: Setup Ninja | |
uses: seanmiddleditch/gha-setup-ninja@master | |
- name: Install ccache | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE} | |
if [ "${{ matrix.platform.os_type }}" == 'macos' ]; then | |
brew install ccache | |
elif [ "${{ matrix.platform.os_type }}" == 'ubuntu' ]; then | |
sudo apt-get update | |
sudo apt-get install -y ccache | |
elif [ "${{ matrix.platform.os_type }}" == 'manylinux' ]; then | |
mkdir -p ccache | |
cd ccache | |
curl -L https://github.com/ccache/ccache/releases/download/v4.9.1/ccache-4.9.1.tar.gz > ccache.tar.gz | |
tar -zxf ccache.tar.gz | |
rm ccache.tar.gz | |
mkdir -p build-ccache | |
mkdir -p install-ccache | |
cd build-ccache | |
cmake -DCMAKE_INSTALL_PREFIX="$RUNNER_WORKSPACE/ccache/install-ccache" -DCMAKE_BUILD_TYPE=Release ../ccache-4.9.1 | |
cmake --build . --target install | |
echo "$RUNNER_WORKSPACE/ccache/install-ccache/bin" >> $GITHUB_PATH | |
fi | |
- name: Prepare ccache timestamp on non-Windows platforms | |
if: matrix.platform.os_type != 'windows' | |
id: ccache_cache_timestamp | |
shell: cmake -P {0} | |
run: | | |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) | |
message("::set-output name=timestamp::${current_date}") | |
- name: Set ccache cache directory on non-Windows | |
if: matrix.platform.os_type != 'windows' | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE} | |
echo "CCACHE_DIR=${RUNNER_WORKSPACE}/.ccache" >> "${GITHUB_ENV}" | |
echo "COMPILER_LAUNCHER=ccache" >> "${GITHUB_ENV}" | |
- name: Cache ccache files on non-Windows | |
if: matrix.platform.os_type != 'windows' | |
uses: actions/cache@v3 | |
with: | |
path: ${RUNNER_WORKSPACE}/.ccache | |
key: | |
${{ runner.os }}-${{ steps.ccache_cache_timestamp.outputs.timestamp | |
}} | |
restore-keys: | | |
${{ runner.os }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} | |
${{ runner.os }}- | |
- name: Create build directory | |
shell: bash | |
run: mkdir -p ${RUNNER_WORKSPACE}/build-llvm | |
- name: Configure CMake for LLVM | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE}/build-llvm | |
cmake $GITHUB_WORKSPACE/llvm \ | |
-G "Ninja" \ | |
-DCMAKE_C_COMPILER_LAUNCHER=${COMPILER_LAUNCHER} \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=${COMPILER_LAUNCHER} \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.platform.build_type }} \ | |
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.platform.arch }} \ | |
-DCMAKE_INSTALL_PREFIX="${RUNNER_WORKSPACE}/install-llvm" | |
- name: Build and install LLVM | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE}/build-llvm | |
cmake --build . --target install --config ${{ matrix.platform.build_type }} | |
- name: Give Execute permissions to LLVM binaries | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE} | |
cd install-llvm/bin | |
chmod a+x llvm-config | |
- name: Set artifacts path and name | |
shell: bash | |
run: | | |
cd ${RUNNER_WORKSPACE} | |
echo "artifacts_name=llvm-${{ matrix.platform.name }}" >> "${GITHUB_ENV}" | |
# we need to use relative path as actions/upload-artifact@v1 cannot find it on containerized runners | |
echo "artifacts_path=../install-llvm" >> "${GITHUB_ENV}" | |
- name: Upload LLVM binaries | |
uses: actions/upload-artifact@v1 | |
with: | |
name: ${{env.artifacts_name}} | |
path: ${{env.artifacts_path}} |