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

Add GitHub Actions annotations #34

Merged
merged 2 commits into from
Jan 11, 2022

Conversation

ekohl
Copy link

@ekohl ekohl commented Dec 20, 2021

It is possible to get inline annotations with GitHub Actions. This is based on Rubocop's formatter.

It's implemented as a configuration option that's dynamic by default. This means it will show up in actions, but not in other environments. Overriding is still possible.

@ekohl ekohl requested a review from a team as a code owner December 20, 2021 10:19
@ekohl
Copy link
Author

ekohl commented Dec 20, 2021

This is currently very light on tests. I also wonder about the additional class.

See voxpupuli/puppet-example#19 for an example:
image

Comment on lines +78 to +86
def override_env
old_env = ENV.clone
yield
ensure
ENV.clear
ENV.update(old_env)
end
Copy link
Author

Choose a reason for hiding this comment

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

I wasn't quite sure about this, but I wrote it on the train without internet access.

Choose a reason for hiding this comment

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

Is this comment resolvable?

Copy link
Author

Choose a reason for hiding this comment

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

Well, it works. I just don't know if this is the desired solution in this repo.

Copy link
Collaborator

@bastelfreak bastelfreak left a comment

Choose a reason for hiding this comment

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

looks quite good to me and the screenshot shows it's working.

@ekohl ekohl force-pushed the add-github-actions-annotations branch from e1e7e81 to d91347e Compare December 20, 2021 10:25
Copy link

@genebean genebean left a comment

Choose a reason for hiding this comment

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

LGTM

@ekohl
Copy link
Author

ekohl commented Jan 8, 2022

It looks like no CI ran, only the CLA check. I'm not sure why that is.

@genebean
Copy link

genebean commented Jan 9, 2022

It looks like no CI ran, only the CLA check. I'm not sure why that is.

That’s weird…

@ekohl ekohl closed this Jan 10, 2022
@ekohl ekohl reopened this Jan 10, 2022
@ekohl
Copy link
Author

ekohl commented Jan 10, 2022

Found it and it's the same thing we suffer from in theforeman: https://github.com/puppetlabs/puppet-lint/actions/workflows/ci.yml shows

This scheduled workflow is disabled because there hasn't been activity in this repository for at least 60 days. Enable this workflow to resume scheduled runs.

This is because there's a schedule and regular PR testing in the same workflow, which is very annoying.

@ekohl ekohl closed this Jan 11, 2022
@ekohl ekohl reopened this Jan 11, 2022
@ekohl
Copy link
Author

ekohl commented Jan 11, 2022

See, it was good that we enabled CI. Looks like I need to please Rubocop.

This should be no difference in execution, but it pleases Rubocop in the
next commit when some code is added and makes review easier.
@ekohl ekohl force-pushed the add-github-actions-annotations branch from d91347e to 670cbac Compare January 11, 2022 16:20
@ekohl
Copy link
Author

ekohl commented Jan 11, 2022

It looks like there's an interesting interaction I didn't foresee: the CI runs on GitHub actions as well so that's generating the warnings in this test suite, which was not intended. Looks like I need to use the configuration option I implemented.

It is possible to get inline annotations with GitHub Actions. This is
based on Rubocop's formatter.

It's implemented as a configuration option that's dynamic by default.
This means it will show up in actions, but not in other environments.
Overriding is still possible.
@ekohl ekohl force-pushed the add-github-actions-annotations branch from 670cbac to b70093d Compare January 11, 2022 16:42
Comment on lines +52 to +55
override_env do
ENV.delete('GITHUB_ACTION')
subject.defaults
end
Copy link
Author

Choose a reason for hiding this comment

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

Annotating my own code: technically this is redundant now that there's ENV.delete() in spec_helper.rb, but it doesn't hurt to be explicit.

Comment on lines +1 to +2
# Disable GitHub Actions reporting since it breaks the test suite
ENV.delete('GITHUB_ACTION')
Copy link
Author

Choose a reason for hiding this comment

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

This isn't the cleanest, but I couldn't find a good way to consistently set the setting. Right now I don't think it would break anything.

@binford2k binford2k merged commit 3f8feaf into puppetlabs:master Jan 11, 2022
@ekohl ekohl deleted the add-github-actions-annotations branch January 11, 2022 16:51
@binford2k
Copy link

@ekohl Apologies, I forgot to get back to you. This does indeed break PDK rendering rather spectacularly when running with a GITHUB_ACTION env variable set. Looks like both output formats get used.

output.txt

@ekohl
Copy link
Author

ekohl commented Feb 4, 2022

Fascinating. I wonder what it's doing. Is it by any chance using JSON output?

@ekohl
Copy link
Author

ekohl commented Feb 4, 2022

I believe #35 should fix it, or at least unbreak JSON mode. Could you verify that?

@binford2k
Copy link

👍 looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants