Skip to content

docs-check broken by #282: quoted doc target + docs_check_targets input ignored in containers #291

Description

@sebsto

The docs-check soundness job fails when the documentation target is read from .spi.yml:

error: no target named '"AWSLambdaRuntime"'
compatible targets: 'AWSLambdaRuntime', ...

The target name reaches swift package plugin generate-documentation wrapped in literal double-quotes. Two separate bugs, both introduced in #282, cause this — and they compound, so fixing only one is not enough.

Bug 1 — check-docs.sh drops the yq -r flag

.github/workflows/scripts/check-docs.sh reads targets from .spi.yml without -r:

docs_targets=$(yq ".builder.configs[] | select(.documentation_targets[] != \"\") | .documentation_targets[]" .spi.yml)

The Swift Ubuntu containers apt install the Python yq (a jq wrapper). Without -r it prints JSON-quoted strings, so $target becomes "AWSLambdaRuntime" (quotes included) and is passed verbatim to --target.

Verified in swift:6.3-noble:

$ yq ".builder.configs[] | .documentation_targets[]" .spi.yml
"AWSLambdaRuntime"      # without -r
$ yq -r ".builder.configs[] | .documentation_targets[]" .spi.yml
AWSLambdaRuntime        # with -r

The pre-#282 script used yq -r and worked. (Note line 106 of the same script still correctly uses -r.)

Fix: restore -r on the extraction line.

Bug 2 — soundness.yml uses [[ under sh

The intended workaround is to pass targets explicitly via the docs_check_targets input, which makes the script skip the .spi.yml path. But the Run documentation check step in soundness.yml builds that argument with bash-only [[:

run: |
  doc_target_arg=""
  if [[ "${DOCS_TARGETS}" != "" ]] ; then
    doc_target_arg="--doc-targets ${DOCS_TARGETS}"
  fi
  ...

The docs-check job runs in a container, where the default step shell is sh (dash), and the step has no shell: bash. Under dash, [[ is not a builtin:

/__w/_temp/....sh: 3: [[: not found

So doc_target_arg stays empty, --doc-targets is never passed, and the script falls back to the broken path in Bug 1. This means the docs_check_targets workaround silently has no effect.

Fix: add shell: bash to the documentation-check step(s), or replace [[ ... ]] with POSIX [ ... ].

Workaround for consumers

Until both are fixed, pin to the commit before #282, which has neither bug:

uses: swiftlang/github-workflows/.github/workflows/soundness.yml@9abcbf2

Affected

main of swiftlang/github-workflows, since #282.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions