-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (55 loc) · 1.69 KB
/
ci.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
name: CI
on:
push:
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: 🚀 Checkout
uses: actions/checkout@v4
- name: 🌿 Setup Bazel
uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
bazelrc: |
build --color=yes
build --show_timestamps
- name: 🗒️ Track Current Files
run: touch /tmp/pre_fmt
- name: 🧹 Format Repository
run: bazel run //:format
- name: 👀 Detect Diff
run: |
set +x
formatted_files=$(find ./config ./src ./tools -newer /tmp/pre_fmt)
num_formatted_files=$(find ./config ./src ./tools -newer /tmp/pre_fmt | wc -l)
if [ "$num_formatted_files" -gt "0" ]; then
echo "❌🔥 Bad code detected! The following files would be reformatted:"
echo "$formatted_files"
exit 1
fi
test:
runs-on: ubuntu-latest
steps:
- name: 🚀 Checkout
uses: actions/checkout@v4
- name: 🌿 Setup Bazel
uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
bazelrc: |
build --color=yes
build --show_timestamps
- name: 🧪 Run Tests
run: bazel test //src/...