diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000..90842a51aa7ed --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Build and Test + +on: + push: + branches: [ dev ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go environment + uses: actions/setup-go@v3 + with: + go-version: '1.23.4' + + - name: Install dependencies + run: go mod download + + - name: Run unit tests + run: go test ./... -v + continue-on-error: true + + - name: Run linting + run: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + golangci-lint run + + - name: Build Docker image + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gitea:latest . + + - name: Log in to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push Docker image + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/gitea:latest diff --git a/.github/workflows/notification-service.yml b/.github/workflows/notification-service.yml new file mode 100644 index 0000000000000..6350117d0c089 --- /dev/null +++ b/.github/workflows/notification-service.yml @@ -0,0 +1,28 @@ +name: Run Notification Service Tests + +on: + pull_request: + branches: + - main + +jobs: + notification-service-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: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest notification service Image + run: docker pull moslemasaad/gitea-notificator + + - name: Run Tests + run: docker run --rm moslemasaad/gitea-notificator test \ No newline at end of file diff --git a/.github/workflows/preproduction.yml b/.github/workflows/preproduction.yml new file mode 100644 index 0000000000000..e450a238b295d --- /dev/null +++ b/.github/workflows/preproduction.yml @@ -0,0 +1,185 @@ +name: Pre Production tests + +on: + push: + branches: + - main + +permissions: + contents: read + actions: read + checks: write + +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 + + notification-service-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: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest notification service Image + run: docker pull moslemasaad/gitea-notificator + + - name: Run Tests + run: docker run --rm moslemasaad/gitea-notificator test + + jmeter: + name: Run JMeter Tests + needs: [api-tests, selenium-tests, notification-service-tests] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run JMeter Action on a test + uses: rbhadti94/apache-jmeter-action@v0.5.0 + with: + testFilePath: tests/jmeter/gite-test-plan.jmx + outputReportsFolder: reports/ + args: "--loglevel INFO" + + - name: Upload JMeter Test Results + uses: actions/upload-artifact@v4 + with: + name: jmeter-test-results + path: reports/ + + lighthouse-tests: + runs-on: ubuntu-latest + needs: [api-tests, selenium-tests, notification-service-tests] + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install Lighthouse CLI + run: npm install -g lighthouse + + - name: Run Lighthouse Performance Audit + run: | + mkdir -p reports + lighthouse https://fox-one-promptly.ngrok-free.app \ + --output=json \ + --output=html \ + --output-path=reports/lighthouse.html \ + --chrome-flags="--headless" + + - name: Debug - List Files + run: ls -alh reports + + - name: Upload Lighthouse Report + uses: actions/upload-artifact@v4 + with: + name: lighthouse-report + path: reports/lighthouse.report.html + + + +# name: Load Testing with JMeter + +# on: +# push: +# branches: +# - main + +# permissions: +# contents: read +# actions: read +# checks: write + +# jobs: +# jmeter: +# name: Run JMeter Tests +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v4 + +# - name: Run JMeter Action on a test +# uses: rbhadti94/apache-jmeter-action@v0.5.0 +# with: +# testFilePath: tests/jmeter/gite-test-plan.jmx +# outputReportsFolder: reports/ +# args: "--loglevel INFO" + +# - name: Upload JMeter Test Results +# uses: actions/upload-artifact@v4 +# with: +# name: jmeter-test-results +# path: reports/ \ No newline at end of file diff --git a/.github/workflows/test-runner.yaml b/.github/workflows/test-runner.yaml new file mode 100644 index 0000000000000..b6f7f6aba0c15 --- /dev/null +++ b/.github/workflows/test-runner.yaml @@ -0,0 +1,74 @@ +name: Run API & Selenium Tests Separately + +on: + pull_request: + branches: + - main + +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 0000000000000..5fcacdade22c5 --- /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/* diff --git a/tests/jmeter/gite-test-plan.jmx b/tests/jmeter/gite-test-plan.jmx new file mode 100644 index 0000000000000..16ac28b68d3f1 --- /dev/null +++ b/tests/jmeter/gite-test-plan.jmx @@ -0,0 +1,55 @@ + + + + + + + + + + + 100 + 25 + true + continue + + 1 + false + + + + + / + true + GET + true + false + + + + + + + /moslem + true + GET + true + false + + + + + + + fox-one-promptly.ngrok-free.app + http + + + + HttpClient4 + + + + + +