Skip to content

Commit

Permalink
Merge pull request #132 from ChainSafe/mkeil/fix-workflow
Browse files Browse the repository at this point in the history
fix: update workflow for new actions version
  • Loading branch information
matthewkeil authored Apr 9, 2024
2 parents b72dc89 + a42c701 commit 80dede6
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 914 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ jobs:
run: yarn test:spec

- name: Upload binding.node
uses: actions/upload-artifact@v4
if: github.repository_owner == 'chainsafe' && github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: binding.node
name: binding-${{ matrix.os }}-${{ matrix.node }}
path: prebuild/*.node
if-no-files-found: error

Expand Down Expand Up @@ -138,10 +138,10 @@ jobs:
docker cp temp-container:/usr/src/blst-ts/prebuild ./prebuild
- name: Upload binding.node
uses: actions/upload-artifact@v4
if: github.repository_owner == 'chainsafe' && github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: binding.node
name: binding-linux-arm-${{ matrix.node }}
path: prebuild/*.node
if-no-files-found: error

Expand All @@ -166,7 +166,7 @@ jobs:

publish:
needs: ["build", "build-arm"]
if: github.ref == 'refs/heads/master'
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -187,7 +187,7 @@ jobs:

- name: Create tag
id: tag
uses: butlerlogic/action-autotag@stable
uses: butlerlogic/action-autotag@1.1.2
with:
strategy: package
tag_prefix: "v"
Expand All @@ -203,8 +203,8 @@ jobs:
- name: Get pre-built binding.node files
uses: actions/download-artifact@v4
with:
name: binding.node
path: prebuild/
merge-multiple: true

- name: Install
run: yarn
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "yarn build:gyp && yarn build:ts",
"build:gyp": "node-gyp build",
"build:gyp:debug": "node-gyp build --debug",
"build:ts": "tsc --project tsconfig.build.json",
"build:ts": "tsc --project tsconfig.build.json && cp lib/index.d.ts dist/lib/index.d.ts",
"build:fuzz": "tsc --project tsconfig.fuzz.json",
"build:clean": "npm run clean && npm run install && npm run build:ts",
"dev": "ts-node tools/dev",
Expand Down Expand Up @@ -51,9 +51,6 @@
"tar": "^6.1.14",
"typescript": "^5.2.2"
},
"optionalDependencies": {
"@jazzer.js/core": "^2.1.0"
},
"main": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -83,4 +80,4 @@
"url": "https://github.com/ChainSafe/blst-ts/issues"
},
"homepage": "https://github.com/ChainSafe/blst-ts#readme"
}
}
3 changes: 2 additions & 1 deletion scripts/makeRelease.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {resolve} from "path";
import {cpSync, readdirSync, rmSync} from "fs";
import {mkdirSync, cpSync, readdirSync, rmSync} from "fs";
import {BINDINGS_FILE} from "../utils";

const RELEASE_FOLDER = resolve(__dirname, "..", "release");
const PREBUILD_FOLDER = resolve(__dirname, "..", "prebuild");

mkdirSync(RELEASE_FOLDER);
/**
* Reads through the files in the PREBUILD_FOLDER. Copies all to the
* RELEASE_FOLDER and then deletes the ones that are not slated for publishing
Expand Down
4 changes: 2 additions & 2 deletions test/fuzz/fuzz.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import fs from "fs";
import {resolve} from "path";
import {PromiseWithChild} from "child_process";
import {PromiseWithChild, execSync} from "child_process";
import {testCases} from "./testCases";
import {exec} from "../../utils";

Expand All @@ -28,7 +28,7 @@ if (!fs.existsSync(resolve(ROOT_DIR, "fuzz-tests", "test", "fuzz", "fuzzTarget.j
}

if (!fs.existsSync(resolve(ROOT_DIR, "node_modules", ".bin", "jazzer"))) {
throw new Error("optionalDependency jazzer not found. Run `yarn install`");
execSync("npm i --no-package-lock --no-save @jazzer.js/core", {stdio: "inherit"});
}

/**
Expand Down
13 changes: 9 additions & 4 deletions test/unit/PublicKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ describe("PublicKey", () => {
});
});
it("should throw on invalid key", () => {
expect(() => PublicKey.deserialize(sullyUint8Array(validPublicKey.compressed))).to.throw(
"BLST_ERROR::BLST_BAD_ENCODING"
);
expect(() => PublicKey.deserialize(badPublicKey)).to.throw("BLST_ERROR::BLST_BAD_ENCODING");
try {
PublicKey.deserialize(sullyUint8Array(validPublicKey.compressed));
expect.fail("Did not throw error for badPublicKey");
} catch (e) {
expect(
(e as Error).message === "BLST_ERROR::BLST_POINT_NOT_ON_CURVE" ||
(e as Error).message === "BLST_ERROR::BLST_BAD_ENCODING"
).to.be.true;
}
});
it("should throw on zero key", () => {
expect(() => PublicKey.deserialize(Buffer.from(G1_POINT_AT_INFINITY))).to.throw("BLST_BAD_ENCODING");
Expand Down
15 changes: 11 additions & 4 deletions test/unit/aggregatePublicKeys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ describe("Aggregate Public Keys", () => {
const agg = aggregatePublicKeys(keys);
expect(agg.keyValidate()).to.be.undefined;
});
it("should throw for invalid PublicKey", () => {
expect(() => aggregatePublicKeys(keys.concat(badPublicKey as unknown as PublicKey))).to.throw(
"BLST_ERROR::BLST_BAD_ENCODING: Invalid key at index 10"
);
it("should throw for invalid PublicKey", function () {
try {
aggregatePublicKeys(keys.concat(badPublicKey as unknown as PublicKey));
expect.fail("Did not throw error for badPublicKey");
} catch (e) {
expect((e as Error).message.startsWith("BLST_ERROR")).to.be.true;
expect(
(e as Error).message.includes("BLST_POINT_NOT_ON_CURVE") || (e as Error).message.includes("BLST_BAD_ENCODING")
).to.be.true;
expect((e as Error).message.endsWith("Invalid key at index 10")).to.be.true;
}
});
it("should return a key that is not in the keys array", () => {
const agg = aggregatePublicKeys(keys);
Expand Down
Loading

0 comments on commit 80dede6

Please sign in to comment.