diff --git a/.github/workflows/jetbrains-plugin-check.yaml b/.github/workflows/jetbrains-plugin-check.yaml index f5bfb23..8fe60e1 100644 --- a/.github/workflows/jetbrains-plugin-check.yaml +++ b/.github/workflows/jetbrains-plugin-check.yaml @@ -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 + 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 diff --git a/.github/workflows/publish-pre-commit-mirror.yaml b/.github/workflows/publish-pre-commit-mirror.yaml index 0323732..94f2f7a 100644 --- a/.github/workflows/publish-pre-commit-mirror.yaml +++ b/.github/workflows/publish-pre-commit-mirror.yaml @@ -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: diff --git a/changelog.d/+jetbrains-dev-archive.bugfix.md b/changelog.d/+jetbrains-dev-archive.bugfix.md new file mode 100644 index 0000000..ca9e2dd --- /dev/null +++ b/changelog.d/+jetbrains-dev-archive.bugfix.md @@ -0,0 +1 @@ +`jetbrains-plugin-check` finds the plugin ZIP of a development version, whose name carries a `+` suffix. diff --git a/changelog.d/+mirror-readme-rev.bugfix.md b/changelog.d/+mirror-readme-rev.bugfix.md new file mode 100644 index 0000000..6f19ee0 --- /dev/null +++ b/changelog.d/+mirror-readme-rev.bugfix.md @@ -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. diff --git a/tests/jetbrains_plugin_check/test_plugin.py b/tests/jetbrains_plugin_check/test_plugin.py index ec772ae..2c965ab 100644 --- a/tests/jetbrains_plugin_check/test_plugin.py +++ b/tests/jetbrains_plugin_check/test_plugin.py @@ -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( diff --git a/tests/publish_pre_commit_mirror/test_mirror.py b/tests/publish_pre_commit_mirror/test_mirror.py index 8a4f54b..af5dc45 100644 --- a/tests/publish_pre_commit_mirror/test_mirror.py +++ b/tests/publish_pre_commit_mirror/test_mirror.py @@ -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