|
| 1 | +name: Process E2E Testing |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + process-e2e-test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up Node.js |
| 17 | + uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: 23 |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + npm install -g pnpm |
| 24 | + pnpm install --frozen-lockfile |
| 25 | + npx cypress install |
| 26 | +
|
| 27 | + - name: Create .env file for Testing |
| 28 | + run: | |
| 29 | + echo "NEXT_PUBLIC_BASE_URL=http://localhost:3000" >> .env |
| 30 | + echo "NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY=sample_key" >> .env |
| 31 | + echo "NEXT_PUBLIC_GA_ID=sample_id" >> .env |
| 32 | + echo "NEXT_PUBLIC_SENTRY_AUTH_TOKEN=sample_token" >> .env |
| 33 | + echo "NEXT_PUBLIC_SENTRY_DSN=sample_dsn" >> .env |
| 34 | +
|
| 35 | + - name: Start application server |
| 36 | + run: | |
| 37 | + pnpm dev & |
| 38 | + env: |
| 39 | + CI: true |
| 40 | + |
| 41 | + - name: Wait for server |
| 42 | + run: npx wait-on http://localhost:3000 --timeout 60000 |
| 43 | + |
| 44 | + - name: Run Cypress tests |
| 45 | + uses: cypress-io/github-action@v6 |
| 46 | + with: |
| 47 | + browser: chrome |
| 48 | + headless: true |
| 49 | + record: false |
| 50 | + wait-on: 'http://localhost:3000' |
| 51 | + wait-on-timeout: 120 |
| 52 | + install: false |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + NEXT_PUBLIC_BASE_URL: 'http://localhost:3000' |
| 56 | + NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY: 'sample_key' |
| 57 | + NEXT_PUBLIC_GA_ID: 'sample_id' |
| 58 | + NEXT_PUBLIC_SENTRY_AUTH_TOKEN: 'sample_token' |
| 59 | + NEXT_PUBLIC_SENTRY_DSN: 'sample_dsn' |
| 60 | + |
| 61 | + # KST 시간을 GitHub Actions 환경 변수에 세팅 |
| 62 | + - name: Get Current KST Time |
| 63 | + run: echo "KST_TIME=$(TZ=Asia/Seoul date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV |
| 64 | + |
| 65 | + - name: Upload screenshots |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + if: failure() |
| 68 | + with: |
| 69 | + name: cypress-screenshots |
| 70 | + path: cypress/screenshots |
| 71 | + |
| 72 | + - name: Send Slack Notification on Failure |
| 73 | + |
| 74 | + if: failure() |
| 75 | + with: |
| 76 | + payload: | |
| 77 | + { |
| 78 | + "text": "*❌ FE E2E CI Test was failed*\n\n📅 *Timestamp (KST):* ${{ env.KST_TIME }}\n\n🔗 *Workflow URL:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>\n\n🔗 *Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\n\n📸 *Screenshots:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts|Download Screenshots>" |
| 79 | + } |
| 80 | + env: |
| 81 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
0 commit comments