Skip to content

Commit 5eb624e

Browse files
authored
Merge pull request #58 from lukewilliamboswell/builtin-task
Add Task as a builtin module/type
2 parents 1518c41 + 9797feb commit 5eb624e

43 files changed

Lines changed: 659 additions & 928 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
cancel-in-progress: true
99

10+
env:
11+
JUMP_START: 1
12+
ROC: ./roc_nightly/roc
13+
EXAMPLES_DIR: ./examples/
14+
1015
jobs:
1116
build-and-test:
1217
runs-on: [ubuntu-22.04]
@@ -43,7 +48,7 @@ jobs:
4348
run: expect -v
4449

4550
# Run all tests
46-
- run: ROC=./roc_nightly/roc EXAMPLES_DIR=./examples/ ./ci/all_tests.sh
51+
- run: ./ci/all_tests.sh
4752

4853
- name: Install dependencies for musl build
4954
run: |
@@ -56,23 +61,6 @@ jobs:
5661
- name: Test using musl build
5762
run: |
5863
# no need to build platform anymore
59-
sed -i '/build\.roc\|jump-start\.sh/d' ./ci/all_tests.sh
60-
ROC=./roc_nightly/roc EXAMPLES_DIR=./examples/ ./ci/all_tests.sh
64+
NO_BUILD=1 ./ci/all_tests.sh
6165
62-
63-
- name: build example in README.md
64-
run: |
65-
roc_block_count=$(grep -c '```roc' README.md)
66-
67-
# Error if more than one Roc code block
68-
if [ $roc_block_count -gt 1 ]; then
69-
echo "Error: Found $roc_block_count Roc code blocks in README.md. I only know how to test one. Modify this CI step to test them all."
70-
exit 1
71-
fi
72-
73-
# Extract roc code block from README.md
74-
sed -n '/```roc/,/```/p' README.md | sed '1d;$d' > readme.roc
75-
76-
# Build the code to make sure it works
77-
./roc_nightly/roc build readme.roc --linker=legacy
7866
# TODO clippy, rustfmt, roc fmt check

.github/workflows/ci_nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: cachix/install-nix-action@v23
2323
with:
2424
nix_path: nixpkgs=channel:nixos-unstable
25-
25+
2626
- name: Run all tests
2727
run: nix develop -c sh -c 'export ROC=roc && export EXAMPLES_DIR=./examples/ && ./ci/all_tests.sh'
2828

build.roc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
app [main] {
2-
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br",
2+
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
33
}
44

5-
import cli.Task exposing [Task]
65
import cli.Cmd
76
import cli.Stdout
87
import cli.Env
@@ -90,9 +89,9 @@ getRustTargetFolder =
9089
Task.ok "target/release/"
9190
else
9291
Task.ok "target/$(targetEnvVar)/release/"
93-
Err e ->
92+
Err e ->
9493
info! "Failed to get env var CARGO_BUILD_TARGET with error \(Inspect.toStr e). Assuming default CARGO_BUILD_TARGET (native)..."
95-
94+
9695
Task.ok "target/release/"
9796

9897
cargoBuildHost : Task {} _

ci/all_tests.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
4-
set -euxo pipefail
4+
set -exo pipefail
55

66

77
if [ -z "${ROC}" ]; then
@@ -23,8 +23,19 @@ if [ -z "${EXAMPLES_DIR}" ]; then
2323
exit 1
2424
fi
2525

26-
echo "build the platform"
27-
$ROC ./build.roc --prebuilt-platform -- --roc $ROC
26+
if [ "$NO_BUILD" != "1" ]; then
27+
if [ "$JUMP_START" == "1" ]; then
28+
echo "building platform..."
29+
30+
# we can't use a release of basic-cli becuase we are making a breaking change
31+
# let's build the platform using bash instead
32+
bash jump-start.sh
33+
34+
else
35+
# run build script for the platform which uses basic-cli
36+
$ROC ./build.roc --prebuilt-platform -- --roc $ROC
37+
fi
38+
fi
2839

2940
echo "roc check"
3041
for roc_file in $EXAMPLES_DIR*.roc; do

ci/expect_scripts/dir.exp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@ set timeout 7
77

88
spawn $env(EXAMPLES_DIR)dir
99

10-
expect "Listening on <http://127.0.0.1:8000>\r\n" {
11-
set curlOutput [exec curl -sS localhost:8000]
12-
13-
if {$curlOutput eq "Logged request"} {
14-
expect -re {The current working directory is .*/basic-webserver\r\n} {
15-
expect "Set cwd to examples/\r\n" {
16-
expect "The paths are;\r\n" {
17-
expect -re {.*dir\.roc.*} {
18-
exit 0
19-
}
20-
}
10+
expect -re {The current working directory is .*/basic-webserver\r\n} {
11+
expect "Set cwd to examples/\r\n" {
12+
expect "The paths are;\r\n" {
13+
expect -re {.*dir\.roc.*} {
14+
exit 0
2115
}
2216
}
23-
} else {
24-
puts "Error: curl output was different than expected: $curlOutput"
25-
exit 1
2617
}
2718
}
2819

crates/roc_fn/src/lib.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ROC_HOSTED_FNS: &[HostedFn] = &[
2323
HostedFn {
2424
name: "envList",
2525
arg_types: &[],
26-
ret_type: "roc_std::RocList<(roc_std::RocStr, roc_std::RocStr)>",
26+
ret_type: "roc_std::RocResult<roc_std::RocList<(roc_std::RocStr, roc_std::RocStr)>, ()>",
2727
},
2828
HostedFn {
2929
name: "exePath",
@@ -38,42 +38,32 @@ const ROC_HOSTED_FNS: &[HostedFn] = &[
3838
HostedFn {
3939
name: "cwd",
4040
arg_types: &[],
41-
ret_type: "roc_std::RocList<u8>",
41+
ret_type: "roc_std::RocResult<roc_std::RocList<u8>,()>",
4242
},
4343
HostedFn {
4444
name: "stdoutLine",
4545
arg_types: &["&roc_std::RocStr"],
46-
ret_type: "()",
46+
ret_type: "roc_std::RocResult<(),RocStr>",
4747
},
4848
HostedFn {
4949
name: "stdoutWrite",
5050
arg_types: &["&roc_std::RocStr"],
51-
ret_type: "()",
52-
},
53-
HostedFn {
54-
name: "stdoutFlush",
55-
arg_types: &[],
56-
ret_type: "()",
51+
ret_type: "roc_std::RocResult<(),RocStr>",
5752
},
5853
HostedFn {
5954
name: "stderrLine",
6055
arg_types: &["&roc_std::RocStr"],
61-
ret_type: "()",
56+
ret_type: "roc_std::RocResult<(),RocStr>",
6257
},
6358
HostedFn {
6459
name: "stderrWrite",
6560
arg_types: &["&roc_std::RocStr"],
66-
ret_type: "()",
67-
},
68-
HostedFn {
69-
name: "stderrFlush",
70-
arg_types: &[],
71-
ret_type: "()",
61+
ret_type: "roc_std::RocResult<(),RocStr>",
7262
},
7363
HostedFn {
7464
name: "commandOutput",
7565
arg_types: &["&roc_app::InternalCommand"],
76-
ret_type: "roc_app::InternalOutput",
66+
ret_type: "roc_std::RocResult<roc_app::InternalOutput,()>",
7767
},
7868
HostedFn {
7969
name: "commandStatus",
@@ -83,45 +73,45 @@ const ROC_HOSTED_FNS: &[HostedFn] = &[
8373
HostedFn {
8474
name: "posixTime",
8575
arg_types: &[],
86-
ret_type: "roc_std::U128",
76+
ret_type: "roc_std::RocResult<roc_std::U128,()>",
8777
},
8878
HostedFn {
8979
name: "tcpConnect",
9080
arg_types: &["&roc_std::RocStr", "u16"],
91-
ret_type: "roc_app::ConnectResult",
81+
ret_type: "roc_std::RocResult<roc_app::ConnectResult,()>",
9282
},
9383
HostedFn {
9484
name: "tcpClose",
9585
arg_types: &["*mut std::io::BufReader<std::net::TcpStream>"],
96-
ret_type: "()",
86+
ret_type: "roc_std::RocResult<(),()>",
9787
},
9888
HostedFn {
9989
name: "tcpReadUpTo",
10090
arg_types: &["usize", "*mut std::io::BufReader<std::net::TcpStream>"],
101-
ret_type: "roc_app::ReadResult",
91+
ret_type: "roc_std::RocResult<roc_app::ReadResult,()>",
10292
},
10393
HostedFn {
10494
name: "tcpReadExactly",
10595
arg_types: &["usize", "*mut std::io::BufReader<std::net::TcpStream>"],
106-
ret_type: "roc_app::ReadExactlyResult",
96+
ret_type: "roc_std::RocResult<roc_app::ReadExactlyResult,()>",
10797
},
10898
HostedFn {
10999
name: "tcpReadUntil",
110100
arg_types: &["u8", "*mut std::io::BufReader<std::net::TcpStream>"],
111-
ret_type: "roc_app::ReadResult",
101+
ret_type: "roc_std::RocResult<roc_app::ReadResult,()>",
112102
},
113103
HostedFn {
114104
name: "tcpWrite",
115105
arg_types: &[
116106
"&roc_std::RocList<u8>",
117107
"*mut std::io::BufReader<std::net::TcpStream>",
118108
],
119-
ret_type: "roc_app::WriteResult",
109+
ret_type: "roc_std::RocResult<roc_app::WriteResult,()>",
120110
},
121111
HostedFn {
122112
name: "sleepMillis",
123113
arg_types: &["u64"],
124-
ret_type: "()",
114+
ret_type: "roc_std::RocResult<(),()>",
125115
},
126116
HostedFn {
127117
name: "fileWriteUtf8",

0 commit comments

Comments
 (0)