-
Notifications
You must be signed in to change notification settings - Fork 34
Add release canary test #525
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2825d04
Add release canary test
br-lewis 84f6a67
Switch to a test run on each PR
br-lewis 7b11e03
Fix some unnecessary duplication of work
br-lewis 9329a70
Fix github action and reformat readme
br-lewis d80368f
Add language to code block
br-lewis 0cf490d
Remove unnecessary include
br-lewis befd966
Merge branch 'main' into FUZZ-747-release-test
br-lewis ef92402
Remove registry-url
br-lewis cbf97b2
Remove jazzerjsrc
br-lewis 8a14d2e
Merge branch 'main' into FUZZ-747-release-test
br-lewis bc2c6a8
Fix lint error
br-lewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| **/package-lock.json | ||
| **/.cifuzz-corpus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Jazzer End to End Canary Test | ||
|
|
||
| This is the code from `examples/jest_typescript_integration` with a single | ||
| change to `package.json`: the Jazzer.js dependencies now come from | ||
| `jazzer-js-<package name>.tgz` files in this directory. These can be created by | ||
| running `./package-jazzer-js.sh` which will call `npm pack` on the Jazzer | ||
| packages so that we can test for any packaging errors. | ||
|
|
||
| The Typescript integration example was chosen as that should exercise more of | ||
| jazzer.js than the other examples. | ||
|
|
||
| ## Running Locally | ||
|
|
||
| ```bash | ||
| ./package-jazzer-js.sh | ||
| npm install --save-dev *.tgz | ||
| npx jest | ||
| ``` | ||
|
|
||
| _Note_: running just `npm install` may result in caching issues where the | ||
| contents of the tarballs in this directory are ignored and older versions from | ||
| somewhere are used instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Copyright 2023 Code Intelligence GmbH | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import "@jazzer.js/jest-runner"; | ||
| import * as target from "./target"; | ||
|
|
||
| describe("Target", () => { | ||
| it.fuzz("executes sync methods", (data: Buffer) => { | ||
| target.fuzzMe(data); | ||
| }); | ||
|
|
||
| it.fuzz("executes async methods", async (data: Buffer) => { | ||
| await target.asyncFuzzMe(data); | ||
| }); | ||
|
|
||
| it.fuzz( | ||
| "executes methods with a done callback", | ||
| (data: Buffer, done: (e?: Error) => void) => { | ||
| target.callbackFuzzMe(data, done); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright 2023 Code Intelligence GmbH | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as target from "./target"; | ||
|
|
||
| describe("My describe", () => { | ||
| it("My normal Jest test", () => { | ||
| expect(1).toEqual(1); | ||
| }); | ||
|
|
||
| it("My done callback Jest test", (done) => { | ||
| expect(1).toEqual(1); | ||
| done(); | ||
| }); | ||
|
|
||
| it("My async Jest test", async () => { | ||
| expect(1).toEqual(1); | ||
| }); | ||
|
|
||
| it("Test target function", () => { | ||
| const data = Buffer.from("a"); | ||
| target.fuzzMe(data); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright 2023 Code Intelligence GmbH | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import type { Config } from "jest"; | ||
|
|
||
| const config: Config = { | ||
| verbose: true, | ||
| projects: [ | ||
| { | ||
| displayName: "Jest", | ||
| preset: "ts-jest", | ||
| }, | ||
| { | ||
| displayName: { | ||
| name: "Jazzer.js", | ||
| color: "cyan", | ||
| }, | ||
| preset: "ts-jest", | ||
| runner: "@jazzer.js/jest-runner", | ||
| testEnvironment: "node", | ||
| testMatch: ["<rootDir>/*.fuzz.[jt]s"], | ||
| }, | ||
| ], | ||
| coveragePathIgnorePatterns: ["/node_modules/", "/dist/"], | ||
| modulePathIgnorePatterns: ["/node_modules", "/dist/"], | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/sh | ||
|
|
||
| cd .. | ||
| npm install | ||
| npm run build | ||
| npm run build --workspace='@jazzer.js/fuzzer' | ||
bertschneider marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| sed_version_and_mv() { | ||
bertschneider marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| while read data; do | ||
| local no_version=$(echo $data | sed -r -f end-to-end/remove-version.sed) | ||
| echo "mv $data end-to-end/$no_version" | ||
| mv $data end-to-end/$no_version | ||
| done | ||
| } | ||
|
|
||
| npm pack --workspaces | sed_version_and_mv | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "jest_typescript_integration", | ||
| "version": "1.0.0", | ||
| "description": "An example showing how Jazzer.js integrates with Jest and TypeScript", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "dryRun": "jest", | ||
| "fuzz": "JAZZER_FUZZ=1 jest --coverage", | ||
| "coverage": "jest --coverage" | ||
| }, | ||
| "devDependencies": { | ||
| "@jazzer.js/bug-detectors": "file:jazzer.js-bug-detectors.tgz", | ||
| "@jazzer.js/core": "file:jazzer.js-core.tgz", | ||
| "@jazzer.js/fuzzer": "file:jazzer.js-fuzzer.tgz", | ||
| "@jazzer.js/hooking": "file:jazzer.js-hooking.tgz", | ||
| "@jazzer.js/instrumentor": "file:jazzer.js-instrumentor.tgz", | ||
| "@jazzer.js/jest-runner": "file:jazzer.js-jest-runner.tgz", | ||
| "@types/jest": "^29.4.0", | ||
| "jest": "^29.4.1", | ||
| "ts-jest": "^29.0.5", | ||
| "ts-node": "^10.9.1", | ||
| "typescript": "^4.9.5" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| s/-[0-9]+\.[0-9]+\.[0-9]+\.tgz/\.tgz/g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Copyright 2023 Code Intelligence GmbH | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| export function fuzzMe(data: Buffer) { | ||
| const s = data.toString(); | ||
| if (s.length !== 16) { | ||
| return; | ||
| } | ||
| if ( | ||
| s.slice(0, 8) === "Awesome " && | ||
| s.slice(8, 15) === "Fuzzing" && | ||
| s[15] === "!" | ||
| ) { | ||
| throw Error("Welcome to Awesome Fuzzing!"); | ||
| } | ||
| } | ||
|
|
||
| export function callbackFuzzMe(data: Buffer, done: (e?: Error) => void) { | ||
| // Use setImmediate here to unblock the event loop but still have better | ||
| // performance compared to setTimeout. | ||
| setImmediate(() => { | ||
| try { | ||
| fuzzMe(data); | ||
| done(); | ||
| } catch (e: unknown) { | ||
| if (e instanceof Error) { | ||
| done(e); | ||
| } else { | ||
| done(new Error(`Error: ${e}`)); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| export async function asyncFuzzMe(data: Buffer) { | ||
| return new Promise((resolve, reject) => { | ||
| callbackFuzzMe(data, (e?: Error) => { | ||
| if (e) { | ||
| reject(e); | ||
| } else { | ||
| resolve(null); | ||
| } | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "NodeNext", | ||
| "moduleResolution": "node", | ||
| "allowJs": true, | ||
| "rootDir": ".", | ||
| "outDir": "./dist", | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "declaration": true, | ||
| "composite": true, | ||
| "sourceMap": true | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.