Skip to content

Keep track of the checks changed at every Datadog Agent release #2277

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

Merged
merged 8 commits into from
Sep 20, 2018

Conversation

masci
Copy link
Contributor

@masci masci commented Sep 20, 2018

What does this PR do?

Adds the release agent_changelog command to ddev to provide a list of the changes for every Agent release in the form of a changelog file.

Motivation

The Agent changelog points to an invalid list of changed checks, from now on it can point directly the AGENT_CHANGELOG.md file from the root of this repo.

Review checklist

  • PR has a meaningful title or PR has the no-changelog label attached
  • Feature or bugfix has tests
  • Git history is clean
  • If PR impacts documentation, docs team has been notified or an issue has been opened on the documentation repo

Additional Notes

Generating the changelog is still a manual procedure!

@phrawzty
Copy link
Contributor

phrawzty commented Sep 20, 2018

Failed on flake8?

Also - and this is a minor thing - but I think we can drop the trailing period following the version numbers.

Copy link
Contributor

@l0k0ms l0k0ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! this new format is simply, effective, and easily searchable!

I just have a couple of feedback about the wording to make it more obvious for the user when scrolling fast in the changelog.

# go through all the agent releases
for agent, changes in changes_per_agent.iteritems():
url = agent_changelog_url.format(agent)
changelog.write('## Datadog Agent [{}]({})\n\n'.format(agent, url))
Copy link
Contributor

@l0k0ms l0k0ms Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we say ## Datadog Agent version %% ?

Also, do we want to also specify the Agent version release date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing the date is tricky because it would be the date the tag was added on integrations-core, that might be slightly different from the real one

changelog.write('* There were no check updates for this version of the Agent.\n\n')
else:
for name, ver in changes.iteritems():
breaking_notice = "This is a breaking change." if ver[1] else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make the breaking notice more obvious I think. What do you think of BREAKING CHANGE ?

@codecov-io
Copy link

Codecov Report

Merging #2277 into master will decrease coverage by 10.81%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           master    #2277       +/-   ##
===========================================
- Coverage   85.66%   74.84%   -10.82%     
===========================================
  Files         188       17      -171     
  Lines       13254      493    -12761     
  Branches     1435       57     -1378     
===========================================
- Hits        11354      369    -10985     
+ Misses       1493      105     -1388     
+ Partials      407       19      -388

if len(toks) != 2 or not toks[0] or not toks[1]:
# if we get here, the requirements file is garbled but let's stay
# resilient
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to print a message as well just in case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only necessary because we checked in and tagged a file with a git conflict at some point 🙈

Now that the changes to the reqfile are automated, this shouldn't happen again and if I log something we'll get the warning from that one tag forever

Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome tool!

@click.pass_context
def agent_changelog(ctx, since, to, output, force):
"""
FIXME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know what i think about FIXME and TODO in code 😝



def git_tag_list(pattern=None):
with chdir(get_root()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some descriptions here as well

def parse_agent_req_file(contents):
"""
Returns a dictionary mapping {check_name --> pinned_version} from the
given file contents. We can assume lines are in the form:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have a small validation just in case the assumption fails for whatever reasons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pip syntax, it's a safe assumption to make for now since the requirements file is auto generated.

# reverse so we have descendent order
agent_tags = agent_tags[::-1]

# store the changes in a mapping {agent_version --> {check_name --> current_version}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment 👍

changelog = StringIO()

# prepare the links
agent_changelog_url = 'https://github.com/DataDog/datadog-agent/blob/master/CHANGELOG.rst#{}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing we don't support agent 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we only support Agent 6.3.0+

changelog.write('## Datadog Agent version [{}]({})\n\n'.format(agent, url))

if not changes:
changelog.write('* There were no check updates for this version of the Agent.\n\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call our stuff check, or integration or maybe even integration check?

for name, ver in changes.iteritems():
breaking_notice = " **BREAKING CHANGE** " if ver[1] else ""
changelog_url = check_changelog_url.format(name)
changelog.write('* {} [{}]({}){}\n'.format(name, ver[0], changelog_url, breaking_notice))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it may be a little bit more complex to implement. However do we want to write the integration name or the integration folder name. For example MySQL instead mysql?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folder

changelog.write('\n')

# save the changelog on disk if --output was passed
if output:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a dry run param that just output to stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what it does if you don't pass -o (see the else branch)

Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me now. Thanks 🥇

@masci masci merged commit 27629cc into master Sep 20, 2018
@masci masci deleted the massi/changelog branch September 20, 2018 15:54
@ofek ofek mentioned this pull request Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants