Skip to content

Commit 0fdcbf1

Browse files
authored
Allow test script to use upstream DocC. (#21)
Expect `SWIFT_DOCC_BRANCH` and `SWIFT_DOCC_RENDER_ARTIFACT_BRANCH` in the environment, defaulting to `main` for each. Use these branches to clone swift-docc and swift-docc-render-artifact in order to run the tests with newer/upstream dependencies. This could also make it easier to have combined PR CI testing in this project. Exclude the cloned directories from `./bin/check-source`. rdar://97294776
1 parent b46caac commit 0fdcbf1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

bin/check-source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ EOF
108108
\( \! -path '*/.build/*' -a \
109109
\! -name '.' -a \
110110
\( "${matching_files[@]}" \) -a \
111+
\( \! -path './swift-docc/*' \) -a \
112+
\( \! -path './swift-docc-render-artifact/*' \) -a \
111113
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
112114
if [[ "$(cat "$line" | replace_acceptable_years | $reader -n $expected_lines | $SHA_CMD)" != "$expected_sha" ]]; then
113115
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"

bin/test

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,41 @@ filepath() {
2020
# absolute file path to the Swift-DocC-Plugin root source dir.
2121
SWIFT_DOCC_PLUGIN_ROOT="$(dirname $(dirname $(filepath $0)))"
2222

23+
SWIFT_DOCC_ROOT="$SWIFT_DOCC_PLUGIN_ROOT/swift-docc"
24+
SWIFT_DOCC_RENDER_ARTIFACT_ROOT="$SWIFT_DOCC_PLUGIN_ROOT/swift-docc-render-artifact"
25+
export DOCC_HTML_DIR="$SWIFT_DOCC_RENDER_ARTIFACT_ROOT/dist"
26+
27+
SWIFT_DOCC_REPO=${SWIFT_DOCC_REPO:="https://github.com/apple/swift-docc.git"}
28+
SWIFT_DOCC_RENDER_ARTIFACT_REPO=${SWIFT_DOCC_RENDER_ARTIFACT_REPO:="https://github.com/apple/swift-docc-render-artifact.git"}
29+
30+
SWIFT_DOCC_BRANCH=${SWIFT_DOCC_BRANCH:="main"}
31+
SWIFT_DOCC_RENDER_ARTIFACT_BRANCH=${SWIFT_DOCC_RENDER_ARTIFACT_BRANCH:="main"}
32+
33+
# The script will clone swift-docc and swift-docc-render-artifact at the
34+
# branches pulled from the environment above. The tests will then run using
35+
# that built DocC. This can be useful for testing interdependent changes that
36+
# need to land together and make it possible to test multiple pull requests
37+
# together.
38+
39+
echo "Cloning docc..."
40+
rm -rf "$SWIFT_DOCC_ROOT"
41+
git clone -b "$SWIFT_DOCC_BRANCH" "${SWIFT_DOCC_REPO}" "$SWIFT_DOCC_ROOT" || exit 1
42+
43+
echo "Cloning docc-render-artifact..."
44+
rm -rf "$SWIFT_DOCC_RENDER_ARTIFACT_ROOT"
45+
git clone -b "${SWIFT_DOCC_RENDER_ARTIFACT_BRANCH}" "${SWIFT_DOCC_RENDER_ARTIFACT_REPO}" "$SWIFT_DOCC_RENDER_ARTIFACT_ROOT" || exit 1
46+
47+
echo "Building docc..."
48+
swift build --package-path "$SWIFT_DOCC_ROOT" --configuration release || exit 1
49+
50+
export DOCC_EXEC="$(swift build --package-path "$SWIFT_DOCC_ROOT" --show-bin-path --configuration release)/docc"
51+
if [[ ! -f "$DOCC_EXEC" ]]; then
52+
echo "docc executable not found, expected at $SWIFT_DOCC_EXEC"
53+
exit 1
54+
else
55+
echo "Using docc executable: $DOCC_EXEC"
56+
fi
57+
2358
# Build and test Swift-DocC Plugin
2459
swift test --parallel --package-path "$SWIFT_DOCC_PLUGIN_ROOT"
2560

0 commit comments

Comments
 (0)