Skip to content

Commit

Permalink
Merge branch 'main' into use-github-app
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Mar 2, 2024
2 parents cfd814c + 58a343c commit f0078a7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/actions/check-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
steps_to_skip:
description: "Comma separated list of steps to skip"
required: false
admin_check:
description: "Check if the user is a repo admin"
required: false
default: "true"
shell:
description: "The shell being used for the action steps"
required: false
Expand All @@ -31,6 +35,7 @@ runs:
export GITHUB_ACCESS_TOKEN=${{ inputs.token }}
export RH_VERSION_SPEC=${{ inputs.version_spec }}
export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.prep_release
- id: populate-release
Expand All @@ -40,6 +45,7 @@ runs:
export GITHUB_ACCESS_TOKEN=${{ inputs.token }}
export RH_RELEASE_URL=${{ steps.prep-release.outputs.release_url }}
export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
export YARN_UNSAFE_HTTP_WHITELIST=0.0.0.0
python -m jupyter_releaser.actions.populate_release
Expand All @@ -50,4 +56,5 @@ runs:
export GITHUB_ACCESS_TOKEN=${{ inputs.token }}
export RH_RELEASE_URL=${{ steps.populate-release.outputs.release_url }}
export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.finalize_release
5 changes: 5 additions & 0 deletions .github/actions/finalize-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
steps_to_skip:
description: "Comma separated list of steps to skip"
required: false
admin_check:
description: "Check if the user is a repo admin"
required: false
default: "true"
shell:
description: "The shell being used for the action steps"
required: false
Expand Down Expand Up @@ -52,6 +56,7 @@ runs:
export RH_RELEASE_URL=${{ inputs.release_url }}
export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }}
export RH_BRANCH=${{ inputs.branch }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.finalize_release
- if: ${{ success() }}
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/populate-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
steps_to_skip:
description: "Comma separated list of steps to skip"
required: false
admin_check:
description: "Check if the user is a repo admin"
required: false
default: "true"
shell:
description: "The shell being used for the action steps"
required: false
Expand Down Expand Up @@ -49,6 +53,7 @@ runs:
export RH_STEPS_TO_SKIP=${{ inputs.steps_to_skip }}
export RH_RELEASE_URL=${{ inputs.release_url }}
export RH_BRANCH=${{ inputs.branch }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.populate_release
- if: ${{ failure() }}
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/prep-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ inputs:
silent:
description: "Set a placeholder in the changelog and don't publish the release."
required: false
type: boolean
since:
description: "Use PRs with activity since this date or git reference"
required: false
since_last_stable:
description: "Use PRs with activity since the last stable git tag"
required: false
admin_check:
description: "Check if the user is a repo admin"
required: false
default: "true"
shell:
description: "The shell being used for the action steps"
required: false
Expand Down Expand Up @@ -63,6 +66,7 @@ runs:
export RH_SILENT=${{ inputs.silent }}
export RH_SINCE=${{ inputs.since }}
export RH_SINCE_LAST_STABLE=${{ inputs.since_last_stable }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.prep_release
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/publish-changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
description: "If set, do not make a PR"
default: "false"
required: false
admin_check:
description: "Check if the user is a repo admin"
required: false
default: "true"
shell:
description: "The shell being used for the action steps"
required: false
Expand Down Expand Up @@ -41,6 +45,7 @@ runs:
export RH_BRANCH=${{ inputs.branch }}
fi
export RH_DRY_RUN=${{ inputs.dry_run }}
export RH_ADMIN_CHECK=${{ inputs.admin_check }}
python -m jupyter_releaser.actions.publish_changelog
Expand Down
6 changes: 6 additions & 0 deletions jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ def publish_assets(
# a PYPI_TOKEN_MAP will not be sanitized in output
util.retry(f"{twine_cmd} {name}", cwd=dist_dir, env=env, echo=True)
found = True
else:
warnings.warn(
f"Python package name {pkg.name} does not match with name in "
f"jupyter releaser config: {python_package_name}. Skipping uploading dist file {path}",
stacklevel=2,
)
elif suffix == ".tgz":
# Ignore already published versions
try:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def prepare_environment(fetch_draft_release=True):
gh = get_gh_object(dry_run=dry_run, owner=owner, repo=repo_name, token=auth)

# Ensure the user is an admin.
if not dry_run:
if os.environ.get("RH_ADMIN_CHECK", "true").lower() == "true" and not dry_run:
user = os.environ["GITHUB_ACTOR"]
log(f"Getting permission level for {user}")
try:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,36 @@ def wrapped(cmd, **kwargs):
assert "after-publish-assets" in log


@pytest.mark.skipif(os.name == "nt", reason="pypiserver does not start properly on Windows")
def test_publish_assets_py_skip(py_package, runner, mocker, git_prep, mock_github):
# Create the dist files
changelog_entry = mock_changelog_entry(py_package, runner, mocker)
run("pipx run build .", cwd=util.CHECKOUT_NAME)

orig_run = util.run
called = 0

# Set a different package name in config
os.environ["RH_PYTHON_PACKAGES"] = "foo_path:foo1"

def wrapped(cmd, **kwargs):
nonlocal called
if "twine upload" in cmd:
called += 1
return orig_run(cmd, **kwargs)

mock_run = mocker.patch("jupyter_releaser.util.run", wraps=wrapped)

dist_dir = py_package / util.CHECKOUT_NAME / "dist"
release = create_draft_release(files=glob(f"{dist_dir}/*.*"))
os.environ["RH_RELEASE_URL"] = release.html_url
# Expect a user warning
with pytest.warns(UserWarning):
runner(["publish-assets", "--dist-dir", dist_dir, "--dry-run"])
# Upload should be skipped and command shouldn't be called at all
assert called == 0


def test_publish_assets_npm(npm_dist, runner, mocker, mock_github):
# Create the release.
dist_dir = npm_dist / util.CHECKOUT_NAME / "dist"
Expand Down

0 comments on commit f0078a7

Please sign in to comment.