diff --git a/.github/workflows/release-actions.yml b/.github/workflows/release-actions.yml index 8dce942f1..011a4c1ac 100644 --- a/.github/workflows/release-actions.yml +++ b/.github/workflows/release-actions.yml @@ -34,10 +34,11 @@ on: - "allowlist-check/**" - "pelican/**" - "stash/**" + - "website-comment/**" workflow_dispatch: inputs: action: - description: "Tag prefix to release (allowlist-check, pelican, save, restore). Leave empty to auto-detect from the latest commit." + description: "Tag prefix to release (allowlist-check, pelican, save, restore, preview-annotate, preview-artifact, preview-main-overlay, preview-publish). Leave empty to auto-detect from the latest commit." required: false default: "" bump: diff --git a/.github/workflows/website-comment-test.yml b/.github/workflows/website-comment-test.yml new file mode 100644 index 000000000..86b9796df --- /dev/null +++ b/.github/workflows/website-comment-test.yml @@ -0,0 +1,224 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: Test the PR preview actions +on: + pull_request: + paths: + - "website-comment/**" + - ".github/workflows/website-comment-test.yml" + push: + # Branches only, so release tag pushes do not re-run it. + branches: + - main + paths: + - "website-comment/**" + - ".github/workflows/website-comment-test.yml" + +permissions: + contents: read + +jobs: + node: + name: "publisher, overlay and Astro adapter" + runs-on: ubuntu-26.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "22" + + - name: Install the locked test dependencies + working-directory: website-comment + run: npm ci --ignore-scripts --no-audit --no-fund + + - name: Unit tests + working-directory: website-comment + run: npm test + + - name: preview-annotate outputs the Astro plugin + id: astro + uses: ./website-comment/preview-annotate + with: + generator: astro + + - name: The plugin path resolves + env: + PLUGIN: ${{ steps.astro.outputs.vite-plugin }} + run: test -f "$PLUGIN" + + - name: A built site + run: | + mkdir -p "$RUNNER_TEMP/main-site" + echo '
<h1 data-preview-src="index.md:1">Stamp data-preview-src in preview builds.
' > "$RUNNER_TEMP/docs-site/index.html" + + - name: preview-annotate accepts escaped and prose mentions + uses: ./website-comment/preview-annotate + with: + generator: none + production-output: ${{ runner.temp }}/docs-site + + - name: A production page with the attribute on a tag split across lines + run: | + mkdir -p "$RUNNER_TEMP/split-site" + printf 'naïve
;"); + assert.ok(out.includes(''), out); +}); + +test("leaves unparsable source untouched", () => { + const code = "const a =