feat: detect QLTY_COVERAGE_TOKEN env var#1139
feat: detect QLTY_COVERAGE_TOKEN env var#1139brynary wants to merge 2 commits intosimplecov-ruby:mainfrom
Conversation
|
In my view, this illustrates why it was probably a mistake to hardcode hooks for a specific commercial product. I would sooner remove support for |
|
Hi Erik -- Hope you're well! I don't have a strong opinion on the core question -- I actually didn't fully realize that this hook was in simplecov-ruby until we had users experiencing breakages. If there's anything we can do to make supporting this compatibility easier, we would be happy to do that. My primary concern is breakages for users. (We do offer a commercial product, and we also provide free services to OSS projects who often have less maintenance resources available to them.) Cheers, -Bryan |
|
Looking at the history of this feature, it appears to have come from My preferred approach going forward would be deprecating support for that environment variable (with a warning message) in favor of a generic environment variable (something like @brynary Would this solve the problem for your customers? I understand it would require them setting two environment variables instead of just one, but maybe QLTY could set this variable by default in Ruby projects that bundle |
|
Ok, booting back up on this, thanks for the patience. This is my best understanding... Over-simplifying a bit, but basically the way people setup code coverage reporting in a CI setting has historically been along the lines of: # CI workflow pseudo code
env:
CC_TEST_REPORTER_ID: "random_string" # Or now QLTY_COVERAGE_TOKEN
steps:
run: rake test
run: upload_coverage_dataThere are ~tens of thousands of CI workflows checked into version control across private and open source projects. Unfortunately, we don't have the ability to modify them. Critically, we don't have a hook to be able to set environment variables for the So today, simplecov-ruby will see the presence of If This surfaced to us because a customer replaced Given the above, if simplecov-ruby stopped recognizing |
|
N.b. I did not propose removing the I am proposing your users migrate to something like this: env:
QLTY_COVERAGE_TOKEN: "random string"
SIMPLECOV_JSON_FORMATTER: "true"
steps:
run: rake test
run: upload_coverage_dataI imagine that the Alternatively, your users could do something like this, before calling if ENV["CC_TEST_REPORTER_ID"] || ENV["QLTY_COVERAGE_TOKEN"]
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
else
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
endI suspect something like this is what your competitors require of their customers. Another possible approach is if |
Makes sense, and thanks for clarifying! I was just booting back into this and trying to sort through what the impact would be if/when a deprecation became a removal.
I think that's a reasonable approach! Do you feel like this kind of enabling behavior on vendor-specific environment variables has caused issues for simplecov users or maintainers?
Unfortunately I don't think we could do this because there are many non-simplecov cases where someone sets
Yes, we can update our setup procedures to reflect this.
Yes, I think this would create headaches for everyone because an HTML change would risk becoming a breaking change. The JSON format helps avoid incidental wire breakages as it's inherently more of a contract than HTML. As far as alternative ideas, one random idea would be: Would it be reasonable is Simplecov generated JSON by default? I'm not prepared to recommend that, but some coverage generation tools will output a machine-readable coverage report (e.g. a |
|
(Just split out the docs-only part of this to #1162 for convenience.) |
Merged!
No, it hasn’t caused a significant maintenance burden, but if one (or two or five) of your competitors open similar pull requests, I want to be able to credibly deny them without looking like I’m showing favoritism to you, Bryan, who I know and like. 😄 Think of it like defensive programming for GitHub Issues. It’s not a problem now, but I have a clear idea of how it could become a problem and am trying to nip it in the bud.
I need to think a bit more about this, but on first thought, I like this idea! Two options I’d consider:
Curious if you have a preference between either of these two options (or perhaps you had a third one in mind). |
|
Alright here it goes. I will preface this by saying that @sferik did the recent work here, and so it's his call. Historical Context
Merging the JSON formatter means more maintenance for any current or future maintainers of simplecov. Running it for everyone means we spend resources on everyone's machine. Because a company didn't want to add setup instructions for using their tool. Why are we doing this?From where I'm standing we're doing this essentially because a company refused to add setup instructions for how to use their product. And now we've further pushed the maintenance burden of features onto unpaid volunteers, to support the functioning of a money making product. This all started because code climate started relying on an undocumented implementation detail, never meant for consumption, without collaborating with the open source team. What could code climate have done instead?
This whole also sets a dangerous precedent, as Erik mentioned above. Why are we doing things to cater to one specific provider? What if another asks for stuff? What if the requirements conflict? Why are we taking on work (the JSON formatter) that as best as I know was only asked for for this? Why spend my volunteer time on this? The interactions I've had with code climate on this have been the anti-thesis of how I believe companies should collaborate with open source. There wasn't collaboration, but there was pushing work on open source projects - who are already under staffed (as you can see with the amount of issues simplecov has to deal with). I say this as someone, who used recommend people to use code climate. Why it's bad to run the JSON formatter by defaultFirst, I care about performance - no code runs faster than no code. You may benchmark it and say it's not that much, you may be right but multiply it by all the people who run simplecov locally or on CI every day (and some huge code bases like f.ex. Shopify push surprising limits there). Huge waste of time and energy. Second, the not run unnecessary code part is not just due to performance but also due to stability. All code has bugs, maybe even crashes. More code run = more possible crashes. Security wise, it also means more possible exploits. So, do we want to potentially fail people's CI for a feature they never asked for or wanted? Now there are common counter arguments:
SummaryI'd strongly prefer for code climate to update their instructions to configure the JSON formatter to run vs. us running it by default. This should be opt-in. But, I'm also saying that I don't think I have a huge say in this through my inactivity in recent years. I did want to provide my input and historical context though, as well as thoughts about how companies work with and use OSS. |
|
@PragTob thank you for writing this all out. This history is genuinely useful, and I want to start by acknowledging how much of SimpleCov exists because of your work. You carried this project for years, and the fact that I'm even in a position to propose changes to it is because you kept the lights on. I agree that the “original sin” was taking on
I’m not going to address your post point-by-point, but on this concern specifically, I think it’s worth clarifying, because that’s not what #1165 does. The JSON is never parsed back into Ruby. The two formatters share a single I expect the combined JSON + HTML pipeline in #1165 to be faster than the old HTML-only pipeline—even on very large projects. If you know someone as Shopify or another large Ruby app who is willing to verify this before I merge it, I’m happy to wait for the results. Independent of anything related to Code Climate/Qlty, I think treating JSON as the data layer and HTML as a view over it is just the right direction for this tool. JSON is the lingua franca for interop. Making I came into this without any of the historical context you shared, and I appreciate you taking the time to write it down rather than just letting the frustration sit. My hope is that, with the formatter merged and owned by us, and with a documented JSON contract that any vendor can target, we can bury the hatchet and move forward as a community. Any future vendor gets the same deal: target the public Thanks again for chiming in. Your input carries a lot of weight with me personally and it’s important to me to evolve this project with your blessing. |
|
Hi @PragTob -- (Code Climate founder here.) I just wanted to chime and and convey an apology for Code Climate inflicting additional maintenance burden on you and SimpleCov. The history spans over a decade at this point, and across a period of time when I was not personally involved in that engineering work, so I don't have direct exposure to the specifics, but based on your description the fact that it was a negative impact is apparent to me now. (And was not known to me personally, prior to today, unfortunately.) I imagine a well-intentioned engineer saw the I was not a party to the conversation you mentioned about how to evolve past that original sin, which sounds like an additional layer of frustration on top of a problem we created. Across all programming languages, test coverage collection setup has historically (especially pre-AI) been a challenge for our users to get right -- That's not a deficiency of coverage tools, just a challenge of getting things right in varied and complex CI environments. I could imagine (hope) that the pushback you felt was driven by I-would-assume-well-intentioned-but-potentially-myopic focus on avoiding breakages for customers and OSS projects who had gone through the setup process (which number in the ~10ks), but that's essentially speculation. We clearly could have and should have done better working through this with you as well. Thank you for your work on SimpleCov, as it is a vital component of the Ruby ecosystem. |
I wouldn't say that, to me the original sin was someone relying on
Imo not really as it was only run in one extremely specific context. My goal/intent would have been to remove the dependency with 1.0 and let it live as its own project. This works really well for me in my benchee library, where there are a bunch of formatters but a good chunk of them are community maintained.
Sorry if it felt this was aimed at #1165 - I hadn't looked at it and still haven't done so now. From the title I assumed it was simplifying the interface of formatters or how they were called. I don't wanna discuss that here, let's discuss that in that PR :)
💚 Hey, I know who you are :) And I've also used your OSS before, or if I'm not mistaken I did (I think you made the package that was a precursor to code climate in a way, i.e. combining simplecov, flog, flay and other stuff with a nice HTML report - thanks for that). And while that didn't make it into my post above, I acknowledge and appreciate seeing you around some of the PRs (also, like this one) helping. Thanks for the apology, although it was not your fault. If you wanted to dig into the history most of it (minus the emails and meeting I think) is in here: qltysh-archive/test-reporter#413 - I'm only posting it for reference. It's been a long time and I don't think there's any need to dig into it.
tell me about it 😅 Before I started maintaining simplecov I thought there were too many mentions of "make sure simplecov is required and started before anything else" in the README. A couple of months in I added even more.
They were definitely well intentioned and nice people. Alas, unwilling to make a couple of key compromises that I believe would have ultimately been beneficial for all sides. |

Hello and thank you for SimpleCov!
This PR updates the detection for the
CC_TEST_REPORTER_IDenvironment variable to also detect theQLTY_COVERAGE_TOKENenv var.Context: As of this year, the Code Climate Quality product has been replaced by the newer Qlty Cloud edition. (Qlty Cloud is operated by the same team previously responsible for Code Climate Quality.)
Qlty Cloud uses the
QLTY_COVERAGE_TOKENenv var in the same way that Code Climate Quality usedCC_TEST_REPORTER_ID. This PR ensures JSON code coverage data is automatically generated when it is present.We discovered that some customers are not aware of the
CC_TEST_REPORTER_IDbehavior and when they switched fromCC_TEST_REPORTER_IDtoQLTY_COVERAGE_TOKENit was confusing that the JSON went missing.This PR also preserves the
CC_TEST_REPORTER_IDbehavior for backwards compatibility, for anyone where it may be a "load bearing" behavior.Please let me know if you have any questions about this change!
-Bryan