Giter Club home page Giter Club logo

Comments (9)

p-rogalski avatar p-rogalski commented on June 16, 2024 1

I tested the new regex and it works as expected, thank you very much for your effort in fixing this. 🚀

from check-jsonschema.

sirosen avatar sirosen commented on June 16, 2024

You can control the regex engine being used by passing --format-regex python to use the Python re engine for regex patterns. There's only support for Python re and regress (a Rust implementation of ECMAScript regexes) today, but I'd be fine with adding others if there are reliable libraries to use.
(By way of example: the Python regex package may perform better than re, and I might like to build in support for that.)

Under pre-commit, it's just a matter of adding args. This should do the trick:

- repo: https://github.com/python-jsonschema/check-jsonschema
  rev: 0.28.0
  hooks:
    - id: check-gitlab-ci
      args: ["--format-regex", "python"]

But definitely this is an issue with the GItLab schema. JSON Schema (the spec) declares that ECMA Script regex syntax or a strict subset of it -- compatible with most languages/engines -- should be used for regexes.

I'll leave this open until I can cross-link a relevant open ticket on GitLab's tracker.

from check-jsonschema.

sirosen avatar sirosen commented on June 16, 2024

I just checked the GitLab schema and found that the regex you cited is not the one I see in their schema (or in our vendored copy).

What version of check-jsonschema are you using? The latest (0.28.0)?

from check-jsonschema.

p-rogalski avatar p-rogalski commented on June 16, 2024

Thanks for your quick reply!

I just checked the GitLab schema and found that the regex you cited is not the one I see in their schema (or in our vendored copy). What version of check-jsonschema are you using? The latest (0.28.0)?

I'm using version 0.28.0 of check-jsonschema. These are the lines in the gitlab-ci json schema I'm talking about: https://gitlab.com/gitlab-org/gitlab/-/blob/50724a13fa9bbfdd358079094930e7026c5d48f2/app/assets/javascripts/editor/schema/ci.json?page=2#L1965-L1970

from check-jsonschema.

p-rogalski avatar p-rogalski commented on June 16, 2024

Under pre-commit, it's just a matter of adding args.

I missed that. Unfortunately, this doesn't work either. I will provide you with a minimal reproduction repo shortly!

from check-jsonschema.

sirosen avatar sirosen commented on June 16, 2024

I misunderstood the original issue -- sorry about this -- from reading the report too quickly.
I thought you were reporting that the gitlab-ci schema contained the problematic regex. But actually, it contains a simple regex -- /.+/ -- which your regex must match.
And that regex comes from gitlab docs.

I'll file a GitLab issue to either correct the schema OR correct their example.
If I had to guess, I would bet they meant for it to be

/[Tt][Oo][Tt][Aa][Ll].*? (100(?:\\.0+)?\\%|[1-9]?\\d(?:\\.\\d+)?\\%)$/

from check-jsonschema.

sirosen avatar sirosen commented on June 16, 2024

I've filed a gitlab docs issue suggesting the above regex as a docs fix, to see what kind of response I'll get from GitLab:
https://gitlab.com/gitlab-org/gitlab-docs/-/issues/1763

Feel free to 👍 it to signal boost, or just try using that regex and seeing how it works.

from check-jsonschema.

p-rogalski avatar p-rogalski commented on June 16, 2024

@sirosen Thank you very much for opening the issue, you certainly have better insight to this!

from check-jsonschema.

sirosen avatar sirosen commented on June 16, 2024

GitLab has accepted my docs suggestion and their new documented value should validate fine. I've closed out the upstream gitlab bug and I think this is all set. let me know if you see any issues!

from check-jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.