-
Notifications
You must be signed in to change notification settings - Fork 4
173 lines (160 loc) · 5 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# GitHub Workflows file
name: main
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version `x.y.z` (without leading `v`)'
type: string
required: true
jobs:
test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- linux
- windows
include:
- build: linux
os: ubuntu-20.04
config: gnu
- build: windows
os: windows-2019
config: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ runner.os }}-bazel-test-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ runner.os }}-bazel-test-
- name: Run bazel test
run: bazel test --config=${{ matrix.config }} --config=ci --disk_cache=~/.cache/bazel_build_cache //...
- name: Cache cleanup
run: ./tools/disk-cache-collect-garbage ~/.cache/bazel_build_cache
buildpkg:
name: Build Release Asset
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
build:
- focal
- jammy
- noble
- macos-universal
- windows
include:
- build: focal
os: ubuntu-20.04
config: gnu
pkgfile: bazel-compile-commands-${{ github.event.inputs.version || 0 }}-focal_amd64.deb
- build: jammy
os: ubuntu-22.04
config: gnu
pkgfile: bazel-compile-commands-${{ github.event.inputs.version || 0 }}-jammy_amd64.deb
- build: noble
os: ubuntu-24.04
config: gnu
pkgfile: bazel-compile-commands-${{ github.event.inputs.version || 0 }}-noble_amd64.deb
- build: macos-universal
os: macos-latest
config: gnu
pkgfile: bazel-compile-commands-${{ github.event.inputs.version || 0 }}-macos_universal.zip
- build: windows
os: windows-2019
config: cl
pkgfile: bazel-compile-commands-${{ github.event.inputs.version || 0 }}-windows_amd64.zip
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ matrix.os }}-bazel-buildpkg-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ matrix.os }}-bazel-buildpkg-
- name: Build Release Package
run: >
bazel run
--config=${{ matrix.config }}
--config=ci --config=release
--//:version=${{ github.event.inputs.version || 0 }}
--disk_cache=~/.cache/bazel_build_cache
//:copy -- ${{ matrix.pkgfile }}
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: pkg-bazel-${{ matrix.build }}
path: ${{ matrix.pkgfile }}
- name: Cache cleanup
run: ./tools/disk-cache-collect-garbage ~/.cache/bazel_build_cache
self_test:
name: Self test
runs-on: ubuntu-latest
needs: buildpkg
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run bazel to generate worktree
run: bazel build --config=gnu --config=ci //...
- name: Download pkg artifact
uses: actions/download-artifact@v4
with:
pattern: pkg-bazel-linux
- name: Install
run: |
sudo dpkg --install pkg-bazel-linux/bazel-compile-commands_*.deb
- name: Create compile-commands.json
run: |
/usr/bin/bazel-compile-commands -v -a --config=gnu --replace=-fno-canonical-system-headers= //...
- name: Run clang-tidy
run: |
clang-tidy -p "$(pwd)" $(find . -type f -name '*.cpp')
mkrelease:
name: Create Release
runs-on: ubuntu-latest
needs: buildpkg
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download pkg artifact
uses: actions/download-artifact@v4
with:
pattern: pkg-*
merge-multiple: true
- name: Create Release
run: |
gh release create v${{ github.event.inputs.version }} --generate-notes *.deb *.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
format_check:
name: Style check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install LLVM
uses: KyleMayes/install-llvm-action@v1.6.1
with:
version: "15.0.6"
- name: clang-format --version
run: clang-format --version
- name: Style check
run: ./tools/clang-format --dry-run -Werror