|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint-and-test: |
| 11 | + name: Lint & Unit Tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [18.x, 20.x, 22.x] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: ${{ matrix.node-version }} |
| 26 | + cache: "npm" |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Check Formatting (Prettier) |
| 32 | + run: npm run lint:check |
| 33 | + |
| 34 | + - name: Build |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Run Unit Tests |
| 38 | + run: npm run test:unit |
| 39 | + |
| 40 | + e2e-postgres: |
| 41 | + name: E2E Tests (PostgreSQL) |
| 42 | + runs-on: ubuntu-latest |
| 43 | + needs: lint-and-test |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Setup Node.js 20.x |
| 50 | + uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version: 20.x |
| 53 | + cache: "npm" |
| 54 | + |
| 55 | + - name: Install dependencies & Build |
| 56 | + run: | |
| 57 | + npm ci |
| 58 | + npm run build |
| 59 | + npm link |
| 60 | +
|
| 61 | + - name: Install PostgreSQL Client Tools |
| 62 | + run: sudo apt-get update && sudo apt-get install -y postgresql-client |
| 63 | + |
| 64 | + - name: Start PostgreSQL Database (Docker) |
| 65 | + run: npm run test:e2e:pgsql:up |
| 66 | + |
| 67 | + - name: Run E2E Tests for PostgreSQL |
| 68 | + run: npm run test:e2e:pgsql |
| 69 | + |
| 70 | + - name: Teardown Database |
| 71 | + if: always() # Garante que os containers morram mesmo se o teste falhar |
| 72 | + run: npm run test:e2e:pgsql:down |
| 73 | + |
| 74 | + e2e-mysql: |
| 75 | + name: E2E Tests (MySQL) |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: lint-and-test |
| 78 | + |
| 79 | + steps: |
| 80 | + - name: Checkout code |
| 81 | + uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Setup Node.js 20.x |
| 84 | + uses: actions/setup-node@v4 |
| 85 | + with: |
| 86 | + node-version: 20.x |
| 87 | + cache: "npm" |
| 88 | + |
| 89 | + - name: Install dependencies & Build |
| 90 | + run: | |
| 91 | + npm ci |
| 92 | + npm run build |
| 93 | + npm link |
| 94 | +
|
| 95 | + - name: Install MySQL Client Tools |
| 96 | + run: sudo apt-get update && sudo apt-get install -y mysql-client |
| 97 | + |
| 98 | + - name: Start MySQL Database (Docker) |
| 99 | + run: npm run test:e2e:mysql:up |
| 100 | + |
| 101 | + - name: Run E2E Tests for MySQL |
| 102 | + run: npm run test:e2e:mysql |
| 103 | + |
| 104 | + - name: Teardown Database |
| 105 | + if: always() |
| 106 | + run: npm run test:e2e:mysql:down |
0 commit comments