Open jamiebrynes7 opened 4 years ago
Some extra information, logging the error thrown by JSON.parse()
(https://github.com/jamiebrynes7/clippy-check/commit/100d2c352ba28cfacff399198d057a7e8731a557#diff-5fa83cff45c4b6ef3a61b59b784d45e4R73) yields the following for seemingly each JSON parsing failure:
##[debug]SyntaxError: Unexpected token , in JSON at position 0
I noticed on a PR (https://github.com/jamiebrynes7/spatialos-sdk-rs/pull/136) that GitHub actions was reporting that the Clippy step was failing, but no errors were being reported.
After turning on debug output, each clippy lint is followed by:
Example
This line originates from https://github.com/actions-rs/clippy-check/blob/master/src/check.ts#L70 where we attempt to parse each line of standard output as JSON.
Manually checking the JSON output from clippy, it seems to be valid.
Example JSON output (prettified)
```json { "reason": "compiler-message", "package_id": "spatialos-sdk 0.0.0 (path+file:///Users/runner/runners/2.161.0/work/spatialos-sdk-rs/spatialos-sdk-rs/spatialos-sdk)", "target": { "kind": ["lib"], "crate_types": ["lib"], "name": "spatialos-sdk", "src_path": "/Users/runner/runners/2.161.0/work/spatialos-sdk-rs/spatialos-sdk-rs/spatialos-sdk/src/lib.rs", "edition": "2018", "doctest": true }, "message": { "rendered": "error: transmute from a type (`f32`) to itself\n --> spatialos-sdk/src/worker/schema/primitives.rs:41:33\n |\n41 | Ok(unsafe { mem::transmute($schema_get(object.as_ptr(), field)) })\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n86 | / impl_primitive_field!(\n87 | | f32,\n88 | | SchemaFloat,\n89 | | Schema_GetFloat,\n... |\n93 | | Schema_AddFloatList,\n94 | | );\n | |__- in this macro invocation\n |\n = note: `-D clippy::useless-transmute` implied by `-D warnings`\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute\n\n", "children": [{ "children": [], "code": null, "level": "note", "message": "`-D clippy::useless-transmute` implied by `-D warnings`", "rendered": null, "spans": [] }, { "children": [], "code": null, "level": "help", "message": "for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute", "rendered": null, "spans": [] }], "code": { "code": "clippy::useless_transmute", "explanation": null }, "level": "error", "message": "transmute from a type (`f32`) to itself", "spans": [{ "byte_end": 1794, "byte_start": 1743, "column_end": 84, "column_start": 33, "expansion": { "def_site_span": { "byte_end": 3377, "byte_start": 1191, "column_end": 2, "column_start": 1, "expansion": null, "file_name": "spatialos-sdk/src/worker/schema/primitives.rs", "is_primary": false, "label": null, "line_end": 84, "line_start": 23, "suggested_replacement": null, "suggestion_applicability": null, "text": [{ "highlight_end": 36, "highlight_start": 1, "text": "macro_rules! impl_primitive_field {" }, { "highlight_end": 6, "highlight_start": 1, "text": " (" }, { "highlight_end": 23, "highlight_start": 1, "text": " $rust_type:ty," }, { "highlight_end": 28, "highlight_start": 1, "text": " $schema_type:ident," }, { "highlight_end": 27, "highlight_start": 1, "text": " $schema_get:ident," }, { "highlight_end": 29, "highlight_start": 1, "text": " $schema_index:ident," }, { "highlight_end": 29, "highlight_start": 1, "text": " $schema_count:ident," }, { "highlight_end": 27, "highlight_start": 1, "text": " $schema_add:ident," }, { "highlight_end": 32, "highlight_start": 1, "text": " $schema_add_list:ident," }, { "highlight_end": 11, "highlight_start": 1, "text": " ) => {" }, { "highlight_end": 25, "highlight_start": 1, "text": " #[derive(Debug)]" }, { "highlight_end": 33, "highlight_start": 1, "text": " pub struct $schema_type;" }, { "highlight_end": 1, "highlight_start": 1, "text": "" }, { "highlight_end": 38, "highlight_start": 1, "text": " impl Field for $schema_type {" }, { "highlight_end": 40, "highlight_start": 1, "text": " type RustType = $rust_type;" }, { "highlight_end": 1, "highlight_start": 1, "text": "" }, { "highlight_end": 82, "highlight_start": 1, "text": " fn get(object: &SchemaObject, field: FieldId) -> Result<$rust_type> {" }, { "highlight_end": 52, "highlight_start": 1, "text": " if Self::count(object, field) > 0 {" }, { "highlight_end": 87, "highlight_start": 1, "text": " Ok(unsafe { mem::transmute($schema_get(object.as_ptr(), field)) })" }, { "highlight_end": 25, "highlight_start": 1, "text": " } else {" }, { "highlight_end": 56, "highlight_start": 1, "text": " Err(Error::missing_field::As far as I can tell, this JSON output matches the interfaces defined in https://github.com/actions-rs/clippy-check/blob/master/src/check.ts#L10
I'm not very familiar with Typescript or the semantics of
JSON.parse
and how@actions/exec
(https://github.com/actions/toolkit/tree/master/packages/exec) pipes standard output through, so despite my best efforts I'm struggling to drill down to the root of this.I'm using Rust 1.39.0 and the clippy action is running on the
macOS-latest
machine.