Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source changelogs for programmatic consumption #430

Open
gioamato opened this issue Nov 8, 2021 · 6 comments
Open

Source changelogs for programmatic consumption #430

gioamato opened this issue Nov 8, 2021 · 6 comments

Comments

@gioamato
Copy link

gioamato commented Nov 8, 2021

It might be useful to source changelogs from WordPress.org with version tags (eg. dependabot could show it in PRs).

I could try to add it and open a PR if you just point me in the right direction.

@NoelLH
Copy link
Contributor

NoelLH commented Jan 6, 2022

Hey @gioamato, thanks for the suggestion. I can see how this might be useful to expose somewhere in the frontend – I'm not sure if there is a working Dependabot use case per se as yet, but let me know if that's wrong?

I think it's potentially a reasonably big change. If you are hoping to consistently pull out the exact changes for each version number I'm also not sure that's going to work. I skimmed some entries from the API and the formatting is pretty inconsistent. In each plugin in the array returned by API v1.1, sections.changelog is a big blob of HTML and sometimes has a paragraph prefix before the versions, sometimes not.

Screenshot 2022-01-06 at 09 08 38

While the version numbered bits later in (or sometimes from the start of) the changelog seem to consistently show in <h4>s their format is not consistent and sometimes includes stuff like date suffixes, which diverges from the Subversion repository's version numbers format. So I suspect these may be impossible to reliably reconcile with the internal version numbers used for Composer dependency management.

If you do still want to look at saving the whole changelog at package level, I'd suggest the steps would be something like:

  1. Add a model field for the info, probably in Outlandish\Wpackagist\Entity\Package.
  2. Add a database migration to get this safely added to schemas: bin/console doctrine:migrations:diff may help here.
  3. Expand the use of the rarst/wporg-client to request the sections key I mentioned above or just sections.changelog if possible, alongside version metadata.
  4. On updates, save that HTML against the field you added – possibly using strip_tags() or doing more involved preprocessing, depending on your plan for outputting the data.
  5. If you want to output it within the Wpackagist web app or anywhere else that might end up in a web context, sanitise the HTML to avoid security risks when doing so. If you are targeting non-web output you will need to strip the HTML and probably do some other reformatting to make these legible as plain text.

@chrillep
Copy link

chrillep commented Jun 13, 2023

+1 on this same for renovate. not sure about the parsing tho. however github supports html.

example urls

fetch("https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&slug=redirection")
  .then(response => response.json())
  .then(data => console.log(data.sections.changelog))
  .catch(error => console.log(error))

refs

@carstingaxion
Copy link

Wanted to ask for this, too. Thank you.

@chrillep
Copy link

chrillep commented Aug 24, 2023

+1 on this same for renovate. not sure about the parsing tho. however github supports html.

example urls

fetch("https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&slug=redirection")
  .then(response => response.json())
  .then(data => console.log(data.sections.changelog))
  .catch(error => console.log(error))

refs

@LeoColomb id like to work on this, but before i start, id like your takeaways.
Im tagging you since youve done this once, but for roots/wordpress.

@chrillep
Copy link

chrillep commented Aug 25, 2023

@LeoColomb
Copy link

Im tagging you since youve done this once, but for roots/wordpress.

Well, I'm not sure the process will be the same, as this plugins API provides an (almost) well formatted and well-structured changelog value. You should feel lucky 😁

My main takeaways though are that WordPress changelog is:

  • Absolutely not ready for API usage. Scraping is never reassuring as the structure is not guarantied.
  • Published about 30-35 min after releases API is updated, while managed Renovate/Dependabot do their stuff about 20-30 min after a release is published. Enjoy the relaxing delay 😢

hmm maybe its better if renovate and dependabot fix this instead.

Probably better, I agree, but comes with some additional challenges (especially HTML handling).
I'd also note plugins with type:wordpress-plugin can be published at/retrieved from many different places, so the script should expect failures and handle them gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants