Skip to content

Commit d691e0f

Browse files
committed
Fixed CI
1 parent 10ef0c2 commit d691e0f

File tree

4 files changed

+120
-153
lines changed

4 files changed

+120
-153
lines changed

.github/workflows/shared.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ jobs:
7979
- if: ${{ matrix.os == 'ubuntu-latest' }}
8080
name: run urbit-tests
8181
run: |
82-
nix flake check
82+
nix flake check --keep-build-log

flake.nix

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@
1616
patchShebangs $out
1717
'';
1818
pkgs = import nixpkgs { inherit system; };
19-
bootFakeShip = { pill }:
19+
bootFakeShip = { pill, arvo }:
2020
pkgs.runCommand "fake-pier" { } ''
21-
${pkgs.urbit}/bin/urbit --pier $out -F zod -B ${pill} -l -x -t -A ${
22-
./pkg
23-
}/arvo
21+
${pkgs.urbit}/bin/urbit --pier $out -F zod -B ${pill} -l -x -t -A ${arvo}
2422
'';
25-
fakePier = bootFakeShip { pill = ./bin/solid.pill; };
23+
fakePier = bootFakeShip {
24+
pill = ./bin/solid.pill;
25+
arvo = "${./pkg}/arvo";
26+
};
27+
testPier = bootFakeShip {
28+
pill = ./bin/solid.pill;
29+
arvo = pkgs.runCommand "test-arvo" {} ''
30+
cp -r ${./pkg} $out
31+
chmod +w -R $out
32+
cp -r ${./tests} $out/arvo/tests
33+
cp -r ${./test-desk.bill} $out/arvo/desk.bill
34+
'' + "/arvo";
35+
};
2636
buildPillThread = pill:
2737
pkgs.writeTextFile {
2838
name = "";
@@ -50,12 +60,13 @@
5060
in {
5161
checks = {
5262
testFakeShip = import ./nix/test-fake-ship.nix {
53-
inherit (pkgs) stdenvNoCC curl python3 urbit;
54-
pier = fakePier;
63+
inherit pkgs;
64+
pier = testPier;
65+
click = usableTools + "/pkg/click/click";
5566
};
5667
};
5768
packages = {
58-
inherit fakePier;
69+
inherit fakePier testPier;
5970
brass = buildPill "brass";
6071
ivory = buildPill "ivory";
6172
solid = buildPill "solid";

nix/test-fake-ship.nix

Lines changed: 87 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,74 @@
1-
{ stdenvNoCC, curl, python3, pier, urbit }:
2-
3-
stdenvNoCC.mkDerivation {
1+
{ click, pier, pkgs }:
2+
3+
let
4+
poke = ''
5+
=>
6+
|%
7+
++ take-poke-ack
8+
|= =wire
9+
=/ m (strand ,?)
10+
^- form:m
11+
|= tin=strand-input:strand
12+
?+ in.tin `[%skip ~]
13+
~ `[%wait ~]
14+
[~ %agent * %poke-ack *]
15+
?. =(wire wire.u.in.tin)
16+
`[%skip ~]
17+
?~ p.sign.u.in.tin
18+
`[%done %.y]
19+
`[%done %.n]
20+
==
21+
++ poke
22+
|= [=dock =cage]
23+
=/ m (strand ,?)
24+
^- form:m
25+
=/ =card:agent:gall [%pass /poke %agent dock %poke cage]
26+
;< ~ bind:m (send-raw-card card)
27+
(take-poke-ack /poke)
28+
--
29+
30+
'';
31+
testThread = dojoCommand:
32+
pkgs.writeTextFile {
33+
name = "${dojoCommand}.hoon";
34+
text = ''
35+
${poke}
36+
=/ m (strand ,vase)
37+
;< [=ship =desk =case] bind:m get-beak
38+
;< ok=? bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '${dojoCommand}'] [%output-file 'result/noun']]))
39+
(pure:m !>(ok))
40+
'';
41+
};
42+
appThread = generator: app:
43+
pkgs.writeTextFile {
44+
name = ":${app}|${generator}.hoon";
45+
text = ''
46+
${poke}
47+
=/ m (strand ,vase)
48+
;< [=ship =desk =case] bind:m get-beak
49+
;< ok=? bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '+${app}/${generator}'] [%app %${app}]]))
50+
(pure:m !>(ok))
51+
'';
52+
};
53+
pokeApp = hoon: mark: app:
54+
pkgs.writeTextFile {
55+
name = ":${app} &${mark} ${hoon}.hoon";
56+
text = ''
57+
${poke}
58+
=/ m (strand ,vase)
59+
;< [=ship =desk =case] bind:m get-beak
60+
;< ok=? bind:m (poke [ship %${app}] %${mark} !>(${hoon}))
61+
(pure:m !>(ok))
62+
'';
63+
};
64+
in pkgs.stdenvNoCC.mkDerivation {
465
name = "test-urbit";
566

667
src = pier;
768

869
phases = [ "unpackPhase" "buildPhase" "checkPhase" ];
970

10-
buildInputs = [ curl python3 ];
71+
nativeBuildInputs = [ pkgs.netcat ];
1172

1273
unpackPhase = ''
1374
cp -R $src ./pier
@@ -16,166 +77,48 @@ stdenvNoCC.mkDerivation {
1677

1778
buildPhase = ''
1879
set -x
80+
set -e
1981
20-
${urbit}/bin/urbit -d ./pier 2> urbit-output
21-
22-
# Sledge Hammer!
23-
# See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959
24-
python3 -c $'import os\n[os.set_blocking(i, True) for i in range(3)]\n'
25-
26-
port=$(cat ./pier/.http.ports | grep loopback | tr -s ' ' '\n' | head -n 1)
27-
28-
lensd() {
29-
# -f elided, this can hit server-side timeouts
30-
curl -s \
31-
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
32-
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
33-
}
34-
35-
lensa() {
36-
# -f elided, this can hit server-side timeouts
37-
curl -s \
38-
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
39-
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
40-
}
41-
42-
tail -F urbit-output >&2 &
43-
44-
tailproc=$!
45-
46-
cleanup () {
47-
kill $(cat ./pier/.vere.lock) || true
48-
kill "$tailproc" 2>/dev/null || true
49-
50-
set +x
51-
}
52-
53-
trap cleanup EXIT
54-
55-
# measure initial memory usage
56-
#
57-
lensd '~& ~ ~& %init-mass-start ~'
58-
lensa hood '+hood/mass'
59-
lensd '~& ~ ~& %init-mass-end ~'
60-
61-
# run the unit tests
62-
#
63-
lensd '~& ~ ~& %test-unit-start ~'
64-
lensd '-test %/tests ~'
65-
lensd '~& ~ ~& %test-unit-end ~'
66-
67-
# use the :test app to build all agents, generators, and marks
68-
#
69-
lensa hood '+hood/start %test'
70-
71-
lensd '~& ~ ~& %test-agents-start ~'
72-
lensa test '%agents'
73-
lensd '~& ~ ~& %test-agents-end ~'
82+
${pkgs.urbit}/bin/urbit -d ./pier 1>&2 2> $out
7483
75-
lensd '~& ~ ~& %test-generators-start ~'
76-
lensa test '%generators'
77-
lensd '~& ~ ~& %test-generators-end ~'
84+
tail -F $out >&2 &
85+
86+
${click} -k -p -i ${appThread "mass" "hood"} ./pier
7887
79-
lensd '~& ~ ~& %test-marks-start ~'
80-
lensa test '%marks'
81-
lensd '~& ~ ~& %test-marks-end ~'
88+
sleep 2
8289
83-
# measure memory usage post tests
84-
#
85-
lensd '~& ~ ~& %test-mass-start ~'
86-
lensa hood '+hood/mass'
87-
lensd '~& ~ ~& %test-mass-end ~'
90+
${click} -k -p -i ${testThread "-test %/tests ~"} ./pier
8891
89-
# defragment the loom
90-
#
91-
lensd '~& ~ ~& %pack-start ~'
92-
lensa hood '+hood/pack'
93-
lensd '~& ~ ~& %pack-end ~'
92+
${click} -k -p -i ${pokeApp "%agents" "noun" "test"} ./pier
93+
${click} -k -p -i ${pokeApp "%generators" "noun" "test"} ./pier
94+
${click} -k -p -i ${pokeApp "%marks" "noun" "test"} ./pier
9495
95-
# reclaim space within arvo
96-
#
97-
lensd '~& ~ ~& %trim-start ~'
98-
lensa hood '+hood/trim'
99-
lensd '~& ~ ~& %trim-end ~'
96+
# The rest of the commands fail for unknown reasons.
10097
101-
# measure memory usage pre |meld
102-
#
103-
lensd '~& ~ ~& %trim-mass-start ~'
104-
lensa hood '+hood/mass'
105-
lensd '~& ~ ~& %trim-mass-end ~'
98+
# ${click} -k -p -i ${appThread "mass" "hood"} ./pier
99+
# sleep 2
106100
107-
# globally deduplicate
108-
#
109-
lensd '~& ~ ~& %meld-start ~'
110-
lensa hood '+hood/meld'
111-
lensd '~& ~ ~& %meld-end ~'
101+
# ${click} -k -p -i ${pokeApp "~" "helm-pack" "hood"} ./pier
112102
113-
# measure memory usage post |meld
114-
#
115-
lensd '~& ~ ~& %meld-mass-start ~'
116-
lensa hood '+hood/mass'
117-
lensd '~& ~ ~& %meld-mass-end ~'
103+
# ${click} -k -p -i ${appThread "trim" "hood"} ./pier
118104
119-
lensa hood '+hood/exit'
105+
# ${click} -k -p -i ${appThread "mass" "hood"} ./pier
120106
121-
cleanup
107+
# ${click} -k -p -i ${appThread "meld" "hood"} ./pier
122108
123-
# Collect output
124-
cp urbit-output test-output-unit
125-
cp urbit-output test-output-agents
126-
cp urbit-output test-output-generators
127-
cp urbit-output test-output-marks
128-
129-
sed -i '0,/test-unit-start/d' test-output-unit
130-
sed -i '/test-unit-end/,$d' test-output-unit
109+
# sleep 60
131110
132-
sed -i '0,/test-agents-start/d' test-output-agents
133-
sed -i '/test-agents-end/,$d' test-output-agents
111+
# ${click} -k -p -i ${appThread "mass" "hood"} ./pier
134112
135-
sed -i '0,/test-generators-start/d' test-output-generators
136-
sed -i '/test-generators-end/,$d' test-output-generators
137-
138-
sed -i '0,/test-marks-start/d' test-output-marks
139-
sed -i '/test-marks-end/,$d' test-output-marks
140-
141-
mkdir -p $out
142-
143-
cp test-output-* $out/
113+
# ${click} -k -p -i ${appThread "exit" "hood"} ./pier
144114
145115
set +x
146116
'';
147117

148118
checkPhase = ''
149-
hdr () {
150-
echo =====$(sed 's/./=/g' <<< "$1")=====
151-
echo ==== $1 ====
152-
echo =====$(sed 's/./=/g' <<< "$1")=====
153-
}
154-
155-
for f in $(find "$out/" -type f); do
156-
hdr "$(basename $f)"
157-
cat "$f"
158-
done
159-
160-
fail=0
161-
162-
for f in $(find "$out/" -type f); do
163-
if egrep "((FAILED|CRASHED)|warn:) " $f >/dev/null; then
164-
if [[ $fail -eq 0 ]]; then
165-
hdr "Test Failures"
166-
fi
167-
168-
echo "ERROR Test failure in $(basename $f)"
169-
170-
((fail++))
171-
fi
172-
done
173-
174-
if [[ $fail -eq 0 ]]; then
175-
hdr "Success"
119+
if egrep "((FAILED|CRASHED|Failed)|warn:)" $out >/dev/null; then
120+
exit 1
176121
fi
177-
178-
exit "$fail"
179122
'';
180123

181124
doCheck = true;

test-desk.bill

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:~ %acme
2+
%azimuth
3+
%dbug
4+
%dojo
5+
%eth-watcher
6+
%hood
7+
%herm
8+
%lens
9+
%ping
10+
%spider
11+
%test
12+
==
13+

0 commit comments

Comments
 (0)