Skip to content

Commit e9533d8

Browse files
committed
Track wiki pointer drift without republishing content
1 parent cad9c63 commit e9533d8

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

.github/actions/wiki/refresh-release-pointer/run.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ git -C "${target}" clean -fd
2020
dev-tools wiki --target="${target}"
2121

2222
if [ -z "$(git -C "${target}" status --porcelain)" ]; then
23+
pointer_changed="false"
24+
25+
if ! git diff --quiet -- "${target}"; then
26+
pointer_changed="true"
27+
fi
28+
2329
{
2430
echo "published=false"
25-
echo "pointer-changed=false"
31+
echo "pointer-changed=${pointer_changed}"
2632
echo "publish-sha=$(git -C "${target}" rev-parse HEAD)"
2733
} >> "${GITHUB_OUTPUT}"
2834

tests/GitHubActions/RefreshReleaseWikiPointerActionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ public function refreshWillSkipPublicationWhenTheRenderedWikiDoesNotChange(): vo
119119
self::assertSame('', trim($status->getOutput()));
120120
}
121121

122+
/**
123+
* @return void
124+
*/
125+
#[Test]
126+
public function refreshWillReportPointerDriftWhenTheWikiRemoteAdvancedWithoutNewRenderedChanges(): void
127+
{
128+
$workspace = $this->createWorkspaceWithWikiSubmodule();
129+
$this->advanceWikiRemote();
130+
$this->createMockDevToolsBinary(false);
131+
$outputFile = $this->workspace . '/github-output';
132+
133+
$this->runAction($workspace, $outputFile);
134+
135+
$outputs = $this->parseKeyValueFile($outputFile);
136+
$status = $this->runProcess(['git', 'status', '--short', '.github/wiki'], $workspace);
137+
138+
self::assertSame('false', $outputs['published']);
139+
self::assertSame('true', $outputs['pointer-changed']);
140+
self::assertStringContainsString('.github/wiki', $status->getOutput());
141+
}
142+
122143
/**
123144
* @return string
124145
*/
@@ -185,6 +206,19 @@ private function createMockDevToolsBinary(bool $shouldChange): void
185206
chmod($binDirectory . '/dev-tools', 0o755);
186207
}
187208

209+
/**
210+
* @return void
211+
*/
212+
private function advanceWikiRemote(): void
213+
{
214+
$wikiSeed = $this->workspace . '/wiki-seed';
215+
216+
file_put_contents($wikiSeed . '/README.md', "# Wiki\n\nUpdated upstream.\n");
217+
$this->runProcess(['git', 'add', 'README.md'], $wikiSeed);
218+
$this->runProcess(['git', 'commit', '-m', 'Advance wiki remote'], $wikiSeed);
219+
$this->runProcess(['git', 'push', 'origin', 'master'], $wikiSeed);
220+
}
221+
188222
/**
189223
* @param string $workspace
190224
* @param string $outputFile

0 commit comments

Comments
 (0)