diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ada680e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: [master, main] + pull_request: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 20 + + services: + postgres: + image: postgres:17 + env: + POSTGRES_USER: musicshare + POSTGRES_PASSWORD: musicshare + POSTGRES_DB: musicshare_test + ports: ['5432:5432'] + options: >- + --health-cmd "pg_isready -U musicshare" + --health-interval 5s --health-timeout 5s --health-retries 10 + redis: + image: redis:7 + ports: ['6379:6379'] + options: >- + --health-cmd "redis-cli ping" + --health-interval 5s --health-timeout 5s --health-retries 10 + + env: + TEST_DATABASE_URL: postgres://musicshare:musicshare@localhost:5432/musicshare_test + TEST_REDIS_URL: redis://localhost:6379/1 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - run: npm ci + + - name: Typecheck + run: npx turbo run typecheck + + - name: Lint + run: npx turbo run lint + + - name: Test + run: npx turbo run test + + - name: Check migrations match the schema + working-directory: apps/api + run: | + npx drizzle-kit generate --name ci-check + if [ -n "$(git status --porcelain drizzle)" ]; then + echo "::error::schema.ts has changes without a migration. Run 'npm run db:generate' and commit the result." + git status --porcelain drizzle + exit 1 + fi + + - name: Build web + run: npx turbo run build --filter=@musicshare/web + env: + NEXT_PUBLIC_API_URL: https://api.example.com + + - name: Bundle mobile (iOS + Android) + working-directory: apps/mobile + run: npx expo export --platform ios --platform android --output-dir /tmp/expo-export + env: + EXPO_PUBLIC_API_URL: https://api.example.com