client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

gocollector tests: Adjust CI to tell us when generated files were manually changed + refactor?

Open ArthurSens opened this issue 1 year ago • 7 comments

While working on https://github.com/prometheus/client_golang/pull/1559, we noticed that the generated files for the go collector can be manually changed and CI won't block the merge.

Let's investigate this and adjust :)

ArthurSens avatar Aug 09 '24 14:08 ArthurSens

Yup, CI is NOT running this generative script.

We only check if metrics given by the runtime is what we expect in those generated _test files and then complain with instruction to potentially rerun that script. This helps us to figure out what metrics changed across Go version. That's the main goal of those files.

You might be right some CI check that would rerun this script and point mismatch on TOP of our existing test would let us know if someone shoveled some custom manual code to those files.

Do you mind adding clear acceptance criteria to description?

bwplotka avatar Aug 09 '24 19:08 bwplotka

BTW.. we have two of those scripts 🙈

https://github.com/prometheus/client_golang/blob/main/prometheus/gen_go_collector_metrics_set.go https://github.com/prometheus/client_golang/blob/main/prometheus/collectors/gen_go_collector_set.go

bwplotka avatar Aug 14 '24 12:08 bwplotka

This might need proper refactor e.g. have one generated set in internals and separate logic to filter those for test purposes (it's just regex)

bwplotka avatar Aug 14 '24 12:08 bwplotka

Ideally I would also have only one script that generates both package files 🤔

bwplotka avatar Aug 20 '24 10:08 bwplotka

Acceptance Criteria

  • One script to generate test helpers for two places, we can move it to scripts dir or so.
  • Make sure our CI job for periodic script run and check actually works for BOTH files - it looks like it ran only one https://github.com/prometheus/client_golang/pull/1597 recently
  • Fix conflicts (visible in https://github.com/prometheus/client_golang/pull/1597) as we added manual changes to generated files in https://github.com/prometheus/client_golang/pull/1559 - those manual changed have to be either moved somewhere else or moved to generated content. This might need some test refactor
  • Have another CI job that checks for manual changes on those files.

bwplotka avatar Aug 28 '24 06:08 bwplotka

Hello guys, I would like to start contributing to the project and this issue was recommend to me. Can i start working on this?

augustodsgv avatar Nov 06 '24 00:11 augustodsgv

Sure thing! Is the discussion here enough for you to start working, or do you feel like you need extra guidance?

ArthurSens avatar Nov 06 '24 21:11 ArthurSens

Hello 👋 Looks like there was no activity on this issue for the last 3 months. Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗 If there will be no activity in the next 4 weeks, this issue will be closed (we can always reopen an issue if we need!).

stale[bot] avatar Jul 19 '25 06:07 stale[bot]