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

chore: Add Makefile, add OpenApi Validation workflow #1

Merged
merged 8 commits into from
May 16, 2024
Merged
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Postman Collection Validation

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'

- name: Install dependencies
run: make install-dependencies

- name: Convert Postman Collection to OpenAPI
run: make convert2openapi

- name: Lint OpenAPI Specification
continue-on-error: true
run: make lint-oas

- name: Check for uncommitted changes
run: make check-git-status
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SHELL=/bin/bash -e -o pipefail
PWD = $(shell pwd)

# Lint OpenAPI files
lint-oas:
@docker run --rm -v $(PWD):/work:ro dshanley/vacuum:v0.9.15 lint OpenAPI/v1.yml
@docker run --rm -v $(PWD):/work:ro dshanley/vacuum:v0.9.15 lint OpenAPI/v2.yml

# Install dependencies for converting postman files to OpenAPI
install-dependencies:
@npm install -g postman-to-openapi

# Convert postman files to OpenAPI
convert2openapi:
@p2o ./proximity/v2.json -f ./OpenAPI/v2.yml
@p2o ./proximity/v1.json -f ./OpenAPI/v1.yml

# Check for uncommitted git changes
check-git-status:
@if git diff --quiet && git diff --staged --quiet; then \
echo "No uncommitted changes detected."; \
else \
echo "Error: Uncommitted changes detected." >&2; \
echo "Run `make convert2openapi` again and push changes!" >&2; \
exit 1; \
fi
Loading
Loading