Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not merge - ci: run sdk ci on multiple platforms #1650

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions .github/workflows/ci-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ concurrency:
cancel-in-progress: true

jobs:
build_and_test_sdk:
name: Build and test clarinet-sdk packages
build_wasm:
name: Build and test Wasm packages
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -43,18 +43,10 @@ jobs:
uses: actions/cache@v4
with:
path: |
~/.cargo/
~/target/release/build/
~/target/wasm32-unknown-unknown/build/
target/release/build/
target/wasm32-unknown-unknown/
key: clarinet-sdk-cargo-${{ runner.os }}-${{ env.RUST_VERSION_HASH }}-${{ hashFiles('./Cargo.lock') }}

- name: Cache npm
uses: actions/cache@v4
with:
path: |
~/node_modules/
key: clarinet-sdk-npm-${{ runner.os }}-${{ env.NODE_VERSION_HASH }}-${{ hashFiles('./package-lock.json') }}

- name: Install wasm-pack
run: npm install -g wasm-pack

Expand All @@ -64,6 +56,34 @@ jobs:
- name: Build Wasm packages
run: npm run build:sdk-wasm

- name: Upload Wasm artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-artifacts
path: components/clarinet-sdk-wasm/pkg-*

test:
name: Run clarinet-sdk tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
needs: build_wasm
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Download Wasm artifacts
uses: actions/download-artifact@v4
with:
name: wasm-artifacts
path: components/clarinet-sdk-wasm

- name: Install dependencies
run: npm ci

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions components/clarinet-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ serde-wasm-bindgen = { version = "0.6.4", optional = true }
wasm-bindgen = { workspace = true, optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
serde_json = "1.0.114"
web-sys = { workspace = true, features = ["console"], optional = true }


[features]
default = ["cli"]
cli = ["bitcoin", "clarity-repl/sdk"]
wasm = [
"js-sys",
"web-sys",
"serde-wasm-bindgen",
"wasm-bindgen",
"wasm-bindgen-futures",
Expand Down
8 changes: 7 additions & 1 deletion components/clarinet-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ impl FileLocation {
path.extend(&path_to_append);
}
FileLocation::Url { url } => {
#[cfg(target_arch = "wasm32")]
web_sys::console::log_1(&format!("url: {}", url).into());

let mut paths_segments = url
.path_segments_mut()
.map_err(|_| "unable to mutate url".to_string())?;
.map_err(|_| "unable to mutate url")?;
for component in path_to_append.components() {
let segment = component
.as_os_str()
Expand Down Expand Up @@ -264,6 +267,9 @@ impl FileLocation {
path.pop();
}
FileLocation::Url { url } => {
#[cfg(target_arch = "wasm32")]
web_sys::console::log_1(&format!("url: {}", url).into());

let mut segments = url
.path_segments_mut()
.map_err(|_| "unable to mutate url".to_string())?;
Expand Down
2 changes: 1 addition & 1 deletion components/clarinet-sdk/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"clean": "rimraf dist",
"compile": "tsc -b ./tsconfig.json",
"build": "npm run clean; npm run compile",
"build": "npm run clean && npm run compile",
"prepare": "npm run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion components/clarinet-sdk/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"scripts": {
"clean": "rimraf dist",
"compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json",
"build": "npm run clean; npm run compile; node ./scripts/prepare-esm-package.js",
"build": "npm run clean && npm run compile && node ./scripts/prepare-esm-package.js",
"prepare": "npm run build",
"pretest": "tsc -b ./tsconfig.json",
"test": "vitest run"
Expand Down
11 changes: 10 additions & 1 deletion components/clarinet-sdk/node/tests/simnet-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,18 @@ describe("the simnet can execute commands", () => {
});
});

describe("custom manifest path", () => {
it("initSimnet handles absolute path", async () => {
const manifestPath = path.join(process.cwd(), "tests/fixtures/Clarinet.toml");
const simnet = await initSimnet(manifestPath);
expect(simnet.blockHeight).toBe(1);
});
});

describe("the sdk handles multiple manifests project", () => {
it("handle invalid project", () => {
const manifestPath = path.join(process.cwd(), "tests/fixtures/contracts/invalid.clar");
// the lsp displays paths with the unix notation, hence why we are hardcoding the contract path with `/`
const manifestPath = `${process.cwd()}/tests/fixtures/contracts/invalid.clar`;
const expectedErr = `error: unexpected ')'\n--> ${manifestPath}:5:2\n)) ;; extra \`)\`\n`;

expect(async () => {
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"lint": "eslint ./client/src ./server/src",
"dev:watch": "webpack -c ./webpack.config.dev.js -w",
"dev:browser": "vscode-test-web --extensionDevelopmentPath=. ./test-data --open-devtools",
"dev": "webpack -c ./webpack.config.dev.js; concurrently \"npm:dev:*\"",
"vscode:prepublish": "npm run clean; NODE_ENV=production webpack",
"dev": "webpack -c ./webpack.config.dev.js && concurrently \"npm:dev:*\"",
"vscode:prepublish": "npm run clean && NODE_ENV=production webpack",
"vsce:package": "vsce package",
"vsce:publish": "vsce publish",
"vsce:prerelease": "vsce publish --pre-release"
Expand Down
Loading