Integrate e2e tests. #2
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: Docker Build & Push | |
| on: | |
| push: | |
| branches: [ main ] | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_BACKEND: ${{ secrets.DOCKERHUB_USERNAME }}/task-backend | |
| IMAGE_FRONTEND: ${{ secrets.DOCKERHUB_USERNAME }}/task-frontend | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Backend Image | |
| - name: Build and push backend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./backend | |
| push: true | |
| tags: ${{ env.IMAGE_BACKEND }}:latest | |
| # Frontend Image | |
| - name: Build and push frontend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./frontend | |
| push: true | |
| tags: ${{ env.IMAGE_FRONTEND }}:latest | |
| e2e-tests: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| steps: | |
| - name: Pull and run containers | |
| run: | | |
| docker run -d -p 4000:4000 --name backend ${{ secrets.DOCKERHUB_USERNAME }}/task-backend:latest | |
| docker run -d -p 5173:80 --name frontend ${{ secrets.DOCKERHUB_USERNAME }}/task-frontend:latest | |
| - name: Wait for services | |
| run: | | |
| npx wait-on http://localhost:4000/tasks | |
| npx wait-on http://localhost:5173 | |
| - name: Run E2E Tests | |
| working-directory: e2e | |
| run: npx playwright test |