Skip to content

Commit ab7023b

Browse files
authored
json repr (#8)
* json repr * update dist * align versions * align versions
1 parent 116eb42 commit ab7023b

File tree

13 files changed

+499
-90
lines changed

13 files changed

+499
-90
lines changed

.github/workflows/release.yml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# title/body based on your changelogs.
1313

1414
name: Release
15-
1615
permissions:
17-
contents: write
16+
"contents": "write"
1817

1918
# This task will run whenever you push a git tag that looks like a version
2019
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -62,7 +61,12 @@ jobs:
6261
# we specify bash to get pipefail; it guards against the `curl` command
6362
# failing. otherwise `sh` won't catch that `curl` returned non-0
6463
shell: bash
65-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.15.1/cargo-dist-installer.sh | sh"
64+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.20.0/cargo-dist-installer.sh | sh"
65+
- name: Cache cargo-dist
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: cargo-dist-cache
69+
path: ~/.cargo/bin/cargo-dist
6670
# sure would be cool if github gave us proper conditionals...
6771
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
6872
# functionality based on whether this is a pull_request, and whether it's from a fork.
@@ -111,9 +115,6 @@ jobs:
111115
- uses: actions/checkout@v4
112116
with:
113117
submodules: recursive
114-
- uses: swatinem/rust-cache@v2
115-
with:
116-
key: ${{ join(matrix.targets, '-') }}
117118
- name: Install cargo-dist
118119
run: ${{ matrix.install_dist }}
119120
# Get the dist-manifest
@@ -165,9 +166,12 @@ jobs:
165166
- uses: actions/checkout@v4
166167
with:
167168
submodules: recursive
168-
- name: Install cargo-dist
169-
shell: bash
170-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.15.1/cargo-dist-installer.sh | sh"
169+
- name: Install cached cargo-dist
170+
uses: actions/download-artifact@v4
171+
with:
172+
name: cargo-dist-cache
173+
path: ~/.cargo/bin/
174+
- run: chmod +x ~/.cargo/bin/cargo-dist
171175
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
172176
- name: Fetch local artifacts
173177
uses: actions/download-artifact@v4
@@ -211,16 +215,19 @@ jobs:
211215
- uses: actions/checkout@v4
212216
with:
213217
submodules: recursive
214-
- name: Install cargo-dist
215-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.15.1/cargo-dist-installer.sh | sh"
218+
- name: Install cached cargo-dist
219+
uses: actions/download-artifact@v4
220+
with:
221+
name: cargo-dist-cache
222+
path: ~/.cargo/bin/
223+
- run: chmod +x ~/.cargo/bin/cargo-dist
216224
# Fetch artifacts from scratch-storage
217225
- name: Fetch artifacts
218226
uses: actions/download-artifact@v4
219227
with:
220228
pattern: artifacts-*
221229
path: target/distrib/
222230
merge-multiple: true
223-
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
224231
- id: host
225232
shell: bash
226233
run: |
@@ -234,8 +241,29 @@ jobs:
234241
# Overwrite the previous copy
235242
name: artifacts-dist-manifest
236243
path: dist-manifest.json
244+
# Create a GitHub Release while uploading all files to it
245+
- name: "Download GitHub Artifacts"
246+
uses: actions/download-artifact@v4
247+
with:
248+
pattern: artifacts-*
249+
path: artifacts
250+
merge-multiple: true
251+
- name: Cleanup
252+
run: |
253+
# Remove the granular manifests
254+
rm -f artifacts/*-dist-manifest.json
255+
- name: Create GitHub Release
256+
env:
257+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
258+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
259+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
260+
RELEASE_COMMIT: "${{ github.sha }}"
261+
run: |
262+
# Write and read notes from a file to avoid quoting breaking things
263+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
264+
265+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
237266
238-
# Create a GitHub Release while uploading all files to it
239267
announce:
240268
needs:
241269
- plan
@@ -251,21 +279,3 @@ jobs:
251279
- uses: actions/checkout@v4
252280
with:
253281
submodules: recursive
254-
- name: "Download GitHub Artifacts"
255-
uses: actions/download-artifact@v4
256-
with:
257-
pattern: artifacts-*
258-
path: artifacts
259-
merge-multiple: true
260-
- name: Cleanup
261-
run: |
262-
# Remove the granular manifests
263-
rm -f artifacts/*-dist-manifest.json
264-
- name: Create GitHub Release
265-
uses: ncipollo/release-action@v1
266-
with:
267-
tag: ${{ needs.plan.outputs.tag }}
268-
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
269-
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
270-
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
271-
artifacts: "artifacts/*"

Cargo.lock

Lines changed: 47 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
[workspace]
2-
members = ["scout-interpreter", "scout-lexer", "scout-parser", "scout-worker"]
2+
members = ["scout-interpreter", "scout-json", "scout-lexer", "scout-parser", "scout-worker"]
33

44
# Config for 'cargo dist'
55
[workspace.metadata.dist]
66
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
7-
cargo-dist-version = "0.15.1"
7+
cargo-dist-version = "0.20.0"
88
# CI backends to support
99
ci = "github"
1010
# The installers to generate for each app
1111
installers = ["shell"]
1212
# Target platforms to build apps for (Rust target-triple syntax)
13-
targets = [
14-
"aarch64-apple-darwin",
15-
"x86_64-apple-darwin",
16-
"x86_64-unknown-linux-gnu",
17-
"x86_64-pc-windows-msvc",
18-
]
13+
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
1914
# Publish jobs to run in CI
2015
pr-run-mode = "plan"
2116
# Whether to install an updater program
2217
install-updater = false
18+
# Path that installers should place binaries in
19+
install-path = "CARGO_HOME"
2320

2421
[[bin]]
2522
name = "scout"

scout-interpreter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ keywords = [
1818

1919
[dependencies]
2020
scout-parser = { version = "0.6.0", path = "../scout-parser/" }
21+
scout-json = { version = "0.6", path = "../scout-json" }
2122
fantoccini = "0.19.3"
2223
futures = "0.3.30"
2324
serde = { version = "1.0", features = ["derive"] }

scout-interpreter/src/builtin.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub enum BuiltinKind {
5050
SetCookies,
5151
ToJson,
5252
HttpRequest,
53+
SetViewport,
5354
}
5455

5556
impl BuiltinKind {
@@ -77,6 +78,7 @@ impl BuiltinKind {
7778
"setCookies" => Some(SetCookies),
7879
"toJson" => Some(ToJson),
7980
"httpRequest" => Some(HttpRequest),
81+
"setViewport" => Some(SetViewport),
8082
_ => None,
8183
}
8284
}
@@ -149,6 +151,16 @@ impl BuiltinKind {
149151
_ => Err(EvalError::InvalidFnParams),
150152
}
151153
}
154+
SetViewport => {
155+
assert_param_len!(args, 2);
156+
match (&*args[0], &*args[1]) {
157+
(Object::Number(w), Object::Number(h)) => {
158+
crawler.set_window_size(*w as u32, *h as u32).await?;
159+
Ok(Arc::new(Object::Null))
160+
}
161+
_ => Err(EvalError::InvalidFnParams),
162+
}
163+
}
152164
ToJson => {
153165
assert_param_len!(args, 1);
154166
let json = args[0].to_json().await;

0 commit comments

Comments
 (0)