From 2a230a699427e596239edb032560d62e4450521d Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Tue, 12 May 2026 18:39:16 +0200 Subject: [PATCH] feat: add GitHub Actions workflow for testing backend and Flutter components --- .gitea/workflows/test.yml | 131 ++++++++++++++++++++++++++++++++++++++ recipe-app.code-workspace | 6 ++ 2 files changed, 137 insertions(+) create mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 00000000..7e90ee7a --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,131 @@ +name: Test Suite + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + backend-pr-quick: + if: github.event_name == 'pull_request' + runs-on: backend-node24 + + strategy: + matrix: + node-version: [24.15.0] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies (backend) + working-directory: ./backend + run: npm ci + + - name: Prisma schema validate + working-directory: ./backend + run: npx prisma validate --schema prisma/schema.prisma + + - name: Generate Prisma Client + working-directory: ./backend + run: npm run prisma:generate + + - name: Verify generated Prisma client is typed + working-directory: ./backend + run: | + if ! grep -q "export \* from '.prisma/client/default'" node_modules/@prisma/client/index.d.ts; then + echo "Prisma client export is unexpected" + exit 1 + fi + + - name: Build NestJS app + working-directory: ./backend + run: npm run build + + backend-full: + if: github.event_name == 'push' + runs-on: backend-node24 + + strategy: + matrix: + node-version: [24.15.0] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies (backend) + working-directory: ./backend + run: npm ci + + - name: Prisma schema validate + working-directory: ./backend + run: npx prisma validate --schema prisma/schema.prisma + + - name: Generate Prisma Client + working-directory: ./backend + run: npm run prisma:generate + + - name: Verify generated Prisma client is typed + working-directory: ./backend + run: | + if ! grep -q "export \* from '.prisma/client/default'" node_modules/@prisma/client/index.d.ts; then + echo "Prisma client export is unexpected" + exit 1 + fi + + - name: Dependency audit (high+critical) + working-directory: ./backend + run: npm audit --audit-level=high + + - name: Run tests (backend) + working-directory: ./backend + run: npm test + + - name: Build NestJS app + working-directory: ./backend + run: npm run build + + flutter-quality: + runs-on: flutter-3-41 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.41.9' + + - name: Install dependencies (flutter) + working-directory: ./flutter + run: flutter pub get + + - name: Analyze Flutter code + working-directory: ./flutter + run: flutter analyze + + - name: Set Flutter test mode + shell: bash + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "FLUTTER_TEST_CMD=flutter test --reporter=compact" >> "$GITHUB_ENV" + else + echo "FLUTTER_TEST_CMD=flutter test" >> "$GITHUB_ENV" + fi + + - name: Run Flutter tests + working-directory: ./flutter + run: ${{ env.FLUTTER_TEST_CMD }} diff --git a/recipe-app.code-workspace b/recipe-app.code-workspace index 876a1499..1718cde1 100644 --- a/recipe-app.code-workspace +++ b/recipe-app.code-workspace @@ -2,6 +2,12 @@ "folders": [ { "path": "." + }, + { + "path": "../microservice-importer" + }, + { + "path": "../recipe-gitea-runner" } ], "settings": {}