Skip to content

[wip] add eudsl-tblgen #12

[wip] add eudsl-tblgen

[wip] add eudsl-tblgen #12

Workflow file for this run

name: "Test"
on:
workflow_dispatch:
inputs:
force_debug_with_tmate:
type: boolean
description: 'Run the build with tmate session'
required: false
default: false
debug_with_tmate:
type: boolean
description: 'Run the build with a tmate session ONLY in case of failure'
required: false
default: false
pull_request:
merge_group:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
test-eudsl-tblgen:
strategy:
fail-fast: false
matrix:
include:
- name: "manylinux_x86_64"
runs-on: "ubuntu-22.04"
- name: "windows_x86_64"
runs-on: "windows-2019"
- name: "macos_arm64"
runs-on: "macos-14"
- name: "macos_x86_64"
runs-on: "macos-13"
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.name }}
defaults:
run:
shell: bash
permissions:
id-token: write
contents: write
env:
# either the PR number or `branch-N` where N always increments
CACHE_KEY: test_${{ matrix.name }}_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
CACHE_DIR: ${{ github.workspace }}/.container-cache
steps:
- name: "Set unified TZ"
uses: szenius/[email protected]
with:
# this is an arbitrary choice
timezoneLinux: "Asia/Singapore"
timezoneMacos: "Asia/Singapore"
timezoneWindows: "Singapore Standard Time"
- name: "Restore cache"
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
key: ${{ env.CACHE_KEY }}
restore-keys: test_${{ matrix.name }}_clang
- name: "Check out repository"
uses: actions/[email protected]
with:
submodules: false
- name: "Install OS deps"
run: |
if [[ "${{ matrix.runs-on }}" == macos* ]]; then
brew install ccache ninja curl
fi
- name: "Install Python"
uses: actions/setup-python@v4
if: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}
with:
python-version: '3.12'
- name: "Setup compiler/toolchain"
uses: aminya/setup-cpp@v1
if: ${{ startsWith(matrix.runs-on, 'ubuntu') || startsWith(matrix.runs-on, 'windows') }}
with:
compiler: llvm-18
cmake: true
ninja: true
ccache: true
vcvarsall: ${{ startsWith(matrix.runs-on, 'windows') }}
- name: "Set CC/CXX"
run: |
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then
echo "CC=/github/home/llvm/bin/clang" >> $GITHUB_ENV
echo "CXX=/github/home/llvm/bin/clang++" >> $GITHUB_ENV
elif [[ "${{ matrix.runs-on }}" == windows* ]]; then
echo "CC=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
echo "CXX=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
elif [[ "${{ matrix.runs-on }}" == macos* ]]; then
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
fi
- name: "Python deps"
run: |
python3_command=""
if (command -v python3.12 &> /dev/null); then
python3_command="python3.12"
elif (command -v python3 &> /dev/null); then
python3_command="python3"
elif (command -v python &> /dev/null); then
python3_command="python"
fi
echo "Python3_EXECUTABLE=$(which $python3_command)" >> $GITHUB_ENV
- name: "Download MLIR"
env:
GH_TOKEN: ${{ github.token }}
run: |
export RELEASE_PREFIX="mlir_${{ matrix.name }}"
RELEASE_URL=$(gh release view latest --json assets -q '.assets |= sort_by(.createdAt) | .assets | map(select(.name | contains(env.RELEASE_PREFIX))) | .[-1] | .url')
curl -sLO $RELEASE_URL
tar xf $RELEASE_PREFIX*.tar.gz
- name: "Build eudsl-tblgen"
id: build
run: |
export CCACHE_DIR="${{ env.CACHE_DIR }}/ccache"
export CCACHE_COMPILERCHECK="string:$($CC --version)"
export CCACHE_MAXSIZE=700M
export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros
export CCACHE_CPP2=true
export CCACHE_UMASK=002
export CMAKE_C_COMPILER_LAUNCHER=ccache
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld"
export CMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld"
export CMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld"
export Python3_EXECUTABLE="$Python3_EXECUTABLE"
export CMAKE_PREFIX_PATH="$PWD/llvm-install"
export EUDSL_SRC_DIR="$PWD/projects/eudsl-tblgen"
export EUDSL_BUILD_DIR="$PWD/eudsl-build"
export EUDSL_INSTALL_DIR="$PWD/eudsl-install"
ccache -z
cmake -S "$EUDSL_SRC_DIR" \
-B "$EUDSL_BUILD_DIR" \
"-DCMAKE_PREFIX_PATH=$PWD/__w/eudsl/eudsl/llvm-install/llvm-install" \
"-DCMAKE_INSTALL_PREFIX=$EUDSL_INSTALL_DIR"
cmake --build "$EUDSL_BUILD_DIR" --target install
ccache -s
echo "*********************** SMOKE TEST *********************************"
"$EUDSL_INSTALL_DIR/bin/eudsl-tblgen" --version
echo "*********************** SMOKE TEST *********************************"
SHA_SHORT=$(git rev-parse --short HEAD)
tar -czf eudsl_tblgen_${{ matrix.name }}_$SHA_SHORT.tar.gz -C "$EUDSL_INSTALL_DIR" bin
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: eudsl_${{ matrix.name }}_artifact
path: eudsl-install/bin
if-no-files-found: warn
- name: Release current commit
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
uses: ncipollo/[email protected]
with:
artifacts: "*.tar.gz"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "latest"
name: "latest"
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true
- name: "Save cache"
uses: actions/cache/save@v3
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
with:
path: ${{ env.CACHE_DIR }}
key: ${{ env.CACHE_KEY }}
- name: "Setup tmate session"
if: ${{ (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate }}
uses: mxschmitt/[email protected]
with:
limit-access-to-actor: true
install-dependencies: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}