Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Fix linux build with clang #350

Fix linux build with clang

Fix linux build with clang #350

name: Build and Test
on:
push:
branches:
- master
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04 GCC",
os: ubuntu-20.04,
shell: bash,
cc: "gcc",
cxx: "g++",
extra_cmake_flags: "-DDISABLE_SSL=on",
static_checks: true,
artifact: "buildcache-linux.tar.gz",
artifact_format: "gnutar",
artifact_tar_flags: "z",
}
- {
name: "macOS Latest Clang",
os: macos-latest,
shell: bash,
cc: "clang",
cxx: "clang++",
extra_cmake_flags: "-DCMAKE_OSX_ARCHITECTURES=x86_64\\;arm64",
artifact: "buildcache-macos.zip",
artifact_format: "zip",
}
- {
name: "Windows Server 2022 MSVC",
os: windows-2022,
shell: cmd,
environment_script: "call \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64",
cc: "cl",
cxx: "cl",
artifact: "buildcache-windows.zip",
artifact_format: "zip",
}
- {
name: "Linux/MinGW (cross-compile for Windows)",
os: ubuntu-20.04,
shell: bash,
cc: "x86_64-w64-mingw32-gcc",
cxx: "x86_64-w64-mingw32-g++",
extra_cmake_flags: "-DCMAKE_BUILD_WITH_INSTALL_RPATH=on",
cross_compile: true,
static_checks: true,
}
- {
name: "Ubuntu 22.04 GCC",
os: ubuntu-22.04,
shell: bash,
cc: "gcc",
cxx: "g++",
}
steps:
- uses: actions/checkout@v1
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8.x
# TODO(m): MinGW cross compilation fails with CMake v3.22.x+. For some
# reason "-isystem /usr/include" is added to the GCC command line, which
# breaks MinGW system includes.
- name: Setup CMake and Ninja
uses: lukka/[email protected]
- name: Setup Clang tools
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt install -y clang-tidy clang-format
- name: Setup MinGW
if: ${{ runner.os == 'Linux' && contains(matrix.config.cxx, 'mingw') }}
run: |
sudo apt update
sudo apt install -y mingw-w64
- name: Configure
env:
CC: "${{ matrix.config.cc }}"
CXX: "${{ matrix.config.cxx }}"
run: |
${{ matrix.config.environment_script }}
cmake -S src -B build -DCMAKE_BUILD_TYPE=Release -G Ninja ${{ matrix.config.extra_cmake_flags }}
- name: Build
env:
NINJA_STATUS: "[%f/%t %o s] "
run: |
${{ matrix.config.environment_script }}
cmake --build build
- name: Run unit tests
if: ${{ !matrix.config.cross_compile }}
working-directory: build
env:
CTEST_OUTPUT_ON_FAILURE: "ON"
run: |
ctest -j 5
- name: Run system tests
if: ${{ runner.os != 'Windows' && !matrix.config.cross_compile }}
working-directory: build
env:
CC: "${{ matrix.config.cc }}"
CXX: "${{ matrix.config.cxx }}"
run: |
../test_scripts/run_file_lock_stresstest.sh
../test_scripts/build_with_buildcache.sh
- name: Run static checks
if: ${{ matrix.config.static_checks }}
run: test_scripts/run_linters.py -p build
- name: Install Strip
if: ${{ matrix.config.artifact }}
run: cmake --install build --prefix buildcache --strip
- name: Pack
if: ${{ matrix.config.artifact }}
run: cmake -E tar cv${{ matrix.config.artifact_tar_flags }}f ${{ matrix.config.artifact }} --format=${{ matrix.config.artifact_format }} buildcache
- name: Upload
if: ${{ matrix.config.artifact }}
uses: actions/upload-artifact@v1
with:
path: ./${{ matrix.config.artifact }}
name: ${{ matrix.config.artifact }}
release:
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- uses: actions/upload-artifact@v1
with:
path: ./upload_url
name: upload_url
publish:
if: contains(github.ref, 'tags/v')
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04 GCC",
artifact: "buildcache-linux.tar.gz",
artifact_content_type: "application/gzip",
os: ubuntu-latest
}
- {
name: "macOS Latest Clang",
artifact: "buildcache-macos.zip",
artifact_content_type: "application/zip",
os: ubuntu-latest
}
- {
name: "Windows Server 2022 MSVC",
artifact: "buildcache-windows.zip",
artifact_content_type: "application/zip",
os: ubuntu-latest
}
needs: release
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ matrix.config.artifact }}
path: ./
- name: Download URL
uses: actions/download-artifact@v1
with:
name: upload_url
path: ./
- id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo ::set-output name=upload_url::$upload_url
- name: Upload to Release
id: upload_to_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: ${{ matrix.config.artifact_content_type }}