Skip to content

Commit

Permalink
fix: set debug output, split more, group logs
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Sep 1, 2024
1 parent 79c975e commit 106cb87
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ runs:
if: ${{ steps.check.outputs.skip != 'true' }}
shell: bash -leo pipefail {0}
run: |
echo "::group::relock"
python ${{ github.action_path }}/relock.py \
--environment-file='${{ inputs.environment-file }}' \
--lock-file='${{ inputs.lock-file }}' \
Expand All @@ -112,6 +113,7 @@ runs:
echo EOF
} >> "$GITHUB_OUTPUT"
rm ${{ github.action_path }}/summary.txt
echo "::endgroup::"
- name: open PR
id: pr
Expand Down
33 changes: 28 additions & 5 deletions relock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Mapping
import os
import pprint
import shutil
import subprocess
import sys
Expand All @@ -16,11 +17,12 @@

def _split_package_list(package_list):
packages = []
for line in package_list.split("\n"):
for pkg in line.split(","):
_pkg = pkg.strip()
if _pkg:
packages.append(_pkg)
for nline in package_list.split("\n"):
for cline in nline.split(","):
for sline in cline.split():
_pkg = sline.strip()
if _pkg:
packages.append(_pkg)
return packages


Expand Down Expand Up @@ -130,8 +132,29 @@ def main(
for _pkg in _spec:
deps_to_relock.add(MatchSpec(_pkg).name)

print("relock all packages:", relock_all_packages, flush=True)
print(
"initial deps to relock:\n",
pprint.pformat(deps_to_relock),
flush=True,
)
print(
"ignored packages:\n", pprint.pformat(ignored_packages), flush=True
)
print(
"include only packages:\n",
pprint.pformat(include_only_packages),
flush=True,
)

deps_to_relock = deps_to_relock - set(ignored_packages)

print(
"final deps to relock:\n",
pprint.pformat(deps_to_relock),
flush=True,
)

relock_tuples = {platform: [] for platform in envyml["platforms"]}
for pkg in deps_to_relock:
for platform in envyml["platforms"]:
Expand Down
7 changes: 5 additions & 2 deletions test_relock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
(",", []),
("\n", []),
("conda", ["conda"]),
("conda,python", ["conda", "python"]),
("\nconda, python\nblah,blah\n,\n\n", ["conda", "python", "blah", "blah"]),
("conda, python", ["conda", "python"]),
(
"\nconda, python\nblah,blah\n,\nfoo bar\n",
["conda", "python", "blah", "blah", "foo", "bar"],
),
],
)
def test_split_package_list(input, output):
Expand Down

0 comments on commit 106cb87

Please sign in to comment.