diff --git a/build-wheelhouse/action.yml b/build-wheelhouse/action.yml index f7ffb07a4..201917a92 100644 --- a/build-wheelhouse/action.yml +++ b/build-wheelhouse/action.yml @@ -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. @@ -188,3 +196,4 @@ runs: python-version: ${{ inputs.python-version }} skip-install: true checkout: false + whitelist-license-check: ${{ inputs.whitelist-license-check }} diff --git a/check-licenses/action.yml b/check-licenses/action.yml index 10f01ef72..768e8e5ea 100644 --- a/check-licenses/action.yml +++ b/check-licenses/action.yml @@ -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``. @@ -161,6 +168,46 @@ 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 }}" + # 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: "Logging licenses and packages" + shell: bash + run: | + # Load accepted licenses + mapfile licenses_from_txt < accepted-licenses.txt + accepted_licenses='Accepted licenses:\n' + for license in ${licenses_from_txt[*]}; do accepted_licenses+="$license\n"; done + echo "LOG_ACCEPTED_LICENSES=$accepted_licenses" >> $GITHUB_ENV + + # Load accepted packages + mapfile ignored_packages_from_txt < ignored-packages.txt + ignored_packages='Ignored packages:\n' + for pckg in ${ignored_packages_from_txt[*]}; do ignored_packages+="$pckg\n"; done + echo "LOG_IGNORED_PACKAGES=$ignored_packages" >> $GITHUB_ENV + + - name: Log ignored packages and accepted licenses + uses: ansys/actions/_logging@main + with: + level: "INFO" + message: | + Licenses accepted and packages ignored + ---------------------------------------------- + + ${{ env.LOG_ACCEPTED_LICENSES }} + + ${{ env.LOG_IGNORED_PACKAGES }} + - name: "Check licences of packages" shell: bash run: | @@ -168,15 +215,13 @@ runs: mapfile licenses_from_txt < accepted-licenses.txt accepted_licenses='' for license in ${licenses_from_txt[*]}; do accepted_licenses+="$license\|"; done - accepted_licenses=${accepted_licenses::-2} - echo "Accepted licenses: $accepted_licenses" + accepted_licenses=${accepted_licenses::-2} # Load accepted packages mapfile ignored_packages_from_txt < ignored-packages.txt ignored_packages='' for pckg in ${ignored_packages_from_txt[*]}; do ignored_packages+="$pckg "; done - ignored_packages_from_txt=${ignored_packages_from_txt::-1} - echo "Ignored packages: $ignored_packages" + ignored_packages_from_txt=${ignored_packages_from_txt::-1} # Verify if the Python environment contains invalid licenses if [[ -z $(pip-licenses --summary --ignore-packages $ignored_packages | grep -v $accepted_licenses | tail -n+2) ]]; then