Skip to content

Commit 070589d

Browse files
author
Steven Silvester
authored
Merge pull request #116 from fcollonval/fix/more-cleanup
Cleanup
2 parents 9dde1d5 + cca416a commit 070589d

File tree

9 files changed

+80
-67
lines changed

9 files changed

+80
-67
lines changed

.github/workflows/generate-changelog.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ jobs:
4949
env:
5050
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5151
run: |
52-
export INPUT_BRANCH=${{ github.event.inputs.branch }}
53-
export INPUT_SINCE=${{ github.event.inputs.since }}
52+
export RH_BRANCH=${{ github.event.inputs.branch }}
53+
export RH_SINCE=${{ github.event.inputs.since }}
54+
export RH_REF=refs/heads/${RH_BRANCH}
55+
export RH_REPOSITORY=${{ github.event.inputs.target }}
5456
export INPUT_UNTIL=${{ github.event.inputs.until }}
5557
export INPUT_CONVERT_TO_RST=${{ github.event.inputs.convert_to_rst }}
56-
python -m jupyter_releaser.actions.generate-changelog ${{ github.event.inputs.target }}
57-
cat changelog.md
58+
python -m jupyter_releaser.actions.generate-changelog
59+
cat CHANGELOG_ENTRY.md
5860
- uses: actions/upload-artifact@v2
5961
with:
6062
name: changelog
61-
path: changelog.md
63+
path: CHANGELOG_ENTRY.md

.github/workflows/test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,17 @@ jobs:
123123
if: ${{ matrix.os == 'ubuntu' }}
124124
env:
125125
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126-
TARGET: https://github.com/jupyter-server/jupyter_releaser
127-
INPUT_BRANCH: master
128-
INPUT_SINCE: v0.3.0
126+
RH_REPOSITORY: jupyter-server/jupyter_releaser
127+
RH_BRANCH: master
128+
RU_SINCE: v0.3.0
129129
INPUT_UNTIL: v0.4.0
130130
run: |
131-
python -m jupyter_releaser.actions.generate-changelog ${{ env.TARGET }}
132-
cat changelog.md
131+
set -eux
132+
python -m jupyter_releaser.actions.generate-changelog
133+
cat CHANGELOG_ENTRY.md
134+
# Check for version entry in between the two versions and one outside
135+
cat CHANGELOG_ENTRY.md | grep -q "#95"
136+
cat CHANGELOG_ENTRY.md | grep -q "compare/0.3.3...v0.4.0"
133137
- name: Coverage
134138
run: |
135139
codecov
Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3-
import os
4-
5-
from jupyter_releaser.util import CHECKOUT_NAME
6-
from jupyter_releaser.util import get_latest_tag
7-
from jupyter_releaser.util import log
83
from jupyter_releaser.util import run
94

105
run("jupyter-releaser prep-git")
11-
12-
# Capture the "since" argument in case we add tags befor checking changelog
13-
# Do this before bumping the version
14-
if not os.environ.get("RH_SINCE"):
15-
curr_dir = os.getcwd()
16-
os.chdir(CHECKOUT_NAME)
17-
since = get_latest_tag(os.environ["RH_BRANCH"]) or ""
18-
if since:
19-
log(f"Capturing {since} in RH_SINCE variable")
20-
os.environ["RH_SINCE"] = since
21-
os.chdir(curr_dir)
22-
236
run("jupyter-releaser bump-version")
247
run("jupyter-releaser build-changelog")
258
run("jupyter-releaser draft-changelog")

jupyter_releaser/actions/draft_release.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from jupyter_releaser.changelog import extract_current
99
from jupyter_releaser.util import CHECKOUT_NAME
10-
from jupyter_releaser.util import get_latest_tag
1110
from jupyter_releaser.util import log
1211
from jupyter_releaser.util import run
1312

@@ -32,18 +31,6 @@
3231
run("pip install -q -e .")
3332

3433
run("jupyter-releaser prep-git")
35-
36-
# Capture the "since" argument in case we add tags befor checking changelog
37-
# Do this before bumping the version
38-
if not os.environ.get("RH_SINCE"):
39-
curr_dir = os.getcwd()
40-
os.chdir(CHECKOUT_NAME)
41-
since = get_latest_tag(os.environ["RH_BRANCH"]) or ""
42-
if since:
43-
log(f"Capturing {since} in RH_SINCE variable")
44-
os.environ["RH_SINCE"] = since
45-
os.chdir(curr_dir)
46-
4734
run("jupyter-releaser bump-version")
4835

4936
if check_release:
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
2-
import sys
32
from pathlib import Path
43

54
from jupyter_releaser.changelog import get_version_entry
5+
from jupyter_releaser.util import CHECKOUT_NAME
6+
from jupyter_releaser.util import run
67

7-
target = sys.argv[-1]
8-
branch = os.environ.get("INPUT_BRANCH")
9-
since = os.environ.get("INPUT_SINCE")
8+
target = os.environ.get("RH_REPOSITORY")
9+
branch = os.environ.get("RH_BRANCH")
10+
ref = os.environ.get("RH_REF")
11+
since = os.environ.get("RH_SINCE")
1012
until = os.environ.get("INPUT_UNTIL")
1113
convert_to_rst = os.environ.get("INPUT_CONVERT_TO_RST", "")
1214

@@ -15,11 +17,16 @@
1517
print("branch:", branch)
1618
print("convert to rst:", convert_to_rst)
1719

18-
output = get_version_entry(branch, target, "current", since=since, until=until)
20+
run("jupyter-releaser prep-git")
21+
orig_dir = os.getcwd()
22+
os.chdir(CHECKOUT_NAME)
23+
output = get_version_entry(ref, branch, target, "current", since=since, until=until)
24+
1925
if convert_to_rst.lower() == "true":
2026
from pypandoc import convert_text
2127

2228
output = convert_text(output, "rst", "markdown")
2329
print("\n\n------------------------------")
2430
print(output, "------------------------------\n\n")
25-
Path("changelog.md").write_text(output, encoding="utf-8")
31+
os.chdir(orig_dir)
32+
Path("CHANGELOG_ENTRY.md").write_text(output, encoding="utf-8")

jupyter_releaser/changelog.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,25 @@ def format_pr_entry(target, number, auth=None):
4141

4242

4343
def get_version_entry(
44-
branch, repo, version, *, since=None, until=None, auth=None, resolve_backports=False
44+
ref,
45+
branch,
46+
repo,
47+
version,
48+
*,
49+
since=None,
50+
until=None,
51+
auth=None,
52+
resolve_backports=False,
4553
):
4654
"""Get a changelog for the changes since the last tag on the given branch.
4755
4856
Parameters
4957
----------
5058
branch : str
5159
The target branch
52-
respo : str
60+
ref: str
61+
The source reference
62+
repo : str
5363
The GitHub owner/repo
5464
version : str
5565
The new version
@@ -68,22 +78,22 @@ def get_version_entry(
6878
A formatted changelog entry with markers
6979
"""
7080

71-
if not since:
81+
if since:
7282
tags = util.run(
73-
f"git --no-pager tag --sort=-creatordate --merged {branch}", quiet=True
83+
f"git --no-pager tag --sort=-creatordate --merged {ref}", quiet=True
7484
)
7585
if tags:
7686
since = tags.splitlines()[0]
7787

7888
util.log(f"Getting changes to {repo} since {since} on branch {branch}...")
7989

80-
until = until or util.run(f'git --no-pager log -n 1 {branch} --pretty=format:"%H"')
81-
82-
until = until.replace("%", "")
90+
if until:
91+
until = until.replace("%", "")
8392

8493
md = generate_activity_md(
8594
repo,
8695
since=since,
96+
until=until,
8797
kind="pr",
8898
heading_level=2,
8999
auth=auth,
@@ -129,7 +139,7 @@ def get_version_entry(
129139
return output
130140

131141

132-
def build_entry(branch, repo, auth, changelog_path, since, resolve_backports):
142+
def build_entry(ref, branch, repo, auth, changelog_path, since, resolve_backports):
133143
"""Build a python version entry"""
134144
branch = branch or util.get_branch()
135145
repo = repo or util.get_repo()
@@ -148,6 +158,7 @@ def build_entry(branch, repo, auth, changelog_path, since, resolve_backports):
148158

149159
# Get changelog entry
150160
entry = get_version_entry(
161+
ref,
151162
branch,
152163
repo,
153164
version,
@@ -196,7 +207,9 @@ def format(changelog):
196207
return re.sub(r"\n\n+$", r"\n", changelog)
197208

198209

199-
def check_entry(branch, repo, auth, changelog_path, since, resolve_backports, output):
210+
def check_entry(
211+
ref, branch, repo, auth, changelog_path, since, resolve_backports, output
212+
):
200213
"""Check changelog entry"""
201214
branch = branch or util.get_branch()
202215

@@ -220,6 +233,7 @@ def check_entry(branch, repo, auth, changelog_path, since, resolve_backports, ou
220233
repo = repo or util.get_repo()
221234

222235
raw_entry = get_version_entry(
236+
ref,
223237
branch,
224238
repo,
225239
version,

jupyter_releaser/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ def bump_version(version_spec, version_cmd):
278278
@use_checkout_dir()
279279
def build_changelog(ref, branch, repo, auth, changelog_path, since, resolve_backports):
280280
"""Build changelog entry"""
281-
changelog.build_entry(branch, repo, auth, changelog_path, since, resolve_backports)
281+
changelog.build_entry(
282+
ref, branch, repo, auth, changelog_path, since, resolve_backports
283+
)
282284

283285

284286
@main.command()
@@ -309,7 +311,7 @@ def check_changelog(
309311
):
310312
"""Check changelog entry"""
311313
changelog.check_entry(
312-
branch, repo, auth, changelog_path, since, resolve_backports, output
314+
ref, branch, repo, auth, changelog_path, since, resolve_backports, output
313315
)
314316

315317

jupyter_releaser/lib.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,19 @@ def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
298298
with open(path, "wb") as f:
299299
for chunk in r.iter_content(chunk_size=8192):
300300
f.write(chunk)
301-
suffix = Path(asset.name).suffix
302-
if suffix in [".gz", ".whl"]:
303-
python.check_dist(path)
304-
elif suffix == ".tgz":
305-
npm.check_dist(path, npm_install_options)
306-
else:
307-
util.log(f"Nothing to check for {asset.name}")
301+
302+
# Check all npm packages
303+
npm.check_dist(dist, npm_install_options)
304+
305+
# Check python packages individually
306+
for asset in assets:
307+
suffix = Path(asset.name).suffix
308+
if suffix in [".gz", ".whl"]:
309+
python.check_dist(path)
310+
elif suffix == ".tgz":
311+
pass # already handled
312+
else:
313+
util.log(f"Nothing to check for {asset.name}")
308314

309315
# Skip sha validation for dry runs since the remote tag will not exist
310316
if dry_run:

jupyter_releaser/tests/test_functions.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,29 @@ def test_get_changelog_version_entry(py_package, mocker):
5353
mocked_gen = mocker.patch("jupyter_releaser.changelog.generate_activity_md")
5454
mocked_gen.return_value = testutil.CHANGELOG_ENTRY
5555
branch = "foo"
56-
resp = changelog.get_version_entry(branch, "bar/baz", version)
56+
ref = "origin/bar/baz"
57+
resp = changelog.get_version_entry(ref, branch, "bar/baz", version)
5758
mocked_gen.assert_called_with(
58-
"bar/baz", since=None, kind="pr", branch=branch, heading_level=2, auth=None
59+
"bar/baz",
60+
since=None,
61+
until=None,
62+
kind="pr",
63+
branch=branch,
64+
heading_level=2,
65+
auth=None,
5966
)
6067

6168
assert f"## {version}" in resp
6269
assert testutil.PR_ENTRY in resp
6370

6471
mocked_gen.return_value = testutil.CHANGELOG_ENTRY
6572
resp = changelog.get_version_entry(
66-
branch, "bar/baz", version, resolve_backports=True, auth="bizz"
73+
ref, branch, "bar/baz", version, resolve_backports=True, auth="bizz"
6774
)
6875
mocked_gen.assert_called_with(
6976
"bar/baz",
7077
since=None,
78+
until=None,
7179
kind="pr",
7280
branch=branch,
7381
heading_level=2,

0 commit comments

Comments
 (0)