diff --git a/.github/actions/scanapi/Dockerfile b/.github/actions/scanapi/Dockerfile new file mode 100644 index 0000000..4f078a2 --- /dev/null +++ b/.github/actions/scanapi/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.7 + +LABEL maintainer="github.com/camilamaia" + +ENV PATH="~/.local/bin:${PATH}" + +RUN pip install pip setuptools --upgrade + +ENTRYPOINT ["/entrypoint.sh"] + +COPY entrypoint.sh /entrypoint.sh diff --git a/.github/actions/scanapi/action.yml b/.github/actions/scanapi/action.yml new file mode 100644 index 0000000..1055cc0 --- /dev/null +++ b/.github/actions/scanapi/action.yml @@ -0,0 +1,21 @@ +name: "ScanAPI" +author: "@scanapi" +description: "Allows any developer to run ScanAPI using github actions" +branding: + icon: "align-justify" + color: "gray-dark" +inputs: + scanapi_version: + description: "The ScanAPI version to be installed" + required: true + default: "latest" + arguments: + description: "Desired arguments to run ScanAPI. Allow multiple parameters separated by spaces." + required: true + default: "--help" +runs: + using: "docker" + image: "Dockerfile" + args: + - ${{ inputs.scanapi_version }} + - ${{ inputs.arguments }} diff --git a/.github/actions/scanapi/entrypoint.sh b/.github/actions/scanapi/entrypoint.sh new file mode 100755 index 0000000..b43761f --- /dev/null +++ b/.github/actions/scanapi/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [[ $1 != 'latest' ]]; then + pip install "scanapi=="$1 +else + echo "latest" + pip install scanapi +fi + +sh -c "scanapi ${@:2}" diff --git a/.github/workflows/scanapi.yml b/.github/workflows/scanapi.yml new file mode 100644 index 0000000..a2b71ce --- /dev/null +++ b/.github/workflows/scanapi.yml @@ -0,0 +1,17 @@ +on: pull_request +name: Run ScanAPI +jobs: + scanapi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run automated API tests + uses: ./.github/actions/scanapi + with: + scanapi_version: "2.0.0" + arguments: "run ./pokeapi/scanapi.yaml" + - name: Upload scanapi-report.html + uses: actions/upload-artifact@v2 + with: + name: ScanAPI Report + path: scanapi-report.html