Skip to content

Commit 719915b

Browse files
Initial commit
fbshipit-source-id: 7c98b4413a035219f8a2949626de33424f6182e5
0 parents  commit 719915b

File tree

1,225 files changed

+659196
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,225 files changed

+659196
-0
lines changed

.circleci/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
CircleCi integration is controlled by the `./circleci/config.yml` file. Our
2+
config currently contains two workflows. One is triggered on every pull request update.
3+
The other workflow runs nightly to verify our compatibility with prestodb internal protocol.
4+
5+
The PR workflow is named `dist-compile` and has 4 jobs, 2 to build and run unit tests on linux and macos
6+
and 2 to check code formatting and license headers:
7+
* linux-build
8+
* macos-build
9+
* format-check
10+
* header-check
11+
12+
## Running locally
13+
14+
The linux container based jobs can be run locally using the `circleci` cli:
15+
16+
```
17+
circleci local execute --job JOB_NAME
18+
```
19+
20+
For example to run unit tests use:
21+
22+
```
23+
circleci local execute --job linux-build
24+
```
25+
26+
A Nightly build with prestodb/master sync checks that the presto_protocol library
27+
remains in sync with Presto Java.
28+
29+
Run the nightly sync job locally:
30+
```
31+
circleci local execute --job presto-sync
32+
```
33+
34+
## Install CircleCi cli
35+
```
36+
curl -fLSs https://circle.ci/cli | bash
37+
```
38+
39+
To use containers Docker must be installed. Here are instructions to [Install
40+
Docker on macos](https://docs.docker.com/docker-for-mac/install/). Docker deamon
41+
must be running before issuing the `circleci` commands.
42+
43+
### Macos testing
44+
45+
Macos testing is done by using the CircleCi macos executor and installing
46+
dependencies each time the job is run. This executor cannot be run locally.
47+
The script `scripts/setup-macos.sh` contains commands that are run as part of
48+
this job to install these dependencies.
49+
50+
### Linux testing
51+
52+
Linux testing uses a Docker container. The container build depends on the Velox CircleCi container. Check
53+
f4d/.circleci/config.yml to see that the base container in circleci-container.dockfile is using the latest.
54+
The container build uses Docker and should be run on your macos or linux laptop with Docker installed and
55+
running.
56+
57+
#### Build the base container:
58+
59+
* In an up-to-date clone of f4d (maybe you have one?)
60+
61+
```
62+
git clone [email protected]:facebookexternal/f4d.git
63+
cd f4d
64+
make base-container
65+
```
66+
* Wait - This step takes rather a long time. It is building clang-format v8 to be compatible with fbcode
67+
* When the base container is finished the new container name will be printed on the console.
68+
* Push the container to DockerHub
69+
```
70+
docker push prestocpp/base-container:$USER-YYYYMMDD
71+
```
72+
* After the push, update `scripts/velox-container.dockfile` with the newly build base container name
73+
74+
#### Build the dependencies container
75+
76+
* If you have a new base-container update scripts/velox-container.dockfile to refer to it
77+
* Build the velox container
78+
```
79+
make velox-container.dockfile
80+
```
81+
* Wait - This takes a few minutes, but not nearly as long as the base container.
82+
* When the velox container is finished the new container name will be printed on the console.
83+
* Push the container to DockerHub
84+
```
85+
docker push prestocpp/velox-container:$USER-YYYYMMDD
86+
```
87+
* Update `.circleci/config.yml` with the newly built circleci container name.
88+
There are two places in the config.yml file that refer to the container, update
89+
both.

.circleci/config.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
version: 2.1
13+
workflows:
14+
version: 2
15+
dist-compile:
16+
jobs:
17+
- linux-build
18+
- macos-build
19+
- format-check
20+
- header-check
21+
22+
executors:
23+
build:
24+
docker:
25+
- image : prestocpp/velox-circleci:mikesh-20210610
26+
resource_class: xlarge
27+
environment:
28+
CC: /opt/rh/gcc-toolset-9/root/bin/gcc
29+
CXX: /opt/rh/gcc-toolset-9/root/bin/g++
30+
check:
31+
docker:
32+
- image : prestocpp/velox-check:mikesh-20210609
33+
34+
jobs:
35+
macos-build:
36+
macos:
37+
xcode: "11.7.0"
38+
steps:
39+
- checkout
40+
- restore_cache:
41+
name: "Restore Dependency Cache"
42+
key: velox-circleci-macos-deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "scripts/setup-macos.sh" }}
43+
- run:
44+
name: "Install dependencies"
45+
command: |
46+
set -xu
47+
if [[ ! -e ~/deps ]]; then
48+
mkdir ~/deps ~/deps-src
49+
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C ~/deps
50+
PATH=~/deps/bin:${PATH} DEPENDENCY_DIR=~/deps-src INSTALL_PREFIX=~/deps PROMPT_ALWAYS_RESPOND=n ./scripts/setup-macos.sh
51+
rm -rf ~/deps/.git ~/deps/Library/Taps/ # Reduce cache size by 70%.
52+
fi
53+
- save_cache:
54+
name: "Save Dependency Cache"
55+
key: velox-circleci-macos-deps-{{ checksum ".circleci/config.yml" }}-{{ checksum "scripts/setup-macos.sh" }}
56+
paths:
57+
- ~/deps
58+
- run:
59+
name: "Calculate merge-base for CCache"
60+
command: git merge-base origin/master HEAD > merge-base
61+
- restore_cache:
62+
name: "Restore CCache cache"
63+
keys:
64+
- velox-ccache-{{ arch }}-{{ checksum "merge-base" }}
65+
- run:
66+
name: "Build on MacOS"
67+
command: |
68+
export PATH=~/deps/bin:${PATH}
69+
mkdir -p .ccache
70+
export CCACHE_DIR=$(pwd)/.ccache
71+
ccache -sz -M 5Gi
72+
cmake -B _build/debug -GNinja -DTREAT_WARNINGS_AS_ERRORS=1 -DENABLE_ALL_WARNINGS=1 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=~/deps -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
73+
ninja -C _build/debug
74+
ccache -s
75+
no_output_timeout: 1h
76+
- save_cache:
77+
name: "Save CCache cache"
78+
key: velox-ccache-{{ arch }}-{{ checksum "merge-base" }}
79+
paths:
80+
- .ccache/
81+
82+
linux-build:
83+
executor: build
84+
steps:
85+
- checkout
86+
- run:
87+
name: "Calculate merge-base for CCache"
88+
command: git merge-base origin/master HEAD > merge-base
89+
- restore_cache:
90+
name: "Restore CCache cache"
91+
keys:
92+
- velox-ccache-{{ arch }}-{{ checksum "merge-base" }}
93+
- run:
94+
name: Build
95+
command: |
96+
mkdir -p .ccache
97+
export CCACHE_DIR=$(realpath .ccache)
98+
ccache -sz -M 5Gi
99+
source /opt/rh/gcc-toolset-9/enable
100+
make debug NUM_THREADS=8 MAX_HIGH_MEM_JOBS=3 MAX_LINK_JOBS=4
101+
ccache -s
102+
no_output_timeout: 1h
103+
- store_artifacts:
104+
path: '_build/debug/.ninja_log'
105+
- run:
106+
name: Run Unit Tests
107+
command: |
108+
make unittest NUM_THREADS=8
109+
no_output_timeout: 1h
110+
- save_cache:
111+
name: "Save CCache cache"
112+
key: velox-ccache-{{ arch }}-{{ checksum "merge-base" }}
113+
paths:
114+
- .ccache/
115+
116+
format-check:
117+
executor: check
118+
steps:
119+
- checkout
120+
- run:
121+
name: Check formatting
122+
command: 'make format-check'
123+
124+
header-check:
125+
executor: check
126+
steps:
127+
- checkout
128+
- run:
129+
name: Check license headers
130+
command: 'make header-check'

.clang-format

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 80
39+
CommentPragmas: '^ IWYU pragma:'
40+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
41+
ConstructorInitializerIndentWidth: 4
42+
ContinuationIndentWidth: 4
43+
Cpp11BracedListStyle: true
44+
DerivePointerAlignment: false
45+
DisableFormat: false
46+
ForEachMacros: [ FOR_EACH, FOR_EACH_R, FOR_EACH_RANGE, ]
47+
IncludeCategories:
48+
- Regex: '^<.*\.h(pp)?>'
49+
Priority: 1
50+
- Regex: '^<.*'
51+
Priority: 2
52+
- Regex: '.*'
53+
Priority: 3
54+
IndentCaseLabels: true
55+
IndentWidth: 2
56+
IndentWrappedFunctionNames: false
57+
KeepEmptyLinesAtTheStartOfBlocks: false
58+
MacroBlockBegin: ''
59+
MacroBlockEnd: ''
60+
MaxEmptyLinesToKeep: 1
61+
NamespaceIndentation: None
62+
ObjCBlockIndentWidth: 2
63+
ObjCSpaceAfterProperty: false
64+
ObjCSpaceBeforeProtocolList: false
65+
PenaltyBreakBeforeFirstCallParameter: 1
66+
PenaltyBreakComment: 300
67+
PenaltyBreakFirstLessLess: 120
68+
PenaltyBreakString: 1000
69+
PenaltyExcessCharacter: 1000000
70+
PenaltyReturnTypeOnItsOwnLine: 200
71+
PointerAlignment: Left
72+
ReflowComments: true
73+
SortIncludes: true
74+
SpaceAfterCStyleCast: false
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 1
79+
SpacesInAngles: false
80+
SpacesInContainerLiterals: true
81+
SpacesInCStyleCastParentheses: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Cpp11
85+
TabWidth: 8
86+
UseTab: Never
87+
...

0 commit comments

Comments
 (0)