Skip to content

Commit ced57ff

Browse files
hyades-bors[bot]cryslith
hyades-bors[bot]
andcommitted
Merge #511
511: Add bors-ng configuration r=cryslith a=cryslith - Configure bors-ng - Run CircleCI only during bors merges - Require branches to have linear git history Closes #491. Co-authored-by: Lily Chung <lkdc@mit.edu>
2 parents 475b6bc + 54235a6 commit ced57ff

File tree

4 files changed

+168
-1
lines changed

4 files changed

+168
-1
lines changed

.circleci/config.yml

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
version: 2
1+
version: 2.1
22
jobs:
3+
check-linear:
4+
machine:
5+
image: ubuntu-1604:201903-01
6+
steps:
7+
- checkout
8+
- run:
9+
name: Check git history of branch is linear
10+
command: tools/check-linear.sh
311
build:
412
machine:
513
image: ubuntu-1604:201903-01
@@ -32,3 +40,21 @@ jobs:
3240
- run:
3341
name: Launch build with bazel
3442
command: echo "bazel build //upload --verbose_failures" | HOMEWORLD_CHROOT="$HOME/autobuild-chroot" USER="circleci" ./build-chroot/enter-ci.sh
43+
workflows:
44+
version: 2
45+
workflow:
46+
jobs:
47+
- check-linear:
48+
filters:
49+
branches:
50+
ignore:
51+
- staging
52+
- trying
53+
- master
54+
- build:
55+
filters:
56+
branches:
57+
only:
58+
- staging
59+
- trying
60+
- master

bors.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
status = [
2+
"ci/circleci: build",
3+
"continuous-integration/jenkins/branch",
4+
]
5+
pr_status = [
6+
"ci/circleci: check-linear",
7+
]
8+
required_approvals = 1
9+
timeout_sec = 10800 # three hour timeout
10+
cut_body_after = "---"
11+
12+
[committer]
13+
name = "hyades-bors[bot]"
14+
email = "sipb-hyades@mit.edu"

docs/bors-ng-setup.txt

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
exit # this isn't quite a script; some parts are interactive.
2+
3+
### Register Github App
4+
# https://github.com/bors-ng/bors-ng#step-1-register-a-new-github-app
5+
# Dashboard URL: https://hijinks.mit.edu:4002/
6+
# Generate and download a private key (.pem file)
7+
8+
9+
### Install dependencies
10+
11+
wget -q -O - https://packages.erlang-solutions.com/debian/erlang_solutions.asc | apt-key add -
12+
echo 'deb https://packages.erlang-solutions.com/debian stretch contrib' >/etc/apt/sources.list.d/erlang-solutions.list
13+
14+
wget -q -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
15+
echo 'deb https://deb.nodesource.com/node_13.x stretch main' >/etc/apt/sources.list.d/nodesource.list
16+
17+
apt-get update
18+
apt-get install esl-erlang elixir postgresql nodejs
19+
20+
21+
# use this command to generate random secrets when called for:
22+
# </dev/urandom tr -dc 'a-zA-Z0-9' | head -c64
23+
24+
### User
25+
useradd -m -U borsng
26+
27+
28+
### Database
29+
sudo -u postgres createuser -P borsng # generate a random db password
30+
sudo -u postgres createdb -O borsng borsng
31+
sudo -u postgres psql -d borsng <<<"CREATE EXTENSION IF NOT EXISTS citext;"
32+
33+
34+
### Nginx configuration: requires existing nginx+certbot setup from jenkins-setup.txt
35+
# Add this location block to /etc/nginx/sites-available/hijinks
36+
cat <<EOF
37+
server {
38+
listen 4002 ssl;
39+
server_name hijinks.mit.edu;
40+
41+
# copied from jenkins' server block:
42+
ssl_certificate /etc/letsencrypt/live/hijinks.mit.edu/fullchain.pem;
43+
ssl_certificate_key /etc/letsencrypt/live/hijinks.mit.edu/privkey.pem;
44+
include /etc/letsencrypt/options-ssl-nginx.conf;
45+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
46+
47+
ssl_trusted_certificate /etc/letsencrypt/live/hijinks.mit.edu/chain.pem;
48+
ssl_stapling on;
49+
ssl_stapling_verify on;
50+
add_header Strict-Transport-Security "max-age=31536000" always;
51+
52+
location / {
53+
include /etc/nginx/proxy_params;
54+
proxy_pass http://localhost:4001/;
55+
proxy_redirect default;
56+
}
57+
}
58+
EOF
59+
60+
### Systemd configuration
61+
cat <<EOF >borsng.service
62+
[Unit]
63+
Description=Bors-NG
64+
After=network.target
65+
66+
[Service]
67+
Type=simple
68+
User=borsng
69+
WorkingDirectory=/home/borsng/bors-ng
70+
EnvironmentFile=/home/borsng/bors-env
71+
Restart=on-failure
72+
ExecStart=/home/borsng/bors-ng/_build/prod/rel/bors/bin/bors start
73+
ExecStop=/home/borsng/bors-ng/_build/prod/rel/bors/bin/bors stop
74+
75+
[Install]
76+
WantedBy=multi-user.target
77+
EOF
78+
ln -s "$(realpath borsng.service)" /etc/systemd/system
79+
systemctl enable borsng
80+
81+
82+
sudo -iu borsng # run all remaining commands as borsng
83+
umask go=
84+
85+
git clone https://github.com/bors-ng/bors-ng.git
86+
87+
cd bors-ng
88+
mix local.hex --force
89+
mix deps.get --only prod
90+
mix local.rebar --force
91+
92+
pushd assets
93+
npm install
94+
popd
95+
npm run deploy --prefix ./assets
96+
MIX_ENV=prod mix phx.digest
97+
98+
MIX_ENV=prod mix compile
99+
MIX_ENV=prod mix release
100+
101+
102+
cat >~/bors-env <<EOF
103+
PORT=4001
104+
MIX_ENV=prod
105+
SECRET_KEY_BASE=??? # generate this randomly
106+
DATABASE_URL='ecto://borsng:<db password>@localhost/borsng' # password from earlier
107+
GITHUB_INTEGRATION_ID=??? # App id in github
108+
GITHUB_WEBHOOK_SECRET=??? # generate this randomly and input it to github
109+
GITHUB_CLIENT_ID=??? # from github
110+
GITHUB_CLIENT_SECRET=??? # from github
111+
PUBLIC_HOST=localhost
112+
EOF
113+
echo "GITHUB_INTEGRATION_PEM='$(base64 -w0 /path/to/file.private-key.pem)'" >>~bors-env # private key from github
114+
115+
sh -ac '. ~/bors-env && POOL_SIZE=1 mix ecto.migrate'

tools/check-linear.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
if [ 0 = "$(git rev-list --min-parents=2 --count "$(git merge-base origin/master HEAD)"..HEAD)" ]
5+
then
6+
echo 'git history is linear'
7+
else
8+
echo 'error: nonlinear branch git history'
9+
echo 'merge commits:'
10+
git rev-list --min-parents=2 "$(git merge-base origin/master HEAD)"..HEAD
11+
exit 1
12+
fi

0 commit comments

Comments
 (0)