forked from typesense/typesense
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (83 loc) · 3.21 KB
/
tests.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
name: tests
#on: workflow_dispatch
on: [push, pull_request]
# Cancel previous running if a new push is made
# Source: https://stackoverflow.com/a/72408109/123545
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y g++-10 make git zlib1g-dev m4
# Define the compiler
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 30
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
- name: Setup lld
run: |
sudo apt-get install -y lld
- name: Set up Bazel
uses: bazelbuild/setup-bazelisk@v2
- name: Download bazel cache
uses: jasonbosco/action-download-artifact@709b71d3729e8980f52a5a2a9ec04261060945c1
with:
name: bazel-cache
search_artifacts: true
workflow_conclusion: ""
if_no_artifact_found: warn
skip_unpack: true
branch: ${{ github.base_ref || github.head_ref || github.ref_name }}
- name: Uncompress bazel cache
run: |
if [ -f "bazel-cache.zip" ]; then
unzip bazel-cache.zip
mkdir -p ~/.cache/bazel
tar_file="bazel-cache.tar.gz" && \
[ -f "$tar_file" ] && \
tar -xzvf "$tar_file" -C ~/.cache/bazel && \
rm bazel-cache.tar.gz
else
echo "bazel-cache.zip does not exist. Continuing..."
fi
exit 0
- name: Build protobuf deps
run: |
bazel build @com_google_protobuf//:protobuf_headers
bazel build @com_google_protobuf//:protobuf_lite
bazel build @com_google_protobuf//:protobuf
bazel build @com_google_protobuf//:protoc
- name: Build Typesense
run: bazel build //:typesense-server
- name: Run tests
run: bazel test --cache_test_results=no --test_output=all //:typesense-test
- name: Compress bazel cache
if: always()
run: |
tar -czvf bazel-cache.tar.gz -C ~/.cache/bazel .
- name: Save bazel cache
uses: actions/upload-artifact@v3
if: always()
with:
name: bazel-cache
path: bazel-cache.tar.gz
if-no-files-found: warn
retention-days: 10
# Source: https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032
- name: Set BAZEL_BIN_FULL_PATH
run: echo "BAZEL_BIN_FULL_PATH=$(readlink -f bazel-bin)" >> $GITHUB_ENV
- name: Save build artifacts
uses: actions/upload-artifact@v3
with:
name: typesense-server
path: ${{ env.BAZEL_BIN_FULL_PATH }}/typesense-server