Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 23f3e00

Browse files
authored
Merge pull request #17 from keybase/david/circleci
Add CircleCI config
2 parents 52f1357 + 9ea67f6 commit 23f3e00

17 files changed

Lines changed: 80 additions & 30 deletions

.circleci/config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
jobs:
3+
integration:
4+
machine:
5+
image: circleci/classic:latest
6+
steps:
7+
- checkout
8+
- run: "./integrationTest.sh"
9+
unit:
10+
docker:
11+
- image: circleci/golang:1.11
12+
steps:
13+
- checkout
14+
- run: go test ./...
15+
lint:
16+
docker:
17+
- image: circleci/golang:1.11
18+
steps:
19+
- checkout
20+
- run: "! go fmt ./... 2>&1 | read"
21+
- run: "! go vet ./... 2>&1 | read"
22+
- run: go get -u golang.org/x/lint/golint
23+
- run: "! golint ./... 2>&1 | read"
24+
- run: go get golang.org/x/tools/cmd/goimports
25+
- run: "! goimports ./... 2>&1 | read"
26+
- run: "! go mod tidy ./... 2>&1 | read"
27+
workflows:
28+
version: 2
29+
build:
30+
jobs:
31+
- integration
32+
- unit
33+
- lint
34+

integrationTest.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,24 @@ set -euo pipefail
33
IFS=$'\n\t'
44

55
# Unit tests first
6-
go test ./... 2>&1 | grep -v 'no test files'
6+
set +u
7+
if [ -z "$CIRCLECI" ]; then
8+
go test ./... 2>&1 | grep -v 'no test files'
9+
fi
710

11+
# Ensure we have the correct environment variables
812
if [[ -f "tests/env.sh" ]]; then
9-
echo "env.sh file already exists, skipping configuring new accounts..."
13+
echo "env.sh already exists, skipping configuring new accounts..."
14+
source tests/env.sh
1015
else
16+
if [ -n "$CIRCLECI" ]; then
17+
echo "Running in circle with configured environment variables"
18+
else
1119
python3 tests/configure_accounts.py
20+
source tests/env.sh
21+
fi
1222
fi
13-
23+
set -u
1424

1525
# Some colors for pretty output
1626
RED='\033[0;31m'
@@ -19,13 +29,13 @@ NC='\033[0m'
1929

2030
# A function used to indent the log output from the tests
2131
indent() { sed 's/^/ /'; }
32+
# Reset docker and wipe all volumes
2233
reset_docker() {
2334
docker-compose down -v
2435
docker system prune -f
2536
}
2637

2738
cd tests/
28-
source env.sh
2939
reset_docker
3040

3141
echo "Building containers..."

tests/Dockerfile-sshd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This dockerfile builds an openssh server that will accept SSH keys signed by the key provided in /mnt/keybase-ca-key.pub
1+
# This dockerfile builds an openssh server that will accept SSH keys signed by the key provided in /shared/keybase-ca-key.pub
22
# It takes in a build argument and only allows keys with the build argument in the principals field
33
FROM ubuntu:18.04
44

@@ -26,4 +26,4 @@ RUN echo -n "uniquestring" > /etc/unique
2626

2727
EXPOSE 22
2828

29-
CMD ln -sf /mnt/keybase-ca-key.pub /etc/ssh/ca.pub && /usr/sbin/sshd -D
29+
CMD ln -sf /shared/keybase-ca-key.pub /etc/ssh/ca.pub && /usr/sbin/sshd -D

tests/bot-entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def load_env():
2424
"bin/keybaseca --wipe-all-configs\n"
2525
"bin/keybaseca --wipe-logs || true\n"
2626
"bin/keybaseca generate --overwrite-existing-key\n"
27-
"echo yes | bin/keybaseca backup > /mnt/cakey.backup\n"
27+
"echo yes | bin/keybaseca backup > /shared/cakey.backup\n"
2828
"bin/keybaseca service &"
2929
) % (shlex.quote(path)))
3030
# Sleep so keybaseca has time to start

tests/bot-entrypoint.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5-
# For some reason it is necessary to touch a file in /mnt/ in order to get the volume permissions to work correctly
5+
# For some reason it is necessary to touch a file in /shared/ in order to get the volume permissions to work correctly
66
# when keybaseca generate runs
7-
touch /mnt/.keep
7+
touch /shared/.keep
88

99
# Generate the env files that will be used for tests
10-
source tests/env.sh
1110
mkdir -p tests/generated-env
1211
ls tests/envFiles/ | xargs -I {} -- bash -c 'cat tests/envFiles/{} | envsubst > tests/generated-env/{}'
1312

1413
nohup bash -c "run_keybase -g &"
1514
sleep 3
1615
keybase oneshot --username $BOT_USERNAME --paperkey "$BOT_PAPERKEY"
17-
touch /mnt/ready
16+
touch /shared/ready
1817
python3 tests/bot-entrypoint.py

tests/docker-compose.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ services:
99
environment:
1010
- BOT_PAPERKEY
1111
- BOT_USERNAME
12+
- SUBTEAM
1213
volumes:
13-
- app-volume:/mnt/
14+
- app-volume:/shared/
1415
user: root
15-
command: "sh -c 'chown -R keybase:keybase /mnt && su keybase -c \"bash tests/bot-entrypoint.sh\"'"
16+
command: "sh -c 'chown -R keybase:keybase /shared && su keybase -c \"bash tests/bot-entrypoint.sh\"'"
1617
ports:
1718
- 8080 # Used for the flask webserver that manages restarting keybaseca with different config options
1819
depends_on:
@@ -31,7 +32,7 @@ services:
3132
- SUBTEAM
3233
- SUBTEAM_SECONDARY
3334
volumes:
34-
- app-volume:/mnt/
35+
- app-volume:/shared/
3536
user: keybase
3637
command: "bash tests/tester-entrypoint.sh"
3738
depends_on:
@@ -49,7 +50,7 @@ services:
4950
user_principal: ${SUBTEAM}.ssh.staging
5051
root_principal: ${SUBTEAM}.ssh.root_everywhere
5152
volumes:
52-
- app-volume:/mnt/
53+
- app-volume:/shared/
5354
# An ssh server that will accept signed requests with the principal "prod"
5455
sshd-prod:
5556
image: sshd-prod
@@ -61,6 +62,6 @@ services:
6162
user_principal: ${SUBTEAM}.ssh.prod
6263
root_principal: ${SUBTEAM}.ssh.root_everywhere
6364
volumes:
64-
- app-volume:/mnt/
65+
- app-volume:/shared/
6566
volumes:
6667
app-volume:

tests/envFiles/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
The files in this directory are env files used to run the CA bot. The files are filled in based on
2-
the values of environment variables `SUBTEAM`, `BOT_USERNAME`, and `BOT_PAPERKEY` from tests/env.sh.
2+
the values of environment variables `SUBTEAM`, `BOT_USERNAME`, and `BOT_PAPERKEY`. When running
3+
locally, these environment variables are stored in tests/env.sh.

tests/envFiles/test_env_1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export TEAMS="$SUBTEAM.ssh.staging,$SUBTEAM.ssh.prod,$SUBTEAM.ssh.root_everywher
66
export KEYBASE_PAPERKEY="$BOT_PAPERKEY"
77
export KEYBASE_USERNAME="$BOT_USERNAME"
88
export CHAT_CHANNEL="$SUBTEAM.ssh#ssh-provision"
9+
export CA_KEY_LOCATION="/shared/keybase-ca-key"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Used to test sending the audit log to the normal filesystem. The code that handles local audit log writes is different
22
# from the code that handles KBFS audit log writes.
33
export KEY_EXPIRATION="+1h"
4-
export LOG_LOCATION="/mnt/ca.log"
4+
export LOG_LOCATION="/shared/ca.log"
55
export TEAMS="$SUBTEAM.ssh.staging,$SUBTEAM.ssh.prod,$SUBTEAM.ssh.root_everywhere"
66
export KEYBASE_PAPERKEY="$BOT_PAPERKEY"
77
export KEYBASE_USERNAME="$BOT_USERNAME"
8+
export CA_KEY_LOCATION="/shared/keybase-ca-key"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Used to test the behavior of the chatbot when the user is not in the first listed team. This used to not work
22
# due to the choice of only placing config files in the first team.
33
export KEY_EXPIRATION="+1h"
4-
export LOG_LOCATION="/mnt/ca.log"
4+
export LOG_LOCATION="/shared/ca.log"
55
export TEAMS="$SUBTEAM.ssh.prod,$SUBTEAM.ssh.staging,$SUBTEAM.ssh.root_everywhere"
66
export KEYBASE_PAPERKEY="$BOT_PAPERKEY"
77
export KEYBASE_USERNAME="$BOT_USERNAME"
8+
export CA_KEY_LOCATION="/shared/keybase-ca-key"

0 commit comments

Comments
 (0)