test: Add Pact mock server #648
This file contains hidden or 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: Online Shop | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| jobs: | |
| build-client: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: customer-client | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: customer-client/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check Prettier formatting | |
| run: npm run format:check | |
| - name: Lint | |
| run: npm run lint | |
| - name: Build | |
| run: npm run build | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps chromium | |
| working-directory: customer-client | |
| - name: Run Playwright tests | |
| run: npm run test | |
| working-directory: customer-client | |
| - name: Upload pact files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pact-files | |
| path: pacts/ | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: playwright-report | |
| path: customer-client/playwright-report/ | |
| build: | |
| needs: build-client | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Download pact files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pact-files | |
| path: pacts/ | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: customer-client/package-lock.json | |
| - name: Install customer-client dependencies | |
| run: npm ci | |
| working-directory: customer-client | |
| - name: Build customer-client | |
| run: npm run build | |
| working-directory: customer-client | |
| - name: Build customer-service | |
| run: mvn clean package -f customer-service/pom.xml -Dservice.name=customer-service | |
| - name: Build billing-service | |
| run: mvn clean package -f billing-service/pom.xml -Dservice.name=billing-service | |
| - name: Build delivery-service | |
| run: mvn clean package -f delivery-service/pom.xml -Dservice.name=delivery-service | |
| - name: Build address-validation-service | |
| run: mvn clean package -f address-validation-service/pom.xml -Dservice.name=address-validation-service | |
| - name: Build with Docker | |
| run: docker compose build | |
| - name: Start with Docker | |
| run: docker compose up -d | |
| - name: Wait for customer-service | |
| run: | | |
| until curl -sf http://localhost:8181/customers/ > /dev/null; do | |
| echo "Waiting for customer-service..." | |
| sleep 2 | |
| done | |
| - name: Stop Docker Containers | |
| if: always() | |
| run: docker compose down |