diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml new file mode 100644 index 0000000..15c61ac --- /dev/null +++ b/.github/workflows/smoke.yml @@ -0,0 +1,33 @@ +name: Smoke test + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + config-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Build fixture through the local action + id: sourcey + uses: ./ + with: + version: "3.6.5" + config: test/fixture/sourcey.config.ts + output: test/fixture/generated docs + + - name: Verify output + env: + OUTPUT_DIR: ${{ steps.sourcey.outputs.output-dir }} + run: | + test "$OUTPUT_DIR" = "test/fixture/generated docs" + test -f "$OUTPUT_DIR/index.html" + test -f "$OUTPUT_DIR/search-index.json" diff --git a/action.yml b/action.yml index 59ca1f9..98c3944 100644 --- a/action.yml +++ b/action.yml @@ -38,23 +38,31 @@ runs: - name: Install Sourcey shell: bash - run: npm install -g sourcey@${{ inputs.version }} + env: + SOURCEY_VERSION: ${{ inputs.version }} + run: npm install --no-save --package-lock=false "sourcey@$SOURCEY_VERSION" - name: Build docs id: build shell: bash + env: + INPUT_ARGS: ${{ inputs.args }} + INPUT_CONFIG: ${{ inputs.config }} + INPUT_OUTPUT: ${{ inputs.output }} + INPUT_SPEC: ${{ inputs.spec }} run: | - ARGS="" - if [ -n "${{ inputs.config }}" ]; then - ARGS="--config ${{ inputs.config }}" - elif [ -n "${{ inputs.spec }}" ]; then - ARGS="${{ inputs.spec }}" + ARGS=() + if [ -n "$INPUT_CONFIG" ]; then + ARGS+=(--config "$INPUT_CONFIG") + elif [ -n "$INPUT_SPEC" ]; then + ARGS+=("$INPUT_SPEC") fi - if [ -n "${{ inputs.output }}" ]; then - ARGS="$ARGS --output ${{ inputs.output }}" + if [ -n "$INPUT_OUTPUT" ]; then + ARGS+=(--output "$INPUT_OUTPUT") fi - if [ -n "${{ inputs.args }}" ]; then - ARGS="$ARGS ${{ inputs.args }}" + if [ -n "$INPUT_ARGS" ]; then + read -r -a EXTRA_ARGS <<< "$INPUT_ARGS" + ARGS+=("${EXTRA_ARGS[@]}") fi - sourcey build $ARGS - echo "output-dir=${{ inputs.output }}" >> "$GITHUB_OUTPUT" + "$GITHUB_WORKSPACE/node_modules/.bin/sourcey" build "${ARGS[@]}" + echo "output-dir=$INPUT_OUTPUT" >> "$GITHUB_OUTPUT" diff --git a/test/fixture/openapi.yaml b/test/fixture/openapi.yaml new file mode 100644 index 0000000..f0d7543 --- /dev/null +++ b/test/fixture/openapi.yaml @@ -0,0 +1,12 @@ +openapi: 3.1.0 +info: + title: Sourcey action fixture + version: 1.0.0 +paths: + /health: + get: + operationId: getHealth + summary: Check service health + responses: + "200": + description: The service is healthy diff --git a/test/fixture/sourcey.config.ts b/test/fixture/sourcey.config.ts new file mode 100644 index 0000000..56c1637 --- /dev/null +++ b/test/fixture/sourcey.config.ts @@ -0,0 +1,14 @@ +import { defineConfig, openapi } from "sourcey"; + +export default defineConfig({ + name: "Sourcey action fixture", + navigation: { + tabs: [ + { + tab: "API Reference", + slug: "api", + source: openapi("./openapi.yaml"), + }, + ], + }, +});