Skip to content

Commit 2fa06ca

Browse files
authored
Add Docker image, add CI checks, fix CI issues. (#2)
- Add a Docker image for use by Travis. - Add packages.sh dependencies script under build_support/. - Add CI checks on Mac: make, check-tests. - Add CI checks on Linux: make, check-format, check-lint, check-clang-tidy, check-tests. - Bump minimum CMake version and avoid using project()'s HOMEPAGE_URL. - Convert missing dependency messages from errors into warnings.
1 parent 10b9fde commit 2fa06ca

File tree

7 files changed

+139
-12
lines changed

7 files changed

+139
-12
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Don't send any build context to Docker.
2+
**

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ language: cpp
33
matrix:
44
fast_finish: true
55
include:
6+
- os: osx
7+
osx_image: xcode10.1
8+
compiler: clang
9+
env:
10+
- NAME="macos-10.14/AppleClang-1001.0.46.4 (Debug/packages.sh)" CMAKE_BUILD_TYPE=debug
11+
install:
12+
- echo 'y' | ./build_support/packages.sh
13+
- export LLVM_DIR=/usr/local/Cellar/llvm/8.0.1
614
- os: linux
715
dist: trusty
816
env:
@@ -11,6 +19,7 @@ matrix:
1119
- docker pull ubuntu:18.04
1220
- docker run -itd --name build ubuntu:18.04
1321
- docker cp . build:/repo
22+
- docker exec build /bin/sh -c "echo 'y' | /repo/build_support/packages.sh"
1423
- os: linux
1524
dist: trusty
1625
env:
@@ -32,11 +41,15 @@ before_script:
3241
- if [[ "$DOCKER" = true ]]; then
3342
docker exec build /bin/sh -c "mkdir -p /repo/build" &&
3443
docker exec -e CMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" build /bin/sh -c "cd /repo/build && cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE .." &&
44+
docker exec build /bin/sh -c "cd /repo/build && make check-format" &&
45+
docker exec build /bin/sh -c "cd /repo/build && make check-lint" &&
46+
docker exec build /bin/sh -c "cd /repo/build && make check-clang-tidy" &&
3547
docker exec build /bin/sh -c "cd /repo/build && make check-tests";
3648
else
3749
mkdir build &&
3850
cd build &&
3951
cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE .. &&
52+
make check-lint &&
4053
make check-tests;
4154
fi
4255

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.10)
22
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For clang-tidy.
33

44
set(CMAKE_CXX_STANDARD 17) # Compile as C++17
55
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Require C++17 support
66

77
project(BusTub
88
VERSION 2019.1
9-
DESCRIPTION "The BusTub Relational Database Management System (Educational)."
10-
HOMEPAGE_URL "https://github.com/cmu-db/bustub"
9+
DESCRIPTION "The BusTub Relational Database Management System (Educational) @ https://github.com/cmu-db/bustub"
1110
LANGUAGES C CXX
1211
)
1312

1413
# Expected directory structure.
1514
set(BUSTUB_BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build_support")
16-
set(BUSTUB_CLANG_SEARCH_PATH "/usr/local/bin" "/usr/bin" "/usr/local/opt/llvm/bin" "/usr/local/opt/llvm@8/bin")
15+
set(BUSTUB_CLANG_SEARCH_PATH "/usr/local/bin" "/usr/bin" "/usr/local/opt/llvm/bin" "/usr/local/opt/llvm@8/bin"
16+
"/usr/local/Cellar/llvm/8.0.1/bin")
1717

1818
######################################################################################################################
1919
# DEPENDENCIES
@@ -27,7 +27,7 @@ find_program(CLANG_FORMAT_BIN
2727
NAMES clang-format clang-format-8
2828
HINTS "${BUSTUB_CLANG_SEARCH_PATH}")
2929
if ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
30-
message(FATAL_ERROR "BusTub/main couldn't find clang-format.")
30+
message(WARNING "BusTub/main couldn't find clang-format.")
3131
else()
3232
message(STATUS "BusTub/main found clang-format at ${CLANG_FORMAT_BIN}")
3333
endif()
@@ -37,7 +37,7 @@ find_program(CLANG_TIDY_BIN
3737
NAMES clang-tidy clang-tidy-8
3838
HINTS "${BUSTUB_CLANG_SEARCH_PATH}")
3939
if ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
40-
message(FATAL_ERROR "BusTub/main couldn't find clang-tidy.")
40+
message(WARNING "BusTub/main couldn't find clang-tidy.")
4141
else()
4242
# Output compile_commands.json
4343
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
@@ -49,7 +49,7 @@ find_program(CPPLINT_BIN
4949
NAMES cpplint cpplint.py
5050
HINTS "${BUSTUB_BUILD_SUPPORT_DIR}")
5151
if ("${CPPLINT_BIN}" STREQUAL "CPPLINT_BIN-NOTFOUND")
52-
message(FATAL_ERROR "BusTub/main ouldn't find cpplint.")
52+
message(WARNING "BusTub/main couldn't find cpplint.")
5353
else()
5454
message(STATUS "BusTub/main found cpplint at ${CPPLINT_BIN}")
5555
endif()

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ubuntu:18.04
2+
CMD bash
3+
4+
# Install Ubuntu packages.
5+
# Please add packages in alphabetical order.
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
RUN apt-get -y update && \
8+
apt-get -y install \
9+
build-essential \
10+
clang-8 \
11+
clang-format-8 \
12+
clang-tidy-8 \
13+
cmake \
14+
doxygen \
15+
git \
16+
g++-7 \
17+
pkg-config \
18+
valgrind \
19+
zlib1g-dev

build_support/packages.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
## =================================================================
4+
## BUSTUB PACKAGE INSTALLATION
5+
##
6+
## This script will install all the packages that are needed to
7+
## build and run the DBMS.
8+
##
9+
## Supported environments:
10+
## * Ubuntu 18.04
11+
## * macOS
12+
## =================================================================
13+
14+
main() {
15+
set -o errexit
16+
17+
echo "PACKAGES WILL BE INSTALLED. THIS MAY BREAK YOUR EXISTING TOOLCHAIN."
18+
echo "YOU ACCEPT ALL RESPONSIBILITY BY PROCEEDING."
19+
read -p "Proceed? [Y/n] : " yn
20+
case $yn in
21+
Y|y) install;;
22+
*) ;;
23+
esac
24+
25+
echo "Script complete."
26+
}
27+
28+
install() {
29+
set -x
30+
UNAME=$(uname | tr "[:lower:]" "[:upper:]" )
31+
32+
case $UNAME in
33+
DARWIN) install_mac ;;
34+
35+
LINUX)
36+
version=$(cat /etc/os-release | grep VERSION_ID | cut -d '"' -f 2)
37+
case $version in
38+
18.04) install_linux ;;
39+
*) give_up ;;
40+
esac
41+
;;
42+
43+
*) give_up ;;
44+
esac
45+
}
46+
47+
give_up() {
48+
set +x
49+
echo "Unsupported distribution '$UNAME'"
50+
echo "Please contact our support team for additional help."
51+
echo "Be sure to include the contents of this message."
52+
echo "Platform: $(uname -a)"
53+
echo
54+
echo "https://github.com/cmu-db/bustub/issues"
55+
echo
56+
exit 1
57+
}
58+
59+
install_mac() {
60+
# Install Homebrew.
61+
if test ! $(which brew); then
62+
echo "Installing Homebrew (https://brew.sh/)"
63+
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
64+
fi
65+
# Update Homebrew.
66+
brew update
67+
# Install packages.
68+
brew ls --versions cmake || brew install cmake
69+
brew ls --versions coreutils || brew install coreutils
70+
brew ls --versions doxygen || brew install doxygen
71+
brew ls --versions git || brew install git
72+
(brew ls --versions llvm | grep 8) || brew install llvm@8
73+
}
74+
75+
install_linux() {
76+
# Update apt-get.
77+
apt-get -y update
78+
# Install packages.
79+
apt-get -y install \
80+
build-essential \
81+
clang-8 \
82+
clang-format-8 \
83+
clang-tidy-8 \
84+
cmake \
85+
doxygen \
86+
git \
87+
g++-7 \
88+
pkg-config \
89+
valgrind \
90+
zlib1g-dev
91+
}
92+
93+
main "$@"

src/include/common/config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ extern std::chrono::duration<int64_t> LOG_TIMEOUT;
3636
#define BUCKET_SIZE 50 // size of extendible hash bucket
3737
#define BUFFER_POOL_SIZE 10 // size of buffer pool
3838

39-
using frame_id_t = int32_t; // frame id type
40-
using page_id_t = int32_t; // page id type
41-
using txn_id_t = int32_t; // transaction id type
42-
using lsn_t = int32_t; // log sequence number type
39+
using frame_id_t = int32_t; // frame id type
40+
using page_id_t = int32_t; // page id type
41+
using txn_id_t = int32_t; // transaction id type
42+
using lsn_t = int32_t; // log sequence number type
4343
using oid_t = uint16_t;
4444

4545
} // namespace bustub

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ file(GLOB BUSTUB_TEST_SOURCES "${PROJECT_SOURCE_DIR}/test/*/*test.cpp")
77
# valgrind
88
find_program(VALGRIND_BIN valgrind)
99
if ("${VALGRIND_BIN}" STREQUAL "VALGRIND_BIN-NOTFOUND")
10-
message(FATAL_ERROR "BusTub/test couldn't find valgrind.")
10+
message(WARNING "BusTub/test couldn't find valgrind.")
1111
else()
1212
message(STATUS "BusTub/test found valgrind at ${VALGRIND_BIN}")
1313
endif()

0 commit comments

Comments
 (0)