ci(tests): fuzz testing workflow for REST API #3
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: REST API Fuzz Test | |
on: | |
workflow_dispatch: | |
pull_request: # Pushing a new commit to the HEAD ref of a pull request will trigger the “synchronize” event | |
paths: | |
- .yarnrc.yml . | |
- .yarn | |
- package.json | |
- '.github/workflows/rest-api-fuzzer.yml' | |
- 'packages/server/**/*' | |
- 'packages/shared/**/*' | |
env: | |
BUILD_CONFIGURATION: Release | |
BUILD_PLATFORM: 'Any CPU' | |
RESTLER_VERSION: '9.2.4' | |
PYTHON_VERSION: '3.8' | |
DOTNET_VERSION: '6.0.x' | |
jobs: | |
build-restler-fuzzer: | |
name: Build Restler Fuzzer | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: microsoft/restler-fuzzer | |
ref: v${{ env.RESTLER_VERSION }} | |
path: 'restler-fuzzer' # The path to clone the repository under {{ github.workspace }} | |
- name: Print environment variables | |
run: printenv | |
- name: Setup .NET ${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Restore NuGet packages | |
run: dotnet restore ${{ github.workspace }}/restler-fuzzer/src/Restler.sln | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install engine (Python) dependencies | |
run: | | |
pip install -r ${{ github.workspace }}/restler-fuzzer/restler/requirements.txt | |
- name: Build RESTler drop | |
run: | | |
python ${{ github.workspace }}/restler-fuzzer/build-restler.py --dest_dir ${{ github.workspace }}/bin/restler | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v3 | |
# - name: Log in to the Container registry | |
# uses: docker/login-action@v3.3.0 | |
# with: | |
# registry: ${{ env.REGISTRY }} | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Extract metadata (tags, labels) for Docker | |
# id: meta | |
# uses: docker/metadata-action@v5.5.1 | |
# with: | |
# tags: type=sha,format=long | |
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
# - name: Build and load preview-service Docker image | |
# uses: docker/build-push-action@v6 | |
# with: | |
# context: ${{ github.workspace }}/restler-fuzzer | |
# file: ${{ github.workspace }}/restler-fuzzer/Dockerfile # The Dockerfile for the restler-fuzzer | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# compile-fuzzer-syntax: | |
# name: Compile Fuzzer Syntax | |
# runs-on: ubuntu-latest | |
# needs: build-restler-fuzzer | |
# steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: 'speckle-server' | |
- name: Compile from OpenAPI | |
# run: docker run --volume ${{ github.workspace }}/restlerConfig:/RESTler/restler/restlerConfig ${{ needs.build-restler-fuzzer.outputs.tags }} compile --api_spec utils/specifications/speckle-server.openapi.json | |
run: | | |
${{ github.workspace }}/bin/restler/compiler compile --api_spec ${{ github.workspace }}/speckle-server/utils/specifications/speckle-server.openapi.json | |
- name: Print the results | |
run: ls -lat ${{ github.workspace }}/restlerConfig | |
# fuzz-rest-api-lite: | |
# runs-on: ubuntu-latest | |
# needs: | |
# - compile-fuzzer-syntax | |
# timeout-minutes: 15 | |
# services: | |
# postgres: | |
# # Docker Hub image | |
# image: postgres:16.4-bookworm@sha256:91f464e7ba0ad91a106c94cff079fb4384139291b8c0502fd36989cf2c788bbb | |
# env: | |
# POSTGRES_DB: fuzz_test | |
# POSTGRES_PASSWORD: fuzz_test | |
# POSTGRES_USER: fuzz_test | |
# # Set health checks to wait until postgres has started | |
# options: >- | |
# --health-cmd pg_isready | |
# --health-interval 10s | |
# --health-timeout 5s | |
# --health-retries 5 | |
# ports: | |
# - 5432:5432 | |
# # 4. Run the fuzzer in lite mode | |
# steps: | |
# - name: Compile from OpenAPI | |
# run: docker run ${{ needs.build-restler-fuzzer.outputs.tags }} compile --api_spec <full path to API specification> | |
# # 5. Print the results | |
# fuzz-rest-api-full: | |
# runs-on: ubuntu-latest | |
# needs: | |
# - compile-fuzzer-syntax | |
# timeout-minutes: 45 | |
# steps: | |
# - name: Run RESTler Fuzzer | |
# run: docker run /RESTler/restler/restler.exe fuzz --api_spec <full path to API specification> --fuzz_mode full | |
# # 7. Print the results |