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

Task #905 - Add scan-licenses.yml GA workflow #145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

anamarijabalaban
Copy link

Task: #905

Aim

Add GA workflow that will run license scanning in the CI/CD pipeline for projects that already have configured license_finder gem.

Solution

Added scan-licenses.yml GA workflow that will be triggered when the Gemfile or package.json file has been changed.

First I tried to run license_finder only by using this command: bundle exec license_finder but I got some errors with missing nokogiri so I found this solution that includes adding x86_64-linux platform to the bundler. License finder issue with this solution.
Screenshot 2023-10-11 at 08 58 27

@anamarijabalaban
Copy link
Author

Later, I figured out that this would be more useful if a workflow could be run on any project no matter if it has configured license_finder or not, so maybe I could prepare a workflow that will install, configure license_finder gem and run license scanning. What do you think?

Comment on lines +18 to +21
bundle config --local deployment false
bundle lock --add-platform x86_64-linux
bundle config --local deployment true
bundle exec license_finder
Copy link
Member

Choose a reason for hiding this comment

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

I'd actually like to have this as a script in the project, similar to e.g. bin/lint:

BIN_LINT = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== zeitwerk check ==========="
time bundle exec rails zeitwerk:check
echo "=========== rubocop ==========="
time bundle exec rubocop --format simple --format github --color --parallel
HEREDOC
create_file 'bin/lint', BIN_LINT, force: true
chmod 'bin/lint', 0755, verbose: false

That way developers can run the script locally and modify it if needed.

Copy link
Member

Choose a reason for hiding this comment

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

For simple one/two-liners, I find it's more complex when CI workflow is referencing project scripts. GH workflow is coupled with the default_rails_template, and it makes it less portable.

In this case, I'm OK with both approaches, but in general, I'm in favor of workflow being self-sustainable, and project scripts should be used only where necessary.

scan-licenses.yml Outdated Show resolved Hide resolved
.github/workflows/scan-licenses.yml Outdated Show resolved Hide resolved
.github/workflows/scan-licenses.yml Outdated Show resolved Hide resolved
scan-licenses.yml Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

How are the developers notified that there are issues with some licenses?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we should setup a Slack notification here.

DevOps used https://github.com/rtCamp/action-slack-notify

Copy link
Member

Choose a reason for hiding this comment

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

I don't think Slack notification is necessary for this step.

Copy link
Author

Choose a reason for hiding this comment

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

@nikajukic I tried to use https://github.com/rtCamp/action-slack-notify for sending slack notifications but it looks like they require us to install this https://slack.com/apps/A0F7XDUAZ-incoming-webhooks?tab=settings&next_id=0

@nikajukic
Copy link
Contributor

@uncoverd @vr4b4c please leave your review

@uncoverd
Copy link
Contributor

uncoverd commented Nov 2, 2023

@lovro-bikic 's suggestions are great, I think once we resolve those we're good to push this 👍

As far as the Slack notifications are concerned, we'd get a failing build notification and a visual notification on the PR. On top of that we have after commit hooks defined in the other PR so I don't think another Slack notification is required

Copy link
Member

@vr4b4c vr4b4c left a comment

Choose a reason for hiding this comment

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

Did we consider running this check as part of the build workflow?

Comment on lines +18 to +20
bundle config --local deployment false
bundle lock --add-platform x86_64-linux
bundle config --local deployment true
Copy link
Member

Choose a reason for hiding this comment

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

This block looks like it's trying to perform a trick/hack. Why do we need this? Is there a more conventional way of achieving the same result?

Copy link
Author

Choose a reason for hiding this comment

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

First, I tried just to call bundle exec license_finder but I got some missing nokogiri error #145 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Seems like you uncovered a problem with our setup. This is a native extension compilation problem, which originates from our template.rb specifically here.

Nokogiri installation docs contains compelling arguments to explicitly list platforms making bundler install precompiled binaries instead of compiling deps natively.

@lovro-bikic your comment here was the trigger to move from explicitly listing platforms to using ruby. Can you please take a look at this problem and add your thoughts on the topic?

Comment on lines +18 to +21
bundle config --local deployment false
bundle lock --add-platform x86_64-linux
bundle config --local deployment true
bundle exec license_finder
Copy link
Member

Choose a reason for hiding this comment

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

For simple one/two-liners, I find it's more complex when CI workflow is referencing project scripts. GH workflow is coupled with the default_rails_template, and it makes it less portable.

In this case, I'm OK with both approaches, but in general, I'm in favor of workflow being self-sustainable, and project scripts should be used only where necessary.

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

Successfully merging this pull request may close these issues.

5 participants