diff --git a/.github/workflows/check-api-for-breaking-changes.yml b/.github/workflows/check-api-for-breaking-changes.yml new file mode 100644 index 000000000..8a2db76ee --- /dev/null +++ b/.github/workflows/check-api-for-breaking-changes.yml @@ -0,0 +1,49 @@ +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 diff --git a/.github/workflows/check-be-pull-request.yml b/.github/workflows/check-be-pull-request.yml deleted file mode 100644 index 2eb040084..000000000 --- a/.github/workflows/check-be-pull-request.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: "Check Backend Pull Request" - -on: - pull_request: - types: [opened, synchronize] - paths: - - "backend/**" - - "!backend/README.md" - - "!backend/.*" - - "backend/.eslintrc.js" - -jobs: - check-be-pr: - name: Check - runs-on: ubuntu-latest - timeout-minutes: 15 - - steps: - - name: โ˜๏ธ Checkout source - uses: actions/checkout@v3 - - name: ๐Ÿ”ง Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: "16" - cache: "npm" - cache-dependency-path: backend/package-lock.json - - name: ๐Ÿ“ฆ Install dependencies - run: npm ci --only-production - working-directory: backend - # - name: ๐Ÿงช Run tests - # run: npm run test:ci - # working-directory: backend - # - name: ๐Ÿ“ Upload test results - # uses: actions/upload-artifact@v3 - # if: always() - # with: - # name: be-test-results - # path: | - # ./backend/reports - # ./backend/coverage - - name: ๐Ÿ—๏ธ Run build - run: npm run build - working-directory: backend diff --git a/.github/workflows/check-be-ts-and-lint.yml b/.github/workflows/check-be-ts-and-lint.yml new file mode 100644 index 000000000..4b9b1a1b8 --- /dev/null +++ b/.github/workflows/check-be-ts-and-lint.yml @@ -0,0 +1,35 @@ +name: "Check Backend PR types and lint" + +on: + pull_request: + types: [opened, synchronize] + paths: + - "backend/**" + - "!backend/README.md" + - "!backend/.*" + - "backend/.eslintrc.js" + +jobs: + check-be-pr: + name: Check TS and Lint + 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" + cache: "npm" + cache-dependency-path: backend/package-lock.json + - name: Install dependencies + run: npm install + working-directory: backend + - name: Run type check + run: npm run type:check + working-directory: backend + - name: Run lint check + run: npm run lint + working-directory: backend diff --git a/docker-compose.pg.yml b/docker-compose.pg.yml index 8ef538f08..a73f7ca5e 100644 --- a/docker-compose.pg.yml +++ b/docker-compose.pg.yml @@ -62,8 +62,11 @@ services: dockerfile: Dockerfile.dev depends_on: - db + - redis env_file: - .env + ports: + - 4000:4000 environment: - NODE_ENV=development - DB_CONNECTION_URI=postgres://infisical:infisical@db/infisical?sslmode=disable