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

feat: whitelist packages on check-licenses action #600

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion build-wheelhouse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ inputs:
default: true
type: boolean

whitelist-license-check:
description: |
Optional list of packages to ignore during the license check. Separated by a comma.
Only used when ``check-licenses`` is set to ``true``.
required: false
default: ''
type: string

checkout:
description: |
Whether to do a checkout step or not. If ``true``, the checkout step is performed.
Expand Down Expand Up @@ -182,9 +190,10 @@ runs:
retention-days: 7

- name: Check library's dependencies license
uses: ansys/actions/check-licenses@main
uses: ansys/actions/check-licenses@feat/whitelist-packages
Copy link
Member Author

Choose a reason for hiding this comment

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

Should be reverted to main once approved and before merging

Suggested change
uses: ansys/actions/check-licenses@feat/whitelist-packages
uses: ansys/actions/check-licenses@main

if: ${{ inputs.check-licenses == 'true' }}
with:
python-version: ${{ inputs.python-version }}
skip-install: true
checkout: false
whitelist-license-check: ${{ inputs.whitelist-license-check }}
20 changes: 20 additions & 0 deletions check-licenses/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ inputs:
default: ''
type: string

whitelist-license-check:
description: |
Optional list of packages to ignore during the license check. Separated by a comma.
required: false
default: ''
type: string

skip-install:
description: |
Whether to skip the installation of the project. The default is ``false``.
Expand Down Expand Up @@ -161,6 +168,19 @@ runs:
wget https://raw.githubusercontent.com/ansys/actions/main/check-licenses/accepted-licenses.txt
wget https://raw.githubusercontent.com/ansys/actions/main/check-licenses/ignored-packages.txt

- name: "Process whitelisted packages provided on input"
shell: bash
run: |
if [[ -n "${{ inputs.whitelist-license-check }}" ]]; then
echo "Whitelisted packages: ${{ inputs.whitelist-license-check }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could echo the path of the "ignored-packages.txt" so we can easily access the list.
Also at the top of this file, I will explain why the following packages are for.

Copy link
Member Author

Choose a reason for hiding this comment

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

The content of the ignored-packages.txt file is printed out: see https://github.com/ansys/pyansys-tools-report/actions/runs/11177206820/job/31072221914?pr=219#step:2:829 as an example

The reasons why we are ignoring some of them is already explained in the description I think but we can improve it if you want... what do you have in mind?

See

description: |
Verifies if the licenses of the dependencies installed in the current
environment are compliant with PyAnsys guidelines. This action is assumed to
be used in its own job step. It clones the project and installs the project with
its runtime dependencies.
.. note::
**This action relies on PyPI metadata to identify the license for each package.**
If the metadata are flawed or not included, it may lead to
inconclusive results. In those cases, please perform a thorough review of the
package you are using. Additionally, it is advised not to blindly rely on PyPI metadata.
Even though packages may define their license as of a certain type, the
package could be not applying properly its licensing conditions.
.. jinja:: check-licenses
.. grid:: 1 1 1 2
:gutter: 2
.. grid-item-card:: :octicon:`codescan-checkmark` Accepted third party licenses
{% for license in accepted_licenses %}
* {{ license }}
{% endfor %}
.. grid-item-card:: :octicon:`package` Ignored packages
{% for package in ignored_packages %}
* {{ package }}
{% endfor %}
.. admonition:: Projects requiring additional licenses or packages
If a certain project requires a license or package that is not supported,
`open an issue <https://github.com/ansys/actions/issues>`_ in the
`official ansys/actions repository
<https://github.com/ansys/actions>`_. For additional support, please
contact the `PyAnsys support <mailto:[email protected]>`_.
and the rendering:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Just put the content of the description.
It is just for users that could find the file without knowing about the existence of the action.
Some contributors might see this file without knowing what is its intent because they don't know about all the actions we have.

# Split the input string by comma, trim values and append them to the ignored-packages.txt file
IFS=',' read -ra whitelist <<< "${{ inputs.whitelist-license-check }}"
for package in "${whitelist[@]}"; do
echo "Ignoring whitelisted package: $package"
echo "$package" >> ignored-packages.txt
done
fi

- name: "Check licences of packages"
shell: bash
run: |
Expand Down