Skip to content

Commit

Permalink
feat(ci): separate the swagger validation in own runner plus improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
p-fernandez committed Aug 16, 2023
1 parent 61299b2 commit 9727dc7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 19 deletions.
22 changes: 22 additions & 0 deletions .github/actions/run-api/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run API

description: Starts and waits for an API running instance

inputs:
launch_darkly_sdk_key:
description: 'The Launch Darkly SDK key to use'
required: false
default: ''

runs:
using: composite

steps:
- name: Start API
env:
IS_IN_MEMORY_CLUSTER_MODE_ENABLED: true
LAUNCH_DARKLY_SDK_KEY: ${{ inputs.launch_darkly_sdk_key }}
run: cd apps/api && pnpm start:test &

- name: Wait on API
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check
17 changes: 17 additions & 0 deletions .github/actions/validate-swagger/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Validate Swagger

description: Validates the swagger from the API

runs:
using: composite

steps:
- name: Get swagger json as file
run: |
curl -o swagger.json http://localhost:1336/api-json
- uses: char0n/swagger-editor-validate@v1
with:
definition-file: swagger.json

- name: Kill port for api 1336 for unit tests
run: sudo kill -9 $(sudo lsof -t -i:1336)
41 changes: 22 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,6 @@ jobs:
targets: test:e2e
projects: ${{matrix.projectName}}

- name: Start Api
env:
IN_MEMORY_CLUSTER_MODE_ENABLED: true
run: cd apps/api && pnpm start:test &

- name: Wait on Api
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check

- name: Get swagger json as file
run: |
curl -o swagger.json http://localhost:1336/api-json
- uses: char0n/swagger-editor-validate@v1
with:
definition-file: swagger.json

- name: Kill port for api 1336 for unit tests
run: sudo kill -9 $(sudo lsof -t -i:1336)

test_unit:
name: Unit Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -268,3 +249,25 @@ jobs:
with:
targets: lint,build,test
projects: ${{matrix.projectName}}

validate_swagger:
name: Validate Swagger
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
timeout-minutes: 10
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: ./.github/actions/run-api
with:
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}

- uses: ./.github/actions/validate-swagger

0 comments on commit 9727dc7

Please sign in to comment.