Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/apischema check action #22

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
49 changes: 49 additions & 0 deletions .github/workflows/checks-test.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### Github workflow for local test and development
### Rename to remove .example, and update the file with your own values
### act -W .\.github\workflows\checks-test.yml --input GITHUB_TOKEN=<TOKEN> --input SWAGGERPATH=https://host.docker.internal:7005/swagger/v1/swagger.json
### act -W .\.github\workflows\checks-test.yml --input GITHUB_TOKEN=<TOKEN> --input AUTH_TOKEN=<TOKEN> --input SWAGGERPATH=https://host.docker.internal:7005/swagger/v1/swagger.json
name: Test action-deployment

on: push

inputs:
GITHUB_TOKEN:
description: 'Github token'
required: true
AUTH_TOKEN:
description: 'Auth token'
required: false
SWAGGERPATH:
description: 'Swagger path'
required: true
XTFSO_License:
description: 'XTFSO License'
required: false
default: '82cf9f16-8366-48fc-96b0-2f683dea79bc;;'

env:
DEPLOYMENT_ENVIRONMENT: dev
jobs:
setupTest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: 'action-helper'

- name: Checkout Github
uses: actions/checkout@v3

- name: output
run: |
echo "Running schemathesis on SwaggerPath: ${{ github.event.inputs.SWAGGERPATH }}"

- name: SchemaCheck
uses: ./schema-check
with:
GITHUB_TOKEN: ${{ github.event.inputs.GITHUB_TOKEN }}
AUTH_TOKEN: ${{ github.event.inputs.AUTH_TOKEN }}
SWAGGERPATH: ${{ github.event.inputs.SWAGGERPATH }}
XTFSO_License: ${{ github.event.inputs.XTFSO_License }}

55 changes: 55 additions & 0 deletions schema-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
### Github workflow for local test and development
### act -W .\.github\workflows\test.yml -v -s GITHUB_TOKEN=##################

name: Schematest
description: 'Schematest for API using schemathesis'

inputs:
AUTH_TOKEN:
description: 'Auth Token'
required: false
default: ''
SWAGGERPATH:
description: 'Swagger Path'
required: false
default: 'https://localhost:3000/swagger.json'
GITHUB_TOKEN:
description: 'Github Token'
required: false
XTFSO_LICENSE:
description: 'XTFSO License'
required: false
default: '82cf9f16-8366-48fc-96b0-2f683dea79bc;;'

runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: BSFishy/pip-action@v1
with:
packages: |
schemathesis

- name: Schemacheck (Auth)
if: inputs.AUTH_TOKEN
id: schemacheck
run: |
echo "Running schemathesis with auth token"
st run -H "X-Tfso-License: ${{ inputs.XTFSO_LICENSE }}" -H "Authorization: Bearer ${{ inputs.AUTH_TOKEN }}" ${{ inputs.SWAGGERPATH }} --request-tls-verify=false --checks response_schema_conformance --wait-for-schema=5 --junit-xml=report.xml

- name: Schemacheck (No Auth)
id: schemacheck
if: inputs.AUTH_TOKEN == ''
run: |
echo "Running schemathesis without auth token"
st run -H "X-Tfso-License: ${{ inputs.XTFSO_LICENSE }}" ${{ inputs.SWAGGERPATH }} --request-tls-verify=false --checks response_schema_conformance --wait-for-schema=5 --junit-xml=report.xml
shell: bash

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure() # always run even if the previous step fails
with:
report_paths: 'report.xml'
Loading