Rewording grouped snaps #1427
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: Pixeleye CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
types: [opened, synchronize] | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
jobs: | |
paths-filter: | |
name: Paths filter | |
runs-on: ubuntu-latest | |
outputs: | |
migrations: ${{ steps.filter.outputs.migrations }} | |
backend: ${{ steps.filter.outputs.backend }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
base: ${{ github.ref }} | |
filters: | | |
migrations: | |
- 'apps/backend/platform/migrations/**' | |
backend: | |
- 'apps/backend/**' | |
paths-filter-pr: | |
name: Paths filter | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' }} | |
permissions: | |
pull-requests: read | |
outputs: | |
migrations: ${{ steps.filter.outputs.migrations }} | |
anythingButMigrations: ${{ steps.filter.outputs.anythingButMigrations }} | |
schema: ${{ steps.filter.outputs.schema }} | |
steps: | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
migrations: | |
- 'apps/backend/platform/migrations/**' | |
anythingButMigrations: | |
- '!(apps/backend/platform/*(database/schema.hcl)*(migrations/**))' | |
schema: | |
- 'apps/backend/platform/database/schema.hcl' | |
node-ci: | |
name: Node - Build, Lint, Test, Types | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18, 20] | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | |
DOCS_TOKEN: ${{ secrets.DOCS_TOKEN }} | |
GITHUB_APP_NAME: "pixeleye-io" | |
ORY_URL: ${{ secrets.ORY_ENDPOINT }} | |
BACKEND_URL: "http://localhost:5000" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Lint | |
run: pnpm turbo lint | |
- name: Test | |
run: pnpm turbo test | |
- name: Types | |
run: pnpm turbo types | |
- name: Build | |
run: pnpm turbo deploy | |
golang-ci: | |
name: Golang - Lint, Test, Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
cache: false | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: v1.54 | |
args: --timeout=5m | |
working-directory: ./apps/backend | |
- name: Install dependencies | |
run: | | |
cd apps/backend | |
go mod download | |
go mod verify | |
- name: Build | |
run: | | |
cd apps/backend | |
go build -v ./... | |
- name: Test | |
run: | | |
cd apps/backend | |
go test -v ./... | |
# atlas-lint: | |
# name: Atlas - Linting | |
# runs-on: ubuntu-latest | |
# needs: paths-filter-pr | |
# if: ${{ ( always() && !failure() && !cancelled() && github.ref == 'refs/heads/main' ) || needs.paths-filter-pr.outputs.migrations == 'true' }} | |
# services: | |
# postgres: | |
# image: postgres:15-alpine | |
# env: | |
# POSTGRES_USER: postgres | |
# POSTGRES_PASSWORD: pass | |
# POSTGRES_DB: test | |
# ports: | |
# - 5430:5432 | |
# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - uses: ariga/setup-atlas@v0 | |
# with: | |
# cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }} | |
# - uses: ariga/atlas-action/migrate/lint@v1 | |
# with: | |
# dir: "file://apps/backend/platform/migrations" | |
# dev-url: postgres://postgres:[email protected]:5430/test?sslmode=disable | |
# dir-name: "pixeleye" | |
# - uses: ariga/atlas-action/migrate/push@v1 | |
# if: github.ref == 'refs/heads/main' | |
# with: | |
# dir: "file://apps/backend/platform/migrations" | |
# dev-url: postgres://postgres:[email protected]:5430/test?sslmode=disable | |
# dir-name: "pixeleye" | |
pixeleye: | |
runs-on: ubuntu-latest | |
needs: [node-ci] | |
env: | |
PIXELEYE_TOKEN: ${{ secrets.PIXELEYE_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Capture stories with Pixeleye CLI | |
# Running Pixeleye against your storybook | |
run: pnpm -F @pixeleye/ui pixeleye | |
api-tests: | |
runs-on: ubuntu-latest | |
needs: [golang-ci, node-ci] | |
strategy: | |
fail-fast: false | |
matrix: | |
shard: [1, 2] | |
name: API Tests - ${{matrix.shard}} | |
services: | |
postgres: | |
image: postgres:15-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: pass | |
POSTGRES_DB: test | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
minio: | |
image: bitnami/minio:latest | |
env: | |
MINIO_ROOT_USER: pixeleye | |
MINIO_ROOT_PASSWORD: pixeleye | |
MINIO_DEFAULT_BUCKETS: pixeleye | |
ports: | |
- 9000:9000 | |
rabbitmq: | |
image: rabbitmq:3-alpine | |
env: | |
RABBITMQ_DEFAULT_USER: rabbitmq | |
RABBITMQ_DEFAULT_PASS: rabbitmq | |
ports: | |
- 5672:5672 | |
- 15672:15672 | |
options: --health-cmd "rabbitmq-diagnostics -q check_running" --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Install Atlas | |
run: | | |
curl -sSf https://atlasgo.sh | sh | |
atlas migrate apply --dir file://apps/backend/platform/migrations/ -u 'postgres://postgres:[email protected]:5432/test?sslmode=disable' | |
- name: Setup golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "^1.22" | |
cache-dependency-path: ./apps/backend/go.sum | |
- name: Install go dependencies | |
working-directory: ./apps/backend | |
run: | | |
go mod download | |
go mod verify | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install dependencies node | |
run: pnpm install | |
- name: Run api tests | |
working-directory: ./apps/backend | |
env: | |
BACKEND_URL: http://127.0.0.1:5000 | |
FRONTEND_URL: http://127.0.0.1:3000 | |
AMQP_USER: rabbitmq | |
AMQP_PASSWORD: rabbitmq | |
AMPQ_HOST: 127.0.0.1 | |
AMQP_PORT: 5672 | |
DB_USERNAME: postgres | |
DB_PASSWORD: pass | |
DB_HOST: 127.0.0.1 | |
DB_PORT: 5432 | |
DB_NAME: test | |
DB_SSL_MODE: disable | |
S3_BUCKET: pixeleye | |
S3_ENDPOINT: http://localhost:9000 | |
S3_KEY_SECRET: pixeleye | |
S3_ACCESS_KEY_ID: pixeleye | |
ORY_URL: ${{ secrets.ORY_ENDPOINT }} | |
ORY_ADMIN_URL: ${{ secrets.ORY_ENDPOINT }} | |
ORY_API_KEY: ${{ secrets.ORY_API_KEY }} | |
run: go run main.go & pnpm turbo test:api -- --shard ${{matrix.shard}}/2 | |
migrations-are-alone: | |
name: Migrations are alone | |
runs-on: ubuntu-latest | |
needs: [paths-filter-pr] | |
if: ${{ github.base_ref == 'main' && needs.paths-filter-pr.outputs.migrations == 'true' && (needs.paths-filter-pr.outputs.anythingButMigrations == 'true' ) }} | |
steps: | |
- name: Fail job | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.setFailed('Database migrations should be alone in a PR, please move them to a separate PR') | |
deploy-private-migration-image: | |
name: Deploy database migrations | |
runs-on: ubuntu-latest | |
# needs: [api-tests, atlas-lint, paths-filter] | |
needs: [api-tests, paths-filter] | |
if: ${{ always() && !failure() && !cancelled() && github.ref == 'refs/heads/main' && needs.paths-filter.outputs.migrations == 'true' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.AWS_REGISTRY }}/pixeleye-migrations | |
tags: | | |
latest | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: apps/backend | |
file: apps/backend/Dockerfile.migrations | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy-private-api-image: | |
name: Deploy api image | |
runs-on: ubuntu-latest | |
# needs: [api-tests, atlas-lint, paths-filter] | |
needs: [api-tests, paths-filter] | |
if: ${{ always() && !failure() && !cancelled() && github.ref == 'refs/heads/main' && needs.paths-filter.outputs.backend == 'true' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.AWS_REGISTRY }}/pixeleye-api | |
tags: | | |
latest | |
type=sha | |
# - name: Set up QEMU | |
# uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: apps/backend | |
platforms: linux/arm64 | |
file: apps/backend/Dockerfile.api | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy-private-ingest-image: | |
name: Deploy ingest image | |
runs-on: ubuntu-latest | |
# needs: [api-tests, atlas-lint, paths-filter] | |
needs: [api-tests, paths-filter] | |
if: ${{ always() && !failure() && !cancelled() && github.ref == 'refs/heads/main' && needs.paths-filter.outputs.backend == 'true' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.AWS_REGISTRY }}/pixeleye-ingest | |
tags: | | |
latest | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: apps/backend | |
file: apps/backend/Dockerfile.ingest | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
promote-vercel-prod: | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
needs: | |
[ | |
deploy-private-ingest-image, | |
deploy-private-api-image, | |
deploy-private-migration-image, | |
pixeleye, | |
] | |
if: ${{ always() && !failure() && !cancelled() && github.ref == 'refs/heads/main' }} | |
name: Promote to Vercel Production | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Promote to Vercel Production | |
run: vercel promote --yes --token=${{ secrets.VERCEL_TOKEN }} --scope pixeleye pixeleye-web-git-main-pixeleye.vercel.app | |
continue-on-error: true |