-
Notifications
You must be signed in to change notification settings - Fork 141
134 lines (115 loc) · 4.75 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and Test
on:
pull_request:
push:
branches:
- "main"
- "actions"
permissions:
contents: read
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup LLVM (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 160
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 160
sudo update-alternatives --install /usr/bin/lli lli /usr/bin/lli-16 160
- name: Setup LLVM and GCC (MacOS)
if: ${{ runner.os == 'macOS' }}
run: |
brew install llvm@16
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
echo "CC=$(brew --prefix llvm@16)/bin/clang" >> $GITHUB_ENV
echo "CXX=$(brew --prefix llvm@16)/bin/clang++" >> $GITHUB_ENV
cd /usr/local/bin
ln -s gcc-11 gcc
- name: Update Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PyTest
run: |
python -m pip install --upgrade pip
pip install pytest pytest-xdist
- name: Build
run: |
mkdir build
cmake -S . -B build -DLLVM_INCLUDE_TESTS=On
cmake --build build
- name: Test
run: |
gcc --version
pytest -n 16
# The llvm-dev package doesn't exist for Windows, so we need to build LLVM ourselves.
build-windows:
runs-on: windows-latest
env:
SCCACHE_GHA_ENABLED: "true"
steps:
- name: Capture runner image version
shell: pwsh
run: Add-Content -Value "ImageVersion=$env:ImageVersion" -Path $env:GITHUB_ENV
- name: Checkout LLVM
id: checkout-llvm
uses: actions/checkout@master
with:
repository: llvm/llvm-project
ref: llvmorg-16.0.6
- name: Checkout
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/llvm/projects/llvm-cbe
- name: Update Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PyTest
run: |
python -m pip install --upgrade pip
pip install pytest pytest-xdist
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Build
shell: pwsh
run: |
$vsWhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$visualStudioInstallationPath = & $vsWhere -latest -property installationPath
Import-Module (Join-Path $visualStudioInstallationPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $visualStudioInstallationPath -DevCmdArguments '-arch=x64 -host_arch=x64'
cd ${{ github.workspace }}
if (!(Test-Path '${{ github.workspace }}\build\')) { mkdir '${{ github.workspace }}\build' }
# Delete the 'projects' directory to force llvm-cbe to be rebuilt.
if (Test-Path '${{ github.workspace }}\build\projects') { del '${{ github.workspace }}\build\projects' -Recurse -Force }
cmake -S llvm -B build -G Ninja -DLLVM_INCLUDE_TESTS=On -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build build
- name: Cache stats
shell: bash
run: ${SCCACHE_PATH} --show-stats
- name: Test
shell: pwsh
run: |
$vsWhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$visualStudioInstallationPath = & $vsWhere -latest -property installationPath
Import-Module (Join-Path $visualStudioInstallationPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $visualStudioInstallationPath -DevCmdArguments '-arch=x64 -host_arch=x64'
cd ${{ github.workspace }}
$env:PATH=(Join-Path $visualStudioInstallationPath 'VC\Tools\Llvm\x64\bin') + ";" + $env:Path + ";${{ github.workspace }}\build\bin"
$env:LLVMToolDir="${{ github.workspace }}\build\bin"
pytest -n 16