generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f125ba1
commit c99bc11
Showing
7 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,58 @@ | ||
name: 'FawltyDeps' | ||
description: 'Check a Python project for _undeclared_ and _unused_ 3rd party dependencies' | ||
# Inspired by and adapted from https://github.com/psf/black/blob/main/action.yml | ||
# Inspired by and adapted from: | ||
# https://github.com/psf/black/blob/main/action.yml | ||
# https://github.com/isort/isort-action | ||
inputs: | ||
options: | ||
description: "Options passed to fawltydeps. Use `fawltydeps --help` to see available options. Default: | ||
''" | ||
required: false | ||
default: "" | ||
requirements-files: | ||
description: > | ||
path(s) to requirements files that should be installed to properly | ||
configure third-party imports | ||
required: false | ||
paths: | ||
description: > | ||
files or directories to scan for dependency issues | ||
required: false | ||
default: . | ||
branding: | ||
color: "purple" | ||
icon: "check-circle" | ||
outputs: | ||
fawltydeps-result: | ||
description: fawltydeps result | ||
value: ${{ steps.run-fawltydeps.outputs.fawltydeps-output }} | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
using: 'composite' | ||
steps: | ||
- run: $GITHUB_ACTION_PATH/bin/ensure_python | ||
shell: bash | ||
|
||
args: | ||
- fawltydeps | ||
- ${{ inputs.options }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: $GITHUB_ACTION_PATH/bin/ensure_python | ||
shell: bash | ||
- run: > | ||
$GITHUB_ACTION_PATH/bin/install_packages | ||
${{ inputs.fawltydeps-version }} | ||
${{ inputs.requirements-files || inputs.requirementsFiles }} | ||
shell: bash | ||
- run: echo "::add-matcher::$GITHUB_ACTION_PATH/fawltydeps-matcher.json" | ||
shell: bash | ||
- id: run-isort | ||
run: > | ||
$GITHUB_ACTION_PATH/bin/run_fawltydeps | ||
${{ inputs.options }} | ||
${{ inputs.paths }} | ||
shell: bash | ||
- run: echo "::remove-matcher owner=fawltydeps-matcher::" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# If Python 3 isn't installed, exit | ||
python3 -V > /dev/null 2>&1 || (echo "python3 is not available. Use the setup-python action" && exit 1) | ||
|
||
# Make sure we're using a supported version of Python | ||
major_version=$(python3 -c 'import sys; print(sys.version_info[0])') | ||
minor_version=$(python3 -c 'import sys; print(sys.version_info[1])') | ||
if [ "$major_version" -lt 3 ] || [ "$minor_version" -lt 6 ]; then | ||
echo "Minimum supported version of python is 3.6, but $(python3 -V) is installed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
isort_version=$1 | ||
requirements_files=$2 | ||
|
||
echo "::group::Install isort" | ||
if [ -z "$isort_version" ] || [ "$isort_version" == "latest" ]; then | ||
echo "Installing latest version of isort" | ||
python3 -m pip install "isort[requirements_deprecated_finder,pipfile_deprecated_finder]" | ||
else | ||
echo "Installing isort==$isort_version" | ||
python3 -m pip install "isort[requirements_deprecated_finder,pipfile_deprecated_finder]==$isort_version" | ||
fi | ||
echo "::endgroup::" | ||
|
||
if [ -n "$requirements_files" ]; then | ||
echo "::group::Install modules from requirements arg" | ||
for file in $requirements_files; do | ||
python3 -m pip install -r "$file" | ||
done | ||
echo "::endgroup::" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Running fawltydeps $*" | ||
fawltydeps_result=$(fawltydeps "$@") | ||
exit_code=$? | ||
|
||
# The fawltydeps output can be a multiline string. By default, GITHUB_OUTPUT expects | ||
# output to be on a single line, so a (random) delimiter needs to be used | ||
# so that the output is parsed properly. | ||
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | ||
DELIMITER=$(echo $RANDOM | md5sum | head -c 20) | ||
{ | ||
echo "fawltydeps-output<<${DELIMITER}" | ||
echo "${fawltydeps_result}" | ||
echo "${DELIMITER}" | ||
} >> "${GITHUB_OUTPUT}" | ||
|
||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "fawltydeps-matcher", | ||
"pattern": [ | ||
{ | ||
"regexp": "(These imports appear to be .* dependencies):$", | ||
"message": 1 | ||
}, | ||
{ | ||
"regexp": "^- '([^']+)' imported at:$", | ||
"message": 1 | ||
}, | ||
{ | ||
"regexp": "^ (.+):([0-9]+)$", | ||
"file": 1, | ||
"line": 2, | ||
"loop": true | ||
} | ||
] | ||
} | ||
] | ||
} |