Skip to content

Commit

Permalink
[chef-inspec] Add automation
Browse files Browse the repository at this point in the history
Similar to chef-infra-client and chef-infra-server.
  • Loading branch information
marcwrobel committed Aug 13, 2024
1 parent d447149 commit 0a2bd46
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/chef-inspec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from bs4 import BeautifulSoup
from common import dates, http, releasedata
from common.git import Git

"""Fetch released versions from docs.chef.io and retrieve their date from GitHub.
docs.chef.io needs to be scraped because not all tagged versions are actually released.
More context on https://github.com/endoflife-date/endoflife.date/pull/4425#discussion_r1447932411.
"""

with releasedata.ProductData("chef-inspec") as product_data:
rn_response = http.fetch_url("https://docs.chef.io/release_notes_inspec/")
rn_soup = BeautifulSoup(rn_response.text, features="html5lib")
released_versions = [h2.get('id') for h2 in rn_soup.find_all('h2', id=True) if h2.get('id')]
print(released_versions)

git = Git("https://github.com/inspec/inspec.git")
git.setup(bare=True)

versions = git.list_tags()
for version, date_str in versions:
sanitized_version = version.replace("v", "")
if sanitized_version in released_versions:
date = dates.parse_date(date_str)
product_data.declare_version(sanitized_version, date)

0 comments on commit 0a2bd46

Please sign in to comment.