From 6e84848d81bbcef68dad479ebc068c1bb43bb1b2 Mon Sep 17 00:00:00 2001 From: ptchela Date: Sun, 9 Mar 2025 19:28:12 +0300 Subject: [PATCH] Update CI --- .github/workflows/selenium_test.yml | 150 +++++++++++++++++++++------- 1 file changed, 116 insertions(+), 34 deletions(-) diff --git a/.github/workflows/selenium_test.yml b/.github/workflows/selenium_test.yml index d63bbec..7424c95 100644 --- a/.github/workflows/selenium_test.yml +++ b/.github/workflows/selenium_test.yml @@ -1,60 +1,142 @@ -name: selenium_test +name: Java CI with Maven on: - push: - branches: [main] pull_request: - branches: [main] + branches: [ main ] permissions: + contents: write + pages: write + id-token: write + actions: read checks: write - pull-requests: write - contents: read jobs: - selenium_test: - runs-on: ubuntu-latest + build: + name: Build On + + strategy: + max-parallel: 4 + matrix: + os: [ ubuntu-latest, windows-latest, macos-13 ] + + runs-on: ${{ matrix.os }} + steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Clone code from repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - distribution: temurin java-version: '17' + distribution: 'corretto' + cache: maven - - name: Cache Maven repository - uses: actions/cache@v3 + - name: Cache m2 dependencies + uses: actions/cache@v4.0.2 with: - path: ~/.m2 + path: .m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- + restore-keys: | + ${{ runner.os }}-maven- - - name: Install Chrome - uses: browser-actions/setup-chrome@latest + - name: Install Firefox on MacOS + if: ${{ matrix.os == 'macos-13' }} + run: brew install --cask firefox - - name: Run Maven tests - run: mvn clean test + - name: Build with Maven for Ubuntu and macOS + if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-13' }} + run: mvn clean -e install -Dmaven.test.skip=true - - name: Upload Surefire Reports (for debugging) - if: failure() # Загружаем отчеты только в случае ошибки - uses: actions/upload-artifact@v4 + - name: Build with Maven for Windows + if: ${{ matrix.os == 'windows-latest' }} + run: mvn clean -e install '-Dmaven.test.skip=true' + + - name: Set CI_RUN Environment Variable + run: echo "CI_RUN=true" >> $GITHUB_ENV + + - name: Run Framework test + run: mvn test -Dtest=FrameworkTest + + - name: Run tests with Maven on Windows with Firefox + if: ${{ matrix.os == 'windows-latest' }} + run: mvn test -Pfirefox '-Dsurefire.reportNameSuffix=firefox' + + - name: Run tests with Maven on macOS with Firefox + if: ${{ matrix.os == 'macos-13' }} + run: mvn test -Pfirefox -Dsurefire.reportNameSuffix=firefox + + - name: Run tests with Maven on Windows with Chrome + if: ${{ matrix.os == 'windows-latest' }} + run: mvn test -Pchrome '-Dsurefire.reportNameSuffix=chrome' + + - name: Run tests with Maven on macOS with Chrome + if: ${{ matrix.os == 'macos-13' }} + run: mvn test -Pchrome -Dsurefire.reportNameSuffix=chrome + + - name: Run 'Smoke' group tests on Ubuntu + if: ${{ matrix.os == 'ubuntu-latest' }} + run: mvn test -Psmoke + + - name: Run 'Regression' group tests on Ubuntu + if: ${{ matrix.os == 'ubuntu-latest' }} + run: mvn test -Pregression + + - name: Run cross-browser testing on Ubuntu with Chrome and Firefox + if: ${{ matrix.os == 'ubuntu-latest' }} + run: mvn test -PcrossBrowser + + - name: Run File loading test + if: ${{ matrix.os == 'ubuntu-latest' }} + run: mvn test -Dtest=FileLoadingTest + + - name: Test Reporter + uses: dorny/test-reporter@v1.9.1 + if: success() || failure() with: - name: surefire-reports - path: target/surefire-reports + name: Opencart project test report for ${{ matrix.os }} + path: target/surefire-reports/TEST-*.xml + reporter: java-junit - - name: Generate Allure Report - run: mvn allure:report + - name: Load Allure test report history + uses: actions/checkout@v4 + if: ${{ matrix.os == 'ubuntu-latest' }} + continue-on-error: true + with: + ref: gh-pages + path: gh-pages - - name: Upload Allure Report Artifact - uses: actions/upload-artifact@v4 + - name: Build Allure test report + uses: simple-elf/allure-report-action@v1.7 + if: ${{ matrix.os == 'ubuntu-latest' }} with: - name: allure-report - path: target/site/allure-maven-plugin + gh_pages: gh-pages + allure_history: allure-history + allure_results: target/allure-results - - name: Deploy Allure Report to GitHub Pages + - name: Publish Allure test report uses: peaceiris/actions-gh-pages@v3 + if: ${{ matrix.os == 'ubuntu-latest' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: allure-history + + - name: Attach screenshots + uses: actions/upload-artifact@v4 + if: always() + with: + path: screenshots + + check-java-code-style: + name: Check Java code style + runs-on: ubuntu-latest + + steps: + - name: Clone code from repo + uses: actions/checkout@v4 with: - github_token: ${{ secrets.EPOLIF_TOKEN }} - publish_dir: target/site/allure-maven-plugin + fetch-depth: 0 \ No newline at end of file