-
Notifications
You must be signed in to change notification settings - Fork 12
148 lines (143 loc) · 5.47 KB
/
main.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright 2023 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Gematria CI
# The pinned version of LLVM. Must be manually updated to match the
# `LLVM_COMMIT` variable defined in `WORKSPACE`.
# TODO(virajbshah): Find a better way to keep these two in sync without the
# need to update one manually every time the other is changed.
env:
LLVM_COMMIT: 29b92d07746fac26cd64c914bc9c5c3833974f6d
on:
push:
branches:
- main
repository_dispatch:
pull_request:
jobs:
check-python-formatting:
name: Python Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install pyink
run: pip3 install pyink==23.9.1
- name: Check python formatting
run: pyink --check --diff .
check-cpp-formatting:
name: C++ Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check c++ formatting
uses: jidicula/[email protected]
with:
clang-format-version: '18'
check-path: 'src'
check-bazel-formatting:
name: Bazel Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: thompsonja/[email protected]
with:
buildifier_version: v6.1.2
check-cmake-projects:
name: Check CMake-based projects
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hendrikmuhs/[email protected]
- uses: ConorMacBride/[email protected]
with:
apt: cmake ninja-build libpthreadpool-dev
- name: Get LLVM
run: |
git clone --depth 1 --no-checkout https://github.com/llvm/llvm-project.git /tmp/llvm-project
cd /tmp/llvm-project
git fetch --depth 1 origin $LLVM_COMMIT
git checkout $LLVM_COMMIT
- name: Set up TFLite
run: |
mkdir /tmp/tflite
cd /tmp/tflite
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CMAKE_C_COMPILER_LAUNCHER=ccache
curl https://raw.githubusercontent.com/google/ml-compiler-opt/main/buildbot/build_tflite.sh | bash
- name: cmake setup
run: |
mkdir /tmp/cmake-build
cd /tmp/cmake-build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD=Native \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-C /tmp/tflite/tflite.cmake \
/tmp/llvm-project/llvm \
-DLLVM_EXTERNAL_PROJECTS=gematria \
-DLLVM_EXTERNAL_GEMATRIA_SOURCE_DIR=${{ github.workspace }}
- name: build
run: |
cd /tmp/cmake-build
ninja llvm-granite check-llvm-tools-llvm-cm
check-bazel:
name: Run bazel build
runs-on: ubuntu-latest
env:
USE_BAZEL_VERSION: 6.4.0
strategy:
matrix:
build-config: [fastbuild, opt]
steps:
- uses: actions/checkout@v4
- name: Setup environment variables
run: echo "CURRENT_DAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup LLVM
# TODO(boomanaiden154): We should refactor the docker image so we can
# have a base image with just system dependencies that we can then run
# everything in here to keep things consistent with less hacks.
run: |
sudo apt-get autoremove gcc-12 g++-12 && \
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main\ndeb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" | sudo tee /etc/apt/sources.list && \
curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \
curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
sudo apt-get update && \
sudo apt-get install -y clang-19 lld-19 && \
sudo rm -f /usr/bin/clang && \
sudo rm -f /usr/bin/clang++ && \
sudo ln -s /usr/bin/clang-19 /usr/bin/clang && \
sudo ln -s /usr/bin/clang-19 /usr/bin/clang++
- name: Cache Bazel
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-bazel-${{ matrix.build-config }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}-${{ env.CURRENT_DAY }}
restore-keys: |
${{ runner.os }}-bazel-${{ matrix.build-config }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
${{ runner.os }}-bazel-${{ matrix.build-config }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install python deps
run: pip3 install -r requirements.txt
- name: Run build
run: bazel build -c ${{ matrix.build-config }} ...
- name: Run tests
run: bazel test -c ${{ matrix.build-config }} --test_tag_filters="-perf_counters" --test_output=errors ...