Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
upload_to_bucket: false
fail_threshold: never

test-lint-file-fail-threshold-never-ok-hide-annotations:
uses: ./.github/workflows/lint.yml
with:
path: fixture/openapi-bad.yaml
upload_to_bucket: false
annotations: none
fail_threshold: never

test-validate-file-external-refs:
uses: ./.github/workflows/validate.yml
with:
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ on:
description: "The threshold to fail the build. Accepted values: warn, error, never"
type: string
default: "never"
annotations:
description: "Annotate files with lint problems. Accepted values: all (annotate all files), none (dont annotate any files)"
type: string
default: all


env:
REDOCLY_VERSION: "2.25.1"
Expand All @@ -32,6 +37,7 @@ jobs:
id-token: write
env:
GHA_API_FAIL_THRESHOLD: ${{ inputs.fail_threshold }}
GHA_API_ANNOTATIONS: ${{ inputs.annotations }}
GHA_API_ARTIFACT: ${{ inputs.artifact }}
GHA_API_PATH: ${{ inputs.path }}
SHOULD_UPLOAD: >-
Expand Down Expand Up @@ -70,6 +76,16 @@ jobs:
exit 1
;;
esac

# Validate annotations
case "$GHA_API_ANNOTATIONS" in
all|none)
;; # OK
*)
echo "::error::annotatons must be one of: all, none"
exit 1
;;
esac
- name: Resolve spec path
id: resolve-spec-path
run: |
Expand Down Expand Up @@ -111,6 +127,7 @@ jobs:
env:
GHA_API_PATH: ${{ steps.resolve-spec-path.outputs.spec_path }}
GHA_API_FAIL_THRESHOLD: ${{ inputs.fail_threshold }}
GHA_API_ANNOTATIONS: ${{ inputs.annotations }}
run: |
set -o errexit
set -o nounset
Expand All @@ -130,7 +147,10 @@ jobs:
fi

if [ "$rc" -eq 1 ]; then
cat $annotations
if [ "$GHA_API_ANNOTATIONS" = "all" ]; then
cat $annotations
fi

# Truncate to stay under GitHub's 1024k step summary limit. Leave 200 bytes for warning message.
max_size=$((1024 * 1024 - 200))
if [ "$(wc -c < "$markdown")" -gt "$max_size" ]; then
Expand Down
5 changes: 4 additions & 1 deletion fixture/openapi-bad.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
openapi: "3.1.0"
openapi: "3.1.0"
info:
x-entur-metadata:
id: example-id

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

entur-info-metadata-owner

The OpenAPI info section MUST include "x-entur-metadata.owner". Documentation: https://github.com/entur/api-guidelines/blob/main/guidelines.md#242-specification-owner

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

entur-info-metadata-audience

The OpenAPI info section MUST include "x-entur-metadata.audience". Documentation: https://github.com/entur/api-guidelines/blob/main/guidelines.md#24-entur-metadata

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

oas3-schema

"info" property must have required property "version". Documentation: https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

oas3-schema

"info" property must have required property "title". Documentation: https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

info-description

Info "description" must be present and non-empty string. Documentation: https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#info-description

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

entur-info-title

The OpenAPI info section MUST include a non-empty "title". Documentation: https://github.com/entur/api-guidelines/blob/main/guidelines.md#21-general-design-principles

Check failure on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

oas3-schema

The document must have either "paths", "webhooks" or "components". Documentation: https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema

Check warning on line 4 in fixture/openapi-bad.yaml

View workflow job for this annotation

GitHub Actions / test-lint-file-fail-threshold-never-ok / OpenAPI Lint

oas3-api-servers

OpenAPI "servers" must be present and non-empty array. Documentation: https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-api-servers
Loading