Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/jetbrains-plugin-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ jobs:
set -euo pipefail
version=$(sed -n 's/^pluginVersion=//p' gradle.properties)
shopt -s nullglob
archives=(build/distributions/*-"$version".zip)
# a development version carries a +<build> suffix in the archive name, such as 1.2.3-dev+abc123
archives=(build/distributions/*-"$version".zip build/distributions/*-"$version"+*.zip)
if ((${#archives[@]} != 1)); then
echo "::error::expected one plugin ZIP for version $version, found ${#archives[@]}" >&2
exit 1
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/publish-pre-commit-mirror.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ jobs:
run: |
set -euo pipefail
version=$(cat .version)
sed -i "s/rev: \".*\"/rev: \"v$version\"/" README.md
# keep the quoting style of the README, which may write rev: v1.2.3 or rev: "v1.2.3"
sed -E -i "s/^([[:space:]]*rev:[[:space:]]*)(\"?)v?[^\"[:space:]]+\\2/\\1\\2v$version\\2/" README.md
if ! grep -Eq "rev:[[:space:]]*\"?v$version\"?$" README.md; then
echo "::error::README.md has no rev: line to update to v$version" >&2
exit 1
fi
- name: 💅 Format generated files
if: ${{ steps.generate.outputs.mirrored == 'true' }}
env:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+jetbrains-dev-archive.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`jetbrains-plugin-check` finds the plugin ZIP of a development version, whose name carries a `+<build>` suffix.
2 changes: 2 additions & 0 deletions changelog.d/+mirror-readme-rev.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`publish-pre-commit-mirror` updates an unquoted `rev:` in the README and fails when the README has no `rev:` line,
instead of leaving the version unchanged.
16 changes: 16 additions & 0 deletions tests/jetbrains_plugin_check/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ def test_build_ignores_archives_of_other_versions(tmp_path: Path, distributions:
assert outputs == {"name": "Plugin-1.2.3.zip", "sha256": hashlib.sha256(b"new").hexdigest()}


def test_build_finds_the_dev_archive_with_a_build_suffix(tmp_path: Path, distributions: Path) -> None:
(tmp_path / "gradle.properties").write_text("pluginVersion=1.2.3-dev\n")
(distributions / "Plugin-1.2.3-dev+abc123.zip").write_bytes(b"dev")
result, outputs = run_workflow_step(
_WORKFLOW,
"build",
"⚙️ Record unsigned ZIP digest",
cwd=tmp_path,
runner_temp=tmp_path,
values={},
env={},
)
assert result.returncode == 0, result.stderr
assert outputs == {"name": "Plugin-1.2.3-dev+abc123.zip", "sha256": hashlib.sha256(b"dev").hexdigest()}


def test_plugin_version_input_overrides_committed_version(tmp_path: Path) -> None:
(tmp_path / "gradle.properties").write_text("pluginVersion=1.2.2\nother=keep\n")
result, _ = run_workflow_step(
Expand Down
44 changes: 44 additions & 0 deletions tests/publish_pre_commit_mirror/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,47 @@ def test_different_published_tag_fails(tmp_path: Path, clone: Path, tools: Path)
result, _ = _commit_mirror(clone, tmp_path / "runner", tools, _ONE_VERSION)
assert result.returncode == 1
assert "v1.0.1 is published with a different mirror tree" in result.stderr


@pytest.mark.parametrize(
("readme", "expected"),
[
pytest.param(' rev: "v1.0.0"\n', ' rev: "v2.0.0"\n', id="quoted"),
pytest.param(" rev: v1.0.0\n", " rev: v2.0.0\n", id="unquoted"),
pytest.param("rev: 1.0.0\n", "rev: v2.0.0\n", id="no-v-prefix"),
],
)
def test_readme_rev_keeps_its_quoting(tmp_path: Path, readme: str, expected: str) -> None:
(tmp_path / ".version").write_text("2.0.0\n")
(tmp_path / "README.md").write_text(readme)

result, _ = run_workflow_step(
_WORKFLOW,
"mirror",
"📝 Update README with current version",
cwd=tmp_path,
runner_temp=tmp_path,
values={},
env={},
)

assert result.returncode == 0, result.stderr
assert (tmp_path / "README.md").read_text() == expected


def test_readme_without_rev_line_fails(tmp_path: Path) -> None:
(tmp_path / ".version").write_text("2.0.0\n")
(tmp_path / "README.md").write_text("no hook snippet\n")

result, _ = run_workflow_step(
_WORKFLOW,
"mirror",
"📝 Update README with current version",
cwd=tmp_path,
runner_temp=tmp_path,
values={},
env={},
)

assert result.returncode != 0
assert "README.md has no rev: line to update to v2.0.0" in result.stderr