build #3914
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: build | |
on: | |
# Run this workflow once every 6 hours against the master branch | |
schedule: | |
- cron: "0 */6 * * *" | |
push: | |
branches: | |
- 'master' | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
linux: | |
strategy: | |
# Notes | |
# - Ubuntu 18.04 is not compatible due to Python being too old | |
# - Pasta does not compile on LLVM 9 or 10, so they have been | |
# removed from the strategy matrix | |
matrix: | |
build_type: [ | |
'Release', | |
'Debug' | |
] | |
image: | |
- { name: 'ubuntu', tag: '22.04' } | |
cxx_common_version: [v0.3.1] | |
llvm_version: [16] | |
runs-on: ubuntu-22.04 | |
container: | |
# Image is built with https://github.com/lifting-bits/cxx-common/blob/master/docker/Dockerfile.ubuntu.vcpkg | |
# Look at that file for the full set of dependencies that may be required for building | |
image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }} | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Get the 🍝 | |
uses: actions/checkout@v2 | |
with: | |
path: src | |
- name: Select the build job count | |
shell: bash | |
id: build_job_count | |
run: | | |
echo ::set-output name=VALUE::$(($(nproc) + 1)) | |
- name: Install system dependencies | |
shell: bash | |
run: | | |
apt update | |
apt install -y build-essential \ | |
ninja-build \ | |
curl \ | |
ccache \ | |
python3-dev \ | |
libncurses-dev \ | |
clang-15 | |
python3 -m pip install nanobind nanobind[global] | |
- name: Setup the build paths | |
shell: bash | |
id: build_paths | |
run: | | |
rel_src_path="src" | |
rel_build_path="build" | |
rel_downloads_path="downloads" | |
rel_install_path="install" | |
rel_ccache_path="ccache" | |
mkdir -p ${rel_build_path} \ | |
${rel_downloads_path} \ | |
${rel_install_path} \ | |
${rel_ccache_path} | |
echo ::set-output name=SOURCE::$(realpath ${rel_src_path}) | |
echo ::set-output name=BUILD::$(realpath ${rel_build_path}) | |
echo ::set-output name=INSTALL::$(realpath ${rel_install_path}) | |
echo ::set-output name=REL_DOWNLOADS::${rel_downloads_path} | |
echo ::set-output name=DOWNLOADS::$(realpath ${rel_downloads_path}) | |
echo ::set-output name=REL_CCACHE::${rel_ccache_path} | |
echo ::set-output name=CCACHE::$(realpath ${rel_ccache_path}) | |
- name: Update the cache (ccache) | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.build_paths.outputs.REL_CCACHE }} | |
key: | | |
gitmodules_${{ matrix.image.name }}-${{ matrix.image.tag }}_${{ matrix.build_type }}_${{ matrix.llvm_version }}_${{ matrix.cxx_common_version }}_${{ github.sha }} | |
restore-keys: | | |
gitmodules_${{ matrix.image.name }}-${{ matrix.image.tag }}_${{ matrix.build_type }}_${{ matrix.llvm_version }}_${{ matrix.cxx_common_version }} | |
- name: Update the cache (downloads) | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.build_paths.outputs.REL_DOWNLOADS }} | |
key: | | |
gitmodules_${{ matrix.image.name }}-${{ matrix.image.tag }}_${{ matrix.build_type }}_${{ matrix.llvm_version }}_${{ matrix.cxx_common_version }}_${{ github.sha }} | |
restore-keys: | | |
gitmodules_${{ matrix.image.name }}-${{ matrix.image.tag }}_${{ matrix.build_type }}_${{ matrix.llvm_version }}_${{ matrix.cxx_common_version }} | |
- name: Acquire the cxx-common ${{ matrix.cxx_common_version }} package for LLVM ${{ matrix.llvm_version }} | |
shell: bash | |
id: cxx_common_installer | |
working-directory: ${{ steps.build_paths.outputs.DOWNLOADS }} | |
run: | | |
folder_name="vcpkg_${{ matrix.image.name }}-${{ matrix.image.tag }}_llvm-${{ matrix.llvm_version }}-pasta_amd64" | |
file_name="${folder_name}.tar.xz" | |
url="https://github.com/lifting-bits/cxx-common/releases/download/${{ matrix.cxx_common_version }}/${file_name}" | |
file_path="${{ steps.build_paths.outputs.DOWNLOADS }}/${file_name}" | |
if [[ ! -f "${file_path}" ]]; then | |
curl "${url}" -L -O | |
ls -t ${{ steps.build_paths.outputs.DOWNLOADS }}/*.tar.xz | tail -n +2 | while read archive_file ; do | |
rm "${archive_file}" | |
done | |
fi | |
tar xf "${file_path}" \ | |
-C "${{ steps.build_paths.outputs.INSTALL }}" | |
echo ::set-output name=PATH::${{ steps.build_paths.outputs.INSTALL }}/${folder_name} | |
echo "${{ steps.build_paths.outputs.INSTALL }}/${folder_name}/installed/x64-linux-rel/bin" >> $GITHUB_PATH | |
- name: Configure the project | |
working-directory: ${{ steps.build_paths.outputs.BUILD }} | |
shell: bash | |
env: | |
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }} | |
run: | | |
cmake -G "Ninja" \ | |
-DCMAKE_TOOLCHAIN_FILE="${{ steps.cxx_common_installer.outputs.PATH }}/scripts/buildsystems/vcpkg.cmake" \ | |
-DVCPKG_ROOT="${{ steps.cxx_common_installer.outputs.PATH }}" \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DCMAKE_C_COMPILER="$(which clang-15)" \ | |
-DCMAKE_CXX_COMPILER="$(which clang++-15)" \ | |
-DPASTA_BOOTSTRAP_MACROS=OFF \ | |
-DPASTA_BOOTSTRAP_TYPES=OFF \ | |
-DPASTA_ENABLE_TESTING=OFF \ | |
-DPASTA_ENABLE_INSTALL=ON \ | |
-DLLVM_DIR="${{ steps.cxx_common_installer.outputs.PATH }}/installed/x64-linux-rel/share/llvm" \ | |
-DClang_DIR="${{ steps.cxx_common_installer.outputs.PATH }}/installed/x64-linux-rel/share/clang" \ | |
"${{ steps.build_paths.outputs.SOURCE }}" | |
- name: Build the project | |
working-directory: ${{ steps.build_paths.outputs.BUILD }} | |
shell: bash | |
env: | |
CCACHE_DIR: ${{ steps.build_paths.outputs.CCACHE }} | |
run: | | |
cmake --build . -j ${{ steps.build_job_count.outputs.VALUE }} | |
- name: Try loading the Python extension | |
shell: bash | |
run: env PYTHONPATH=${{ steps.build_paths.outputs.BUILD }}/bindings/python python3 -c "import pypasta" | |
- name: Reclaim disk space | |
shell: bash | |
run: | | |
rm -rf ${{ steps.build_paths.outputs.BUILD }} |