chore: update E2E workflow to define environment variables for projec… #8
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: E2E Tests | |
| on: [push, pull_request] | |
| jobs: | |
| cypress-run: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Faz o checkout do código | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # 2️⃣ Instala o pnpm | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| # 3️⃣ Instala Node.js com cache do pnpm | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'pnpm' | |
| # 4️⃣ Instala dependências | |
| - name: Install dependencies | |
| run: pnpm install | |
| # 5️⃣ Cache do binário do Cypress | |
| - name: Cache Cypress binary | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/Cypress | |
| key: cypress-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| # 6️⃣ Instala binário do Cypress | |
| - name: Install Cypress binary | |
| run: pnpm cypress install | |
| # 7️⃣ Build do projeto — agora com as variáveis definidas | |
| - name: Build project | |
| run: pnpm build | |
| env: | |
| NODE_ENV: production | |
| APP_URL: 'http://localhost:3000' | |
| NEXT_PUBLIC_API_BASE_URL: 'https://devstore-api-lilac.vercel.app/' | |
| # 8️⃣ Inicia o servidor em segundo plano | |
| - name: Start Next.js server | |
| run: pnpm start & | |
| env: | |
| NODE_ENV: production | |
| APP_URL: 'http://localhost:3000' | |
| NEXT_PUBLIC_API_BASE_URL: 'https://devstore-api-lilac.vercel.app/' | |
| # 9️⃣ Aguarda o servidor estar disponível | |
| - name: Wait for server to be ready | |
| run: npx wait-on http://localhost:3000 | |
| # 🔟 Executa os testes E2E | |
| - name: Run Cypress tests | |
| run: pnpm cypress run | |
| env: | |
| APP_URL: 'http://localhost:3000' | |
| NEXT_PUBLIC_API_BASE_URL: 'https://devstore-api-lilac.vercel.app/' |