diff --git a/.github/workflows/test-runner.yaml b/.github/workflows/test-runner.yaml new file mode 100644 index 0000000000..934da60b3d --- /dev/null +++ b/.github/workflows/test-runner.yaml @@ -0,0 +1,75 @@ +name: Run API & Selenium Tests Separately + +on: + push: + branches: [ main, dev ] + pull_request: + branches: [ main, dev ] + +jobs: + api-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest Test Image + run: docker pull moslemasaad/gitea-test-automation + + - name: Run API Tests + run: | + cd Gitea-Test-Automation + docker-compose up --exit-code-from api-test-runner api-test-runner + + - name: Stop API Containers + run: | + cd Gitea-Test-Automation + docker-compose down + + selenium-tests: + runs-on: ubuntu-latest + needs: api-tests + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest Test Image + run: docker pull moslemasaad/gitea-test-automation + + - name: Start Selenium Grid & Run Selenium Tests + run: | + cd Gitea-Test-Automation + docker-compose up --exit-code-from selenium-test-runner selenium-hub chrome-node firefox-node selenium-test-runner + + - name: Stop Selenium Containers + run: | + cd Gitea-Test-Automation + docker-compose down diff --git a/Gitea-Test-Automation/docker-compose.yaml b/Gitea-Test-Automation/docker-compose.yaml new file mode 100644 index 0000000000..5fcacdade2 --- /dev/null +++ b/Gitea-Test-Automation/docker-compose.yaml @@ -0,0 +1,54 @@ +version: "3.8" + +services: + # API Test Runner - Runs first, then stops + api-test-runner: + image: moslemasaad/gitea-test-automation + container_name: api-test-runner + environment: + - GITEA_API_TOKEN=9829d39ece8b5ad3a7dcf2c8b273b55043ceaca6 + - Password=80517moslem + command: mvn clean test -Dtest=**/apiTests/* + + # Selenium Grid Hub + selenium-hub: + image: selenium/hub:latest + container_name: selenium-hub + ports: + - "4444:4444" + + # Chrome Node + chrome-node: + image: selenium/node-chrome:latest + container_name: selenium-chrome + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + shm_size: "2g" + + # Firefox Node + firefox-node: + image: selenium/node-firefox:latest + container_name: selenium-firefox + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + shm_size: "2g" + + # Selenium Test Runner - Runs after API tests + selenium-test-runner: + image: moslemasaad/gitea-test-automation + container_name: selenium-test-runner + depends_on: + - selenium-hub + environment: + - GITEA_API_TOKEN=9829d39ece8b5ad3a7dcf2c8b273b55043ceaca6 + - Password=80517moslem + - GRID_URL=http://selenium-hub:4444/ + command: mvn clean test -Dtest=**/seleniumTests/*