feat(openapi): a fresh coat of paint on openapi inspect
#2911
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- next | |
- v9 | |
pull_request: | |
jobs: | |
build: | |
name: Test Suite | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: | |
# see the following: | |
# https://github.com/actions/setup-node?tab=readme-ov-file#supported-version-syntax | |
# https://github.com/nvm-sh/nvm/issues/1998#issuecomment-594958684 | |
- lts/-1 | |
- lts/* | |
- latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: npm | |
- name: Build and run tests | |
run: npm cit | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install deps | |
run: npm ci | |
- name: Build dist | |
run: npm run build | |
- name: Run tests | |
run: npm run lint | |
action: | |
name: GitHub Action Dry Run | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout GitHub Action | |
uses: actions/checkout@v4 | |
with: | |
path: rdme-repo | |
- name: Checkout external repo containing OpenAPI file | |
uses: actions/checkout@v4 | |
with: | |
path: oas-examples-repo | |
repository: readmeio/oas-examples | |
# Since this workflow file is in the `rdme` repository itself, | |
# we need to test the GitHub Action using the current commit. | |
# This step builds the `rdme` action code so we can do that. | |
# | |
# This step is not required for syncing your docs to ReadMe! | |
- name: Rebuild GitHub Action for testing purposes | |
run: npm ci && npm run build:gha | |
working-directory: rdme-repo | |
- name: Run `openapi validate` command | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi validate oas-examples-repo/3.1/json/petstore.json | |
- name: Run `openapi validate` command (legacy topic separator) | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi:validate oas-examples-repo/3.1/json/petstore.json | |
- name: Run `openapi validate` with filename in quotes | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi validate "oas-examples-repo/3.1/json/petstore.json" | |
- name: Run `openapi validate` on an invalid file | |
uses: ./rdme-repo/ | |
id: openapi-validate-fail | |
continue-on-error: true | |
with: | |
rdme: openapi validate rdme-repo/__tests__/__fixtures__/invalid-oas.json | |
- name: Assert that previous validation step failed | |
if: ${{ steps.openapi-validate-fail.outcome == 'failure' }} | |
run: echo "The validation in the previous step failed as expected." | |
- name: Throw error if previous validation step did not fail | |
if: ${{ steps.openapi-validate-fail.outcome == 'success' }} | |
run: echo "::error::Expected validation in previous step to fail" && exit 1 | |
# this is a test to ensure that the rdme github action can run properly | |
# the way that our users invoke it | |
- name: E2E run of `openapi validate` on `next` branch | |
uses: readmeio/rdme@next | |
if: ${{ github.ref }} == 'refs/heads/next' | |
with: | |
rdme: openapi validate oas-examples-repo/3.1/json/petstore.json | |
# Docs: https://rdme-test.readme.io | |
- name: Run `openapi` command | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi upload oas-examples-repo/3.1/json/petstore.json --key=${{ secrets.RDME_REFACTORED_TEST_PROJECT_API_KEY }} | |
- name: Run `openapi` command with env var | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi upload oas-examples-repo/3.1/json/petstore.json | |
env: | |
RDME_API_KEY: ${{ secrets.RDME_REFACTORED_TEST_PROJECT_API_KEY }} | |
- name: Run `openapi` command with other env var | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi upload oas-examples-repo/3.1/json/petstore.json | |
env: | |
README_API_KEY: ${{ secrets.RDME_REFACTORED_TEST_PROJECT_API_KEY }} | |
- name: Run `openapi` command with weird arg syntax | |
uses: ./rdme-repo/ | |
with: | |
rdme: openapi upload "oas-examples-repo/3.1/json/petstore.json" --key "${{ secrets.RDME_REFACTORED_TEST_PROJECT_API_KEY }}" |