CI #134
This file contains hidden or 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: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
schedule: | |
- cron: '0 4 * * 6' # Run every Sunday | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies on Linux | |
run: | | |
sudo apt-get install libopenblas-dev ninja-build ccache | |
if: contains( matrix.os, 'ubuntu') | |
- name: Install dependencies on macOS | |
run: | | |
brew update | |
brew install ninja ccache libomp cmake llvm | |
brew install coreutils || true | |
if: contains( matrix.os, 'macos') | |
- uses: actions/cache@v4 | |
env: | |
cache-name: cache-artifacts | |
with: | |
path: ~/.ccache | |
key: ${{ runner.os }}-deploy-${{ env.cache-name }} | |
restore-keys: | | |
${{ runner.os }}-deploy- | |
${{ runner.os }}- | |
- name: Build (Linux) | |
if: contains( matrix.os, 'ubuntu') | |
shell: bash | |
run: | | |
ccache --max-size 2G | |
./build_libtensor.py -v -d ${{runner.workspace}}/build --install ${{runner.workspace}}/install --type Release --features libxm | |
- name: Build (macOS) | |
if: contains( matrix.os, 'macos') | |
shell: bash | |
run: | | |
ccache --max-size 2G | |
CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ ./build_libtensor.py -v -d ${{runner.workspace}}/build --install ${{runner.workspace}}/install --type Release --features libxm | |
- name: Test | |
working-directory: ${{runner.workspace}}/build | |
shell: bash | |
run: ctest --output-on-failure -E ewmult2 | |
- name: Bundle tarball | |
shell: bash | |
run: | | |
python -m pip install --user -U setuptools | |
./scripts/pack_release.py ${{runner.workspace}}/install | |
- name: Upload tarball as artefact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libtensorlight-${{ matrix.os }} | |
path: libtensorlight-*.tar.gz | |
release: | |
if: startsWith(github.ref, 'refs/tags') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Glob asset paths | |
id: asset_paths | |
run: | | |
LINUX_PATH=$(ls artifacts/*/*.tar.gz | grep -i linux | head -n 1) | |
LINUX_NAME=$(basename "$LINUX_PATH") | |
MACOS_PATH=$(ls artifacts/*/*.tar.gz | grep -i macos | head -n 1) | |
MACOS_NAME=$(basename "$MACOS_PATH") | |
RELEASE_NAME=v$(echo "$LINUX_NAME" | cut -d- -f2) | |
echo "::set-output name=linux_path::$LINUX_PATH" | |
echo "::set-output name=macos_path::$MACOS_PATH" | |
echo "::set-output name=linux_name::$LINUX_NAME" | |
echo "::set-output name=macos_name::$MACOS_NAME" | |
echo "::set-output name=release_name::$RELEASE_NAME" | |
- uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ steps.asset_paths.outputs.release_name }} | |
draft: true | |
prerelease: false | |
- uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.asset_paths.outputs.linux_path }} | |
asset_name: ${{ steps.asset_paths.outputs.linux_name }} | |
asset_content_type: application/x-gtar | |
- uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.asset_paths.outputs.macos_path }} | |
asset_name: ${{ steps.asset_paths.outputs.macos_name }} | |
asset_content_type: application/x-gtar |