forked from carbon-language/carbon-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (117 loc) · 4.47 KB
/
tests.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
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: test
on:
push:
branches: [trunk]
paths:
# Conservatively run the tests. However, skip them if the only paths in
# the pull request match files that we know don't impact the build.
- '**'
- '!**/*.md'
- '!LICENSE'
- '!CODEOWNERS'
- '!.git*'
pull_request_target:
paths:
# Conservatively run the tests. However, skip them if the only paths in
# the pull request match files that we know don't impact the build.
- '**'
- '!**/*.md'
- '!LICENSE'
- '!CODEOWNERS'
- '!.git*'
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
build_mode: [fastbuild, opt]
runs-on: ${{ matrix.os }}
steps:
# Checkout the pull request head or the branch.
- name: Checkout pull request
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout branch
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v3
# Setup Python and related tools.
- uses: actions/setup-python@v4
with:
# Match the min version listed in docs/project/contribution_tools.md
python-version: '3.9'
# On macOS we need Go and to use it to install Bazelisk.
- uses: actions/setup-go@v3
if: matrix.os == 'macos-latest'
- name: Install bazelisk
if: matrix.os == 'macos-latest'
run: |
go get github.com/bazelbuild/bazelisk
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
# Setup to the latest LLVM and Clang release.
#
# Ideally we would use the pre-installed versions in the image, but the
# debian packages for LLVM-12 are broken due to several bugs:
# https://bugs.llvm.org/show_bug.cgi?id=43604
# https://bugs.llvm.org/show_bug.cgi?id=46321
#
# For now, we rely on Homebrew to manage installing a correctly built
# toolchain. We also take some care to be as resilient as possible to
# issues fetching and installing the toolchain.
- name: Setup LLVM and Clang
run: |
brew update
brew install --force-bottle --only-dependencies llvm
brew install --force-bottle --force --verbose llvm
brew info llvm
brew config
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
# Print the various tool paths and versions to help in debugging.
- name: Print tool debugging info
run: |
echo $PATH
which bazelisk
bazelisk --version
which python
python --version
which clang
clang --version
which clang++
clang++ --version
# Extract our access key for our build cache.
- name: Extract access key
env:
GCP_BUILDS_SERVICE_ACCOUNT: ${{ secrets.GCP_BUILDS_SERVICE_ACCOUNT }}
run: |
echo "$GCP_BUILDS_SERVICE_ACCOUNT" \
| base64 -d > $HOME/gcp-builds-service-account.json
# Add our bazel configuration and print basic info to ease debugging.
- name: Configure Bazel and print info
run: |
cat >user.bazelrc <<EOF
# Enable remote cache for our CI.
build --remote_cache=https://storage.googleapis.com/carbon-builds-github-${{ matrix.os }}
build --google_credentials=$HOME/gcp-builds-service-account.json
# General build options.
build --verbose_failures
test --test_output=errors
EOF
bazelisk info
# Build all targets first to isolate build failures.
- name: Build (${{ matrix.build_mode }})
env:
# 'libtool_check_unique failed to generate' workaround.
# https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
run: bazelisk build -c ${{ matrix.build_mode }} //...:all
# Run all test targets.
- name: Test (${{ matrix.build_mode }})
env:
# 'libtool_check_unique failed to generate' workaround.
# https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
run: bazelisk test -c ${{ matrix.build_mode }} //...:all