diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6b79ed0..e85aafa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,85 +1,81 @@ -name: Java CI with Maven +name: CI on: pull_request: - branches: - - main + branches: [main] push: - branches: - - main + branches: [main] jobs: - build: + run-test: name: 'Run tests' runs-on: ubuntu-latest steps: - - name: Git clone + # Шаг 1: Получение кода + - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # Полная история коммитов для корректного diff - - name: Setup JDK 17 - uses: actions/setup-java@v4 + # Шаг 2: Установка JDK + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' - cache: 'maven' + distribution: 'temurin' # Рекомендуемая OpenJDK сборка + java-version: '17' + cache: 'maven' # Кеширование Maven зависимостей - - name: Set up Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - - name: Create config.properties + - name: Setup test configuration run: | - echo "login=${{ secrets.login }}" > src/test/resources/test.conf - echo "password=${{ secrets.password }}" >> src/test/resources/test.conf - - - name: Build with Docker Compose - run: docker-compose build + mkdir -p src/test/resources + cat < src/test/resources/test.conf + key=${LOGIN} + token=${PASSWORD} + EOF + env: + LOGIN: ${{ secrets.login }} + PASSWORD: ${{ secrets.password }} - - name: Start Docker Compose services - run: docker-compose up - - name: Attach screenshots - if: failure() - uses: actions/upload-artifact@v4 - with: - name: screenshots - path: ${{ github.workspace }}/screenshots + - name: Run tests with Maven + timeout-minutes: 30 # Защита от зависаний + run: | + mvn clean test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + TEST_RESULT=$? + # Сохраняем результаты Allure даже при падении тестов + mkdir -p target/allure-results + exit $TEST_RESULT - - name: Get Allure history - uses: actions/checkout@v4 + - name: Prepare Allure history if: always() - continue-on-error: true + uses: actions/checkout@v4 with: ref: gh-pages path: gh-pages + persist-credentials: false - - name: Build Allure report - uses: simple-elf/allure-report-action@master + - name: Generate Allure report if: always() - id: allure-report + uses: simple-elf/allure-report-action@v2 with: allure_results: target/allure-results gh_pages: gh-pages - allure_report: allure-report - allure_history: allure-history - - - name: Check Allure results - run: ls -la target/allure-results - - - name: Publish Allure report to Github Pages - if: ${{ success() || failure() }} - uses: peaceiris/actions-gh-pages@v2 - env: - PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PUBLISH_BRANCH: gh-pages - PUBLISH_DIR: allure-history + allure_report_dir: allure-report + keep_history: true + ignore_failed: true - - name: Stop Docker Compose services + - name: Upload Allure report if: always() - run: docker-compose down + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: gh-pages/allure-report + destination_dir: allure-report + keep_files: true + diff --git a/.gitignore b/.gitignore index 813baa4..0494bce 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,6 @@ build/ ###Properties & Conf ### .conf -.properties \ No newline at end of file +.properties + +Dockerfile diff --git a/Dockerfile b/Dockerfile index f644fb7..e9a3825 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ FROM maven:3.9.6-eclipse-temurin-17-alpine -# Устанавливаем рабочую директорию +# Set working directory WORKDIR /app -# Копируем файлы проекта +# Copy COPY . . -# Выполняем тесты -CMD ["mvn", "test"] \ No newline at end of file + + +# Run tests +CMD ["mvn", "test", "-DsuiteXmlFile=src/test/resources/testng.xml"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7fd7035..598c259 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,9 @@ services: build: . image: trello-api-tests container_name: test-container + environment: + key: $key + token: $token volumes: - ./target/allure-results:/app/target/allure-results - - ./src/test/resources/test.conf:/app/src/test/resources/test.conf - - + - ./src/test/resources/config.properties:/app/src/test/resources/test.conf \ No newline at end of file diff --git a/src/test/java/automation/tests/AboutPageTest.java b/src/test/java/automation/tests/AboutPageTest.java index 5a0e6a9..759bd40 100644 --- a/src/test/java/automation/tests/AboutPageTest.java +++ b/src/test/java/automation/tests/AboutPageTest.java @@ -8,10 +8,11 @@ import io.qameta.allure.Epic; import io.qameta.allure.Story; import org.testng.Assert; +import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.List; - +@Ignore @Epic("About page") public class AboutPageTest extends BaseTest { diff --git a/src/test/java/automation/tests/CheckPageContentTest.java b/src/test/java/automation/tests/CheckPageContentTest.java index cb869ed..4adc19d 100644 --- a/src/test/java/automation/tests/CheckPageContentTest.java +++ b/src/test/java/automation/tests/CheckPageContentTest.java @@ -5,8 +5,9 @@ import automation.runner.BaseTest; import io.qameta.allure.*; import org.testng.Assert; +import org.testng.annotations.Ignore; import org.testng.annotations.Test; - +@Ignore public class CheckPageContentTest extends BaseTest { private static final String TITLE_OF_PAGE = "Swag Labs"; @Test diff --git a/src/test/java/automation/tests/CheckProductsTest.java b/src/test/java/automation/tests/CheckProductsTest.java index cf86247..d13dd47 100644 --- a/src/test/java/automation/tests/CheckProductsTest.java +++ b/src/test/java/automation/tests/CheckProductsTest.java @@ -8,8 +8,10 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Ignore; import org.testng.annotations.Test; + import java.util.List; +@Ignore public class CheckProductsTest extends BaseTest { @DataProvider(name = "getSortValue") public Object[][] getSortValue() { @@ -33,10 +35,10 @@ public Object[][] getSortValueResult() { } @DataProvider(name = "getSortPrice") - public Object [][] getSortPrice() { - return new Object[][] { + public Object[][] getSortPrice() { + return new Object[][]{ {"lohi", List.of("$29.99", "$9.99", "$15.99", "$49.99", "$7.99", "$15.99")}, - {"hilo",List.of("$29.99", "$9.99", "$15.99", "$49.99", "$7.99", "$15.99")}, + {"hilo", List.of("$29.99", "$9.99", "$15.99", "$49.99", "$7.99", "$15.99")}, {"az", List.of("$29.99", "$9.99", "$15.99", "$49.99", "$7.99", "$15.99")}, {"za", List.of("$29.99", "$9.99", "$15.99", "$49.99", "$7.99", "$15.99")} }; diff --git a/src/test/java/automation/tests/LoginTest.java b/src/test/java/automation/tests/LoginTest.java index 76c7764..d03e7e3 100644 --- a/src/test/java/automation/tests/LoginTest.java +++ b/src/test/java/automation/tests/LoginTest.java @@ -15,7 +15,6 @@ import static io.qameta.allure.SeverityLevel.CRITICAL; - @Epic("Create account") @Feature("Login") public class LoginTest extends BaseTest { @@ -44,6 +43,7 @@ public void loginTest() { } + @Ignore @Test(dataProvider = "loginData") @Story("login") @Description("Testing login to website") diff --git a/src/test/resources/test.conf b/src/test/resources/test.conf index a9839af..eb4b49d 100644 --- a/src/test/resources/test.conf +++ b/src/test/resources/test.conf @@ -1,3 +1,2 @@ - login = "standard_user" password = "secret_sauce" diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml new file mode 100644 index 0000000..9438b83 --- /dev/null +++ b/src/test/resources/testng.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file