Skip to content

Commit

Permalink
Activate macos build in CircleCI (#241)
Browse files Browse the repository at this point in the history
* Activate macos build in CircleCI
  • Loading branch information
peterebden authored Oct 30, 2017
1 parent 1e74b55 commit 15d47b0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 17 deletions.
31 changes: 30 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
jobs:
build:
build-linux:
working_directory: ~/please
docker:
- image: thoughtmachine/please_ubuntu:latest
Expand All @@ -22,3 +22,32 @@ jobs:
mv plz-out/gen/package/*.deb plz-out/gen/package/*.tar.gz /tmp/artifacts
- store_artifacts:
path: /tmp/artifacts

build-darwin:
macos:
xcode: "9.0"
steps:
- checkout
- run:
name: Install deps
command: brew install go python3 pypy unittest-cpp nasm pkg-config
- run:
name: Bootstrap & Build
command: ./bootstrap.sh -p --exclude no_circleci --test_results_file plz-out/results/test_results.xml
- store_test_results:
path: plz-out/results/test_results.xml
- run:
name: Package
command: |
./plz-out/bin/src/please build -p //package:all --exclude asc --exclude deb &&
mkdir /tmp/artifacts &&
mv plz-out/gen/package/*.tar.gz /tmp/artifacts
- store_artifacts:
path: /tmp/artifacts

workflows:
version: 2
build-all:
jobs:
- build-linux
- build-darwin
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ rm -f ${DEST}/please ${DEST}/please_pex ${DEST}/junit_runner.jar ${DEST}/jarcat
cp -f plz-out/bin/src/please ${DEST}/please
chmod 0775 ${DEST}/please
ln -sf ${DEST}/please ${DEST}/plz
cp -f plz-out/bin/src/libplease_parser_*.so ${DEST}
chmod 0664 ${DEST}/libplease_parser_*.so
cp -f plz-out/bin/src/libplease_parser_* ${DEST}
chmod 0664 ${DEST}/libplease_parser_*
cp -f plz-out/bin/tools/please_pex/please_pex ${DEST}/please_pex
chmod 0775 ${DEST}/please_pex
cp -f plz-out/bin/tools/junit_runner/junit_runner.jar ${DEST}/junit_runner.jar
Expand Down
5 changes: 1 addition & 4 deletions src/parse/cffi/cffi_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ def main(defs_file, parser_file, verbose):
ldflags = ['-Wl,-rpath=./plz-out/gen/_remote/_pypy/bin']
if platform.python_implementation() == 'CPython' and platform.system() == 'Darwin':
version = platform.python_version_tuple()
ldflags = [
'-L/usr/local/Cellar/python3/{}/Frameworks/Python.framework/Versions/{}/lib'
.format('{}.{}.{}'.format(*version), '{}.{}'.format(*version))
]
ldflags = ['-L' + os.path.join(sys.prefix, 'lib')]
ffi.set_source('parser_interface', '#include "%s"' % defs_file,
extra_link_args=ldflags)
with open(parser_file) as f:
Expand Down
4 changes: 3 additions & 1 deletion src/parse/rules/go_rules.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def go_generate(name, srcs, tools, deps=None, visibility=None, test_only=False):
# It's also essential that the compiled .a files are under this prefix, otherwise gcimporter won't find them.
'mkdir pkg',
'ln -s $TMP_DIR pkg/%s_%s' % (CONFIG.OS, CONFIG.ARCH),
'export PATH="$(echo "$TOOLS_GEN " | sed -re \'s|/[^/]+[ ]|:|g\')$PATH"',
'export PATH="$(echo "$TOOLS_GEN " | sed -E -e \'s|/[^/]+[ ]|:|g\')$PATH"',
'GOPATH="$TMP_DIR$(echo ":$(%s)" | sed "s/:$//g")" $TOOLS_GO generate $SRCS' % gopath,
'mv $PKG_DIR/*.go .',
'ls *.go'
Expand Down Expand Up @@ -171,6 +171,8 @@ def cgo_library(name, srcs, go_srcs=None, c_srcs=None, hdrs=None, out=None, comp
cmd = ' && '.join([
'cd $PKG_DIR',
'$TOOL tool cgo -objdir $TMP_DIR -importpath ${PKG#*src/} *.go',
# Remote the .o file which BSD sed gets upset about in the next command
'rm -f $TMP_DIR/_cgo_.o',
# cgo leaves absolute paths in these files which we must get rid of :(
'find $TMP_DIR -type f -maxdepth 1 | xargs sed -i -e "s|$TMP_DIR/||g"',
'cd $TMP_DIR',
Expand Down
27 changes: 19 additions & 8 deletions tools/cache/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (
)

func TestBringUpCluster(t *testing.T) {
lis := openRPCPort(6995)
c1 := NewCluster(5995, 6995, "c1")
m1 := newRPCServer(c1, 6995)
m1 := newRPCServer(c1, lis)
c1.Init(3)
log.Notice("Cluster seeded")

lis = openRPCPort(6996)
c2 := NewCluster(5996, 6996, "c2")
m2 := newRPCServer(c2, 6996)
m2 := newRPCServer(c2, lis)
c2.Join([]string{"127.0.0.1:5995"})
log.Notice("c2 joined cluster")

Expand All @@ -42,8 +44,9 @@ func TestBringUpCluster(t *testing.T) {
assert.Equal(t, expected, c1.GetMembers())
assert.Equal(t, expected, c2.GetMembers())

lis = openRPCPort(6997)
c3 := NewCluster(5997, 6997, "c3")
m3 := newRPCServer(c2, 6997)
m3 := newRPCServer(c2, lis)
c3.Join([]string{"127.0.0.1:5995", "127.0.0.1:5996"})

expected = []*pb.Node{
Expand Down Expand Up @@ -124,16 +127,24 @@ func (r *mockRPCServer) Replicate(ctx context.Context, req *pb.ReplicateRequest)
return &pb.ReplicateResponse{Success: true}, nil
}

// openRPCPort opens a port for the gRPC server.
// This is rather awkwardly split up from below to try to avoid races around the port opening.
// There's something of a circular dependency between starting the gossip service (which triggers
// RPC calls) and starting the gRPC server (which refers to said gossip service).
func openRPCPort(port int) net.Listener {
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
log.Fatalf("Failed to listen on port %d: %v", port, err)
}
return lis
}

// newRPCServer creates a new mockRPCServer, starts a gRPC server running it, and returns it.
// It's not possible to stop it again...
func newRPCServer(cluster *Cluster, port int) *mockRPCServer {
func newRPCServer(cluster *Cluster, lis net.Listener) *mockRPCServer {
m := &mockRPCServer{cluster: cluster}
s := grpc.NewServer()
pb.RegisterRpcServerServer(s, m)
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
log.Fatalf("Failed to listen on port %d: %v", port, err)
}
go s.Serve(lis)
return m
}
2 changes: 1 addition & 1 deletion tools/sandbox/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef __linux__
#include <stdlib.h>
#include <sched.h>
#include <string.h>
#include <net/if.h>
Expand Down

0 comments on commit 15d47b0

Please sign in to comment.