Skip to content

Commit f653067

Browse files
committed
Merge branch 'marlowe-deploy-cherrypicks'
2 parents bcd94a5 + 5c3e7aa commit f653067

File tree

8 files changed

+63
-50
lines changed

8 files changed

+63
-50
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414

15+
- name: Inject slug/short variables
16+
uses: rlespinasse/[email protected]
17+
1518
- name: Deploy to bitte
16-
run: ./scripts/deploy-bitte master
19+
run: ./scripts/deploy-bitte

bitte/default.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,19 @@ in
1111
plutus-playground-server-entrypoint = pkgs.callPackage ./plutus-playground-server.nix {
1212
variant = "plutus";
1313
pkg = plutus-playground.server;
14-
port = 4003;
1514
};
1615
plutus-playground-client-entrypoint = playgroundStatic {
1716
client = plutus-playground.client;
1817
variant = "plutus";
19-
port = 8081;
2018
};
2119

2220
marlowe-playground-server-entrypoint = pkgs.callPackage ./plutus-playground-server.nix {
2321
variant = "marlowe";
2422
pkg = marlowe-playground.server;
25-
port = 4004;
2623
};
2724
marlowe-playground-client-entrypoint = playgroundStatic {
2825
client = marlowe-playground.client;
2926
variant = "marlowe";
30-
port = 8087;
3127
};
3228

3329
marlowe-run-entrypoint = pkgs.callPackage ./pab.nix {
@@ -37,6 +33,5 @@ in
3733

3834
marlowe-website-entrypoint = staticSite {
3935
root = marlowe-web;
40-
port = 8088;
4136
};
4237
}

bitte/pab.nix

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
1-
{ writeShellScriptBin, writeText, pabExe, staticPkg, cacert, coreutils, lib }:
1+
{ writeShellScriptBin, writeText, pabExe, staticPkg, cacert, coreutils, lib, gnused }:
22
let
33
dbFile = "/var/lib/pab/pab-core.db";
44

5-
webserverPort = 9080;
6-
walletPort = 8086;
7-
nodePort = 8082;
8-
chainIndexPort = 8083;
9-
signingProcessPort = 8084;
10-
metadataPort = 8085;
5+
# /var/lib isn't right but whatever
6+
pabYaml = "/var/lib/pab/pab.yaml";
117

12-
slotZeroTime = 1591566291000; # POSIX time of 2020-06-07T21:44:51Z (Sunday, June 7, 2020 21:44:51)
8+
slotZeroTime = 1596059091000; # POSIX time of slot zeron is milliseconds. See note [Datetime to slot] in Marlowe.Slot
139
slotLengthMillis = 1000;
1410

1511
constantFee = 10; # Constant fee per transaction in lovelace
16-
scriptsFeeFactor = 1.0; # Factor by which to multiply the size-dependent scripts fee in lovelace
12+
scriptsFeeFactor = 0.0; # Factor by which to multiply the size-dependent scripts fee in lovelace
1713

18-
pabYaml = writeText "pab.yaml" (builtins.toJSON {
14+
pabYamlIn = writeText "pab.yaml.in" (builtins.toJSON {
1915
dbConfig = {
2016
dbConfigFile = dbFile;
2117
dbConfigPoolSize = 20;
2218
};
2319

2420
pabWebserverConfig = {
25-
baseUrl = "http://localhost:${builtins.toString webserverPort}";
21+
baseUrl = "http://localhost:@WEBSERVER_PORT@";
2622
staticDir = "${staticPkg}";
2723
permissiveCorsPolicy = false;
2824
};
2925

3026
walletServerConfig = {
31-
baseUrl = "http://localhost:${builtins.toString walletPort}";
27+
baseUrl = "http://localhost:@WALLET_PORT@";
3228
wallet = {
3329
getWallet = 1;
3430
};
3531
};
3632

3733
nodeServerConfig = {
38-
mscBaseUrl = "http://localhost:${builtins.toString nodePort}";
34+
mscBaseUrl = "http://localhost:@NODE_PORT@";
3935
mscSocketPath = "/tmp/node-server.sock";
4036
mscRandomTxInterval = 20000000;
4137
mscSlotConfig = {
@@ -59,7 +55,7 @@ let
5955
};
6056

6157
chainIndexConfig = {
62-
ciBaseUrl = "http://localhost:${builtins.toString chainIndexPort}";
58+
ciBaseUrl = "http://localhost:@CHAIN_INDEX_PORT@";
6359
ciWatchedAddresses = [ ];
6460
};
6561

@@ -68,15 +64,11 @@ let
6864
};
6965

7066
signingProcessConfig = {
71-
spBaseUrl = "http://localhost:${builtins.toString signingProcessPort}";
67+
spBaseUrl = "http://localhost:@SIGNING_PROCESS_PORT@";
7268
spWallet = {
7369
getWallet = "1";
7470
};
7571
};
76-
77-
metadataServerConfig = {
78-
mdBaseUrl = "http://localhost:${builtins.toString metadataPort}";
79-
};
8072
});
8173

8274
# Note: The db is dropped as a workaround for a problem with
@@ -100,6 +92,14 @@ writeShellScriptBin "entrypoint" ''
10092
10193
export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs/ca-bundle.crt
10294
95+
${gnused}/bin/sed -e "s|@WEBSERVER_PORT@|$((PORT_RANGE_BASE))|g" \
96+
-e "s|@NODE_PORT@|$((PORT_RANGE_BASE + 1))|g" \
97+
-e "s|@CHAIN_INDEX_PORT@|$((PORT_RANGE_BASE + 2))|g" \
98+
-e "s|@SIGNING_PROCESS_PORT@|$((PORT_RANGE_BASE + 3))|g" \
99+
-e "s|@WALLET_PORT@|$((PORT_RANGE_BASE + 4))|g" \
100+
${pabYamlIn} > ${pabYaml}
101+
102+
103103
${pab-init-cmd}/bin/pab-init-cmd
104104
105105
exec ${pabExe} --config=${pabYaml} all-servers

bitte/playground-static.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
let
33
shiftedDocs = linkFarm docs.name [{ name = "doc"; path = docs; }];
44
in
5-
{ variant, client, port }: staticSite {
5+
{ variant, client }: staticSite {
66
root = (symlinkJoin {
77
name = "${variant}-playground-client-and-docs";
88
paths = [ client shiftedDocs ];
99
});
10-
inherit port;
1110
}

bitte/plutus-playground-server.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{ writeShellScriptBin, pkg, variant, symlinkJoin, lib, cacert, port }:
1+
{ writeShellScriptBin, pkg, variant, symlinkJoin, lib, cacert }:
22

33
let
44
deps = [ pkg ];
55
entrypoint = writeShellScriptBin "entrypoint" ''
66
export PATH=${lib.makeBinPath deps}
77
export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs/ca-bundle.crt
8-
${variant}-playground-server webserver -p ${toString port}
8+
${variant}-playground-server webserver -p $PORT
99
'';
1010
in
1111
symlinkJoin {

bitte/static-site.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd }: { root, port }:
1+
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd }: { root }:
22

33
let
44
config = writeText "lighttpd.conf" ''
55
server.modules = ("mod_deflate")
66
server.document-root = "${root}"
7-
server.port = ${toString port}
7+
server.port = env.PORT
88
index-file.names = ("index.html")
99
mimetype.assign = (
1010
".css" => "text/css",

bitte/web-ghc-server.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
let
44
entrypoint = writeShellScriptBin "entrypoint" ''
5-
${web-ghc-server}/bin/web-ghc-server webserver -p 8009 --bind 0.0.0.0
5+
${web-ghc-server}/bin/web-ghc-server webserver -p $PORT --bind 0.0.0.0
66
'';
77
in
88
symlinkJoin {

scripts/deploy-bitte

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,36 @@ error () {
77
}
88

99
readonly ops_repo="input-output-hk/plutus-ops"
10+
readonly ops_branch="master"
1011
readonly plutus_rev="${GITHUB_SHA:-}"
12+
1113
if [ -z "${plutus_rev}" ]
1214
then
1315
error "GITHUB_SHA environment variable not set!"
1416
fi
1517

16-
### Argument parsing
18+
readonly plutus_ref="${GITHUB_REF_SLUG:-}"
1719

18-
if [ "$#" -ne 1 ]
20+
if [ -z "${plutus_ref}" ]
1921
then
20-
error "USAGE: $0 OPS_BRANCH"
22+
error "GITHUB_REF_SLUG environment variable not set!"
2123
fi
2224

23-
readonly ops_branch="$1"
25+
declare -A ref_env_mapping=(
26+
# TODO Make this the production branch
27+
[bitte]=production
28+
)
29+
30+
if [ ! -v 'ref_env_mapping[${plutus_ref}]' ]
31+
then
32+
error "Ref ${plutus_ref} does not correspond to any known env"
33+
fi
34+
plutus_env="${ref_env_mapping[${plutus_ref}]}"
35+
36+
if [ "$#" -ne 0 ]
37+
then
38+
error "USAGE: $0"
39+
fi
2440

2541
### Set up scratch space
2642

@@ -38,31 +54,31 @@ tmp="$(mktemp -d)"
3854

3955
declare -r tmp
4056

41-
### Write the new plutus-rev.cue
57+
### Write the new revision cue file
4258

43-
cat > "${tmp}/plutus-rev.cue" <<EOF
44-
package bitte
59+
cat > "${tmp}/${plutus_env}.cue" <<EOF
60+
package revisions
4561
46-
plutusRev: "${plutus_rev}"
62+
${plutus_env}: "${plutus_rev}"
4763
EOF
4864

4965

5066

51-
### Get the old plutus-rev.cue, exit if it's unchanged
52-
hub api -XGET -F ref="${ops_branch}" "/repos/${ops_repo}/contents/plutus-rev.cue" > "${tmp}/plutus-rev.cue-contents.json"
53-
prev_hash="$(jq --join-output '.sha' < "${tmp}/plutus-rev.cue-contents.json")"
54-
jq --join-output '.content' < "${tmp}/plutus-rev.cue-contents.json" | base64 -d > "${tmp}/plutus-rev-old.cue"
55-
if diff -q "${tmp}/plutus-rev.cue" "${tmp}/plutus-rev-old.cue" >/dev/null
67+
### Get the old revision cue file, exit if it's unchanged
68+
hub api -XGET -F ref="${ops_branch}" "/repos/${ops_repo}/contents/revisions/${plutus_env}.cue" > "${tmp}/${plutus_env}.cue-contents.json"
69+
prev_hash="$(jq --join-output '.sha' < "${tmp}/${plutus_env}.cue-contents.json")"
70+
jq --join-output '.content' < "${tmp}/${plutus_env}.cue-contents.json" | base64 -d > "${tmp}/${plutus_env}-old.cue"
71+
if diff -q "${tmp}/${plutus_env}.cue" "${tmp}/${plutus_env}-old.cue" >/dev/null
5672
then
5773
exit 0
5874
fi
5975

60-
### Commit the new plutus-rev.cue
61-
base64 "${tmp}/plutus-rev.cue" > "${tmp}/plutus-rev.cue-encoded"
62-
echo "Automatic update: Bump plutus to ${plutus_rev}" > "${tmp}/commit-message"
76+
### Commit the new revision cue file
77+
base64 "${tmp}/${plutus_env}.cue" > "${tmp}/${plutus_env}.cue-encoded"
78+
echo "${plutus_env}: Bump plutus to ${plutus_rev}" > "${tmp}/commit-message"
6379
hub api -XPUT \
6480
-F message=@"${tmp}/commit-message" \
65-
-F content=@"${tmp}/plutus-rev.cue-encoded" \
81+
-F content=@"${tmp}/${plutus_env}.cue-encoded" \
6682
-F sha="${prev_hash}" \
6783
-F branch="${ops_branch}" \
68-
"/repos/${ops_repo}/contents/plutus-rev.cue"
84+
"/repos/${ops_repo}/contents/revisions/${plutus_env}.cue"

0 commit comments

Comments
 (0)