Skip to content

Commit

Permalink
fix: fix bugs in inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Sep 1, 2024
1 parent d074c61 commit bad3af4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GH_PAT }}

tests-ignore:
name: test ignore
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4

- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: |
numpy
python
relock-all-packages: false
github-token: ${{ secrets.GH_PAT }}
automerge: false
base-branch: ${{ github.head_ref }}

- name: did it not relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1

- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GH_PAT }}

tests-no-lock:
name: test no update
needs: tests-lock
Expand Down
11 changes: 5 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,18 @@ runs:
shell: bash -leo pipefail {0}
run: |
python ${{ github.action_path }}/relock.py \
--environment-file=${{ inputs.environment-file }} \
--lock-file=${{ inputs.lock-file }} \
--ignored-packages=${{ inputs.ignored-packages }} \
--relock-all-packages=${{ inputs.relock-all-packages }} \
--include-only-packages=${{ inputs.include-only-packages }} \
--environment-file='${{ inputs.environment-file }}' \
--lock-file='${{ inputs.lock-file }}' \
--ignored-packages='${{ inputs.ignored-packages }}' \
--relock-all-packages='${{ inputs.relock-all-packages }}' \
--include-only-packages='${{ inputs.include-only-packages }}' \
> ${{ github.action_path }}/summary.txt
{
echo 'summary<<EOF'
cat ${{ github.action_path }}/summary.txt
echo EOF
} >> "$GITHUB_OUTPUT"
rm ${{ github.action_path }}/summary.txt
ls -lah
- name: open PR
id: pr
Expand Down
7 changes: 6 additions & 1 deletion relock.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
import os
import shutil
import subprocess
Expand Down Expand Up @@ -123,7 +124,11 @@ def main(
else:
deps_to_relock = set()
for _spec in envyml["dependencies"]:
deps_to_relock.add(MatchSpec(_spec).name)
if not isinstance(_spec, Mapping):
deps_to_relock.add(MatchSpec(_spec).name)
else:
for _pkg in _spec:
deps_to_relock.add(MatchSpec(_pkg).name)

deps_to_relock = deps_to_relock - set(ignored_packages)

Expand Down

0 comments on commit bad3af4

Please sign in to comment.