Skip to content

Commit 7572cf2

Browse files
committed
Updated READMEs and deps. Implemented Go to References.
1 parent 5c250a4 commit 7572cf2

32 files changed

+2846
-53
lines changed

.github/workflows/lsp-ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: LSP CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'lsp/**'
7+
- '.github/workflows/lsp-ci.yml'
8+
push:
9+
branches:
10+
- master
11+
paths:
12+
- 'lsp/**'
13+
- '.github/workflows/lsp-ci.yml'
14+
15+
jobs:
16+
fmt:
17+
name: Rustfmt (lsp)
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Rust (stable)
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: rustfmt
27+
28+
- name: Check formatting
29+
working-directory: lsp
30+
run: cargo fmt --all -- --check
31+
32+
clippy:
33+
name: Clippy (lsp)
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Rust (stable)
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
components: clippy
43+
44+
- name: Run clippy
45+
working-directory: lsp
46+
run: cargo clippy --all-targets --all-features
47+
48+
tests:
49+
name: Tests (lsp)
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Setup Rust (stable)
56+
uses: dtolnay/rust-toolchain@stable
57+
58+
- name: Run tests
59+
working-directory: lsp
60+
run: cargo test --all-features -- --nocapture
61+
62+

.github/workflows/publish-lsp.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Publish simplicityhl-lsp
2+
3+
on:
4+
push:
5+
tags:
6+
- 'simplicityhl-lsp-v*'
7+
workflow_dispatch: {}
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
lint:
13+
name: Lint (lsp)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Rust (stable)
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: clippy, rustfmt
23+
24+
- name: Rustfmt check
25+
working-directory: lsp
26+
run: cargo fmt --all -- --check
27+
28+
- name: Clippy
29+
working-directory: lsp
30+
run: cargo clippy --all-targets --all-features -D warnings
31+
32+
tests:
33+
name: Tests (lsp)
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Rust (stable)
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Run tests
43+
working-directory: lsp
44+
run: cargo test --all-features -- --nocapture
45+
46+
publish:
47+
name: Publish simplicityhl-lsp to crates.io
48+
needs: [lint, tests]
49+
runs-on: ubuntu-latest
50+
environment: release
51+
concurrency:
52+
group: publish-lsp-${{ github.ref }}
53+
cancel-in-progress: false
54+
permissions:
55+
id-token: write
56+
contents: read
57+
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Rust (stable)
63+
uses: actions-rust-lang/setup-rust-toolchain@v1
64+
with:
65+
toolchain: stable
66+
67+
- name: Verify tag matches crate version
68+
shell: bash
69+
run: |
70+
set -euo pipefail
71+
TAG="${GITHUB_REF##*/}"
72+
VERSION_TAG="${TAG#simplicityhl-lsp-v}"
73+
CRATE_VERSION=$(cargo metadata --manifest-path lsp/Cargo.toml --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="simplicityhl-lsp").version')
74+
echo "Tag version: $VERSION_TAG"
75+
echo "Crate version: $CRATE_VERSION"
76+
if [ "$VERSION_TAG" != "$CRATE_VERSION" ]; then
77+
echo "Tag version ($VERSION_TAG) does not match crate version ($CRATE_VERSION)"
78+
exit 1
79+
fi
80+
81+
- name: Check package
82+
working-directory: lsp
83+
run: cargo package
84+
85+
- name: Authenticate with crates.io
86+
id: auth
87+
uses: rust-lang/crates-io-auth-action@v1
88+
89+
- name: Publish
90+
env:
91+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
92+
working-directory: lsp
93+
run: cargo publish
94+
95+

.github/workflows/rust.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,23 @@ jobs:
169169
uses: dtolnay/rust-toolchain@stable
170170
- run: rustup target add wasm32-unknown-unknown
171171
- run: cargo check --target wasm32-unknown-unknown
172+
173+
Fuzz:
174+
name: Check Fuzz
175+
needs: Prepare
176+
runs-on: ubuntu-latest
177+
strategy:
178+
fail-fast: false
179+
steps:
180+
- name: "Checkout repo"
181+
uses: actions/checkout@v4
182+
183+
- name: "Select nightly toolchain"
184+
uses: dtolnay/rust-toolchain@v1
185+
with:
186+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
187+
188+
- name: "Check fuzz crate"
189+
run: |
190+
cargo check --manifest-path=fuzz/Cargo.toml
191+

Cargo.lock

Lines changed: 39 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ clap = "4.5.37"
3838
getrandom = { version = "0.2", features = ["js"] }
3939

4040
[workspace]
41-
members = ["codegen"]
42-
exclude = ["fuzz", "bitcoind-tests"]
41+
members = ["codegen", "fuzz"]
42+
exclude = ["bitcoind-tests", "lsp"]
4343

4444
[lints.clippy]
4545
# Exclude lints we don't think are valuable.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Take a look at the [example programs](https://github.com/BlockstreamResearch/Sim
2020

2121
## MSRV
2222

23-
This crate should compile with any feature combination on **Rust 1.78.0** or higher.
23+
This crate should compile with any feature combination on **Rust 1.79.0** or higher.
2424

2525
## Simplicity's need for a high-level language
2626

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
msrv = "1.78.0"
1+
msrv = "1.79.0"
22
# We have an error type, `RichError`, of size 144. This is pushing it but probably fine.
33
large-error-threshold = 145
44

fuzz/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ simplicityhl = { path = "..", features = ["arbitrary", "serde"] }
1414
itertools = "0.13.0"
1515
serde_json = "1.0.105"
1616

17+
[dev-dependencies]
18+
base64 = "0.22.1"
19+
20+
[lints.rust]
21+
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(fuzzing)'] }
22+
1723
[[bin]]
1824
name = "compile_text"
1925
path = "fuzz_targets/compile_text.rs"

fuzz/fuzz_targets/compile_parse_tree.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#![no_main]
1+
#![cfg_attr(fuzzing, no_main)]
22

3-
use arbitrary::Arbitrary;
4-
use libfuzzer_sys::fuzz_target;
3+
#[cfg(any(fuzzing, test))]
4+
fn do_test(data: &[u8]) {
5+
use arbitrary::Arbitrary;
56

6-
use simplicityhl::error::WithFile;
7-
use simplicityhl::{ast, named, parse, ArbitraryOfType, Arguments};
7+
use simplicityhl::error::WithFile;
8+
use simplicityhl::{ast, named, parse, ArbitraryOfType, Arguments};
89

9-
fuzz_target!(|data: &[u8]| {
1010
let mut u = arbitrary::Unstructured::new(data);
1111
let parse_program = match parse::Program::arbitrary(&mut u) {
1212
Ok(x) => x,
@@ -24,6 +24,24 @@ fuzz_target!(|data: &[u8]| {
2424
.compile(arguments, false)
2525
.with_file("")
2626
.expect("AST should compile with given arguments");
27-
let _simplicity_commit = named::to_commit_node(&simplicity_named_construct)
28-
.expect("Conversion to commit node should never fail");
29-
});
27+
let _simplicity_commit = named::forget_names(&simplicity_named_construct);
28+
}
29+
30+
#[cfg(fuzzing)]
31+
libfuzzer_sys::fuzz_target!(|data| do_test(data));
32+
33+
#[cfg(not(fuzzing))]
34+
fn main() {}
35+
36+
#[cfg(test)]
37+
mod tests {
38+
use base64::Engine;
39+
40+
#[test]
41+
fn duplicate_crash() {
42+
let data = base64::prelude::BASE64_STANDARD
43+
.decode("Cg==")
44+
.expect("base64 should be valid");
45+
super::do_test(&data);
46+
}
47+
}

0 commit comments

Comments
 (0)