test breaking change #6
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: "Check Backend Breaking API Changes" | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- "backend/src/server/routes/**" | |
jobs: | |
check-be-api-changes: | |
name: Check API Changes | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
- name: Setup Node 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
# uncomment this when testing locally using nektos/act | |
# - uses: KengoTODA/actions-setup-docker-compose@v1 | |
# if: ${{ env.ACT }} | |
# name: Install `docker-compose` for local simulations | |
# with: | |
# version: "2.14.2" | |
- name: 📦Build the latest image | |
run: docker build --tag infisical-api . | |
working-directory: backend | |
- name: Start postgres and redis | |
run: touch .env && docker-compose -f "docker-compose.pg.yml" up db redis -d | |
- name: Start the server | |
run: docker run --name infisical-api -d -p 4000:4000 -e DB_CONNECTION_URI=$DB_CONNECTION_URI -e REDIS_URL=$REDIS_URL -e JWT_AUTH_SECRET=$JWT_AUTH_SECRET --entrypoint '/bin/sh' infisical-api -c "npm run migration:latest && ls && node dist/main.mjs" | |
env: | |
REDIS_URL=redis://host.docker.internal:6379 | |
DB_CONNECTION_URI=postgres://infisical:infisical@host.docker.internal:5432/infisical?sslmode=disable | |
JWT_AUTH_SECRET=something-random | |
- name: Install openapi api diff | |
run: npm install -g openapi-diff | |
- name: Wait for containers to be stable | |
run: timeout 60s sh -c 'until docker ps | grep infisical-api | grep -q healthy; do echo "Waiting for container to be healthy..."; sleep 2; done' | |
- name: Get changes made in API | |
id: openapi-diff | |
run: openapi-diff https://app.infisical.com/api/docs/json http://localhost:4000/api/docs/json | |
- name: cleanup | |
run: | | |
docker-compose -f "docker-compose.pg.yml" down | |
docker stop infisical-api | |
docker remove infisical-api |