Skip to content

Conversation

@PatrykWalach
Copy link
Member

@PatrykWalach PatrykWalach commented Dec 21, 2024

Supersedes #290

@PatrykWalach PatrykWalach changed the title Generate-json-schema-rebase Generate schema for isograph.config.json Dec 21, 2024
Copy link
Collaborator

@rbalicki2 rbalicki2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing, love it, just a few nits

Self::Error
}
}
pub fn generate_json_schema_config() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to main.rs? Seems weird to have side effectful functions here

- name: Build
run: pnpm -r compile
- name: Build json schema
run: pnpm build-json-schema
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • let's instead have a step where we ensure that the checked in isograph-config-schema.json file is unchanged after we run build-json-schema, and have this run as a dependency of all-checks-passed

Copy link
Collaborator

@rbalicki2 rbalicki2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you able to get validation to work with a path that starts with ..? If I copy-paste isograph-config-schema.json into the same folder as the isograph.config.json file, I can get vscode to validate it correctly, but if I have it in ../../whatever, it shows Unable to parse content from '/Users/rbalicki/code/isograph/libs/isograph-compiler/isograph-config-schema.json': Parse error at offset 0.

Do you see this?

path: artifacts/linux-x64
- name: Make artifact executable
run: chmod +x ./artifacts/linux-x64/isograph_config
- name: 'Build json schema'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you use single quotes a bunch, but I think they aren't really necessary?

if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.json-schema-artifact-name }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like we're not using the artifact, except for ubuntu-latest (i.e. as part of build-cli-linux). Can we avoid building and uploading this for the other platforms?

TBH I think it's sufficient to check that the output is the same in ubuntu-latest.

#[derive(Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
struct ConfigFile {
pub struct ConfigFile {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes title: "ConfigFile" in the schema file, can we change that to IsographProjectConfig or something?

@PatrykWalach
Copy link
Member Author

PatrykWalach commented Dec 23, 2024

I do get Unable to parse content error but it's not limited to isograph, I get it in my relay project where I use ./node_modules/relay-compiler/relay-compiler-config-schema.json so maybe it's a vs code bug. It used to work just fine.

@rbalicki2
Copy link
Collaborator

re: vscode not accepting it, sgtm

**/.docusaurus/**
**/dist/**
**/relay-crates/**
isograph-config-schema.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we should ignore the json file? It seems like we should always check in the latest version, just like we ensure that the demo artifacts are current (etc)

Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is prettier ignore, we don't format any of the artifacts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, you're right

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess, why are we uploading the artifact (on linux)?

The way I see it, we have the artifact checked in, so instead of uploading and downloading it, we can just use the checked in version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To check if it's been built before check-in

Copy link
Collaborator

@rbalicki2 rbalicki2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFGGG looks great

@rbalicki2 rbalicki2 merged commit ede6bd4 into isographlabs:main Dec 25, 2024
16 of 21 checks passed
PatrykWalach added a commit to PatrykWalach/isograph that referenced this pull request Jan 6, 2025
- generate a JSON schema for `isograph.config.json`, which users can then refer to via `"$schema": "path to schema"` for some added type safety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants