Skip to content

Commit 872bce8

Browse files
authored
Update CI (#21)
1 parent 49cdcad commit 872bce8

1 file changed

Lines changed: 116 additions & 34 deletions

File tree

Lines changed: 116 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,142 @@
1-
name: selenium_test
1+
name: Java CI with Maven
22

33
on:
4-
push:
5-
branches: [main]
64
pull_request:
7-
branches: [main]
5+
branches: [ main ]
86

97
permissions:
8+
contents: write
9+
pages: write
10+
id-token: write
11+
actions: read
1012
checks: write
11-
pull-requests: write
12-
contents: read
1313

1414
jobs:
15-
selenium_test:
16-
runs-on: ubuntu-latest
15+
build:
16+
name: Build On
17+
18+
strategy:
19+
max-parallel: 4
20+
matrix:
21+
os: [ ubuntu-latest, windows-latest, macos-13 ]
22+
23+
runs-on: ${{ matrix.os }}
24+
1725
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v3
26+
- name: Clone code from repo
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
2030

2131
- name: Set up JDK 17
22-
uses: actions/setup-java@v3
32+
uses: actions/setup-java@v4
2333
with:
24-
distribution: temurin
2534
java-version: '17'
35+
distribution: 'corretto'
36+
cache: maven
2637

27-
- name: Cache Maven repository
28-
uses: actions/cache@v3
38+
- name: Cache m2 dependencies
39+
uses: actions/cache@v4.0.2
2940
with:
30-
path: ~/.m2
41+
path: .m2/repository
3142
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
32-
restore-keys: ${{ runner.os }}-maven-
43+
restore-keys: |
44+
${{ runner.os }}-maven-
3345
34-
- name: Install Chrome
35-
uses: browser-actions/setup-chrome@latest
46+
- name: Install Firefox on MacOS
47+
if: ${{ matrix.os == 'macos-13' }}
48+
run: brew install --cask firefox
3649

37-
- name: Run Maven tests
38-
run: mvn clean test
50+
- name: Build with Maven for Ubuntu and macOS
51+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-13' }}
52+
run: mvn clean -e install -Dmaven.test.skip=true
3953

40-
- name: Upload Surefire Reports (for debugging)
41-
if: failure() # Загружаем отчеты только в случае ошибки
42-
uses: actions/upload-artifact@v4
54+
- name: Build with Maven for Windows
55+
if: ${{ matrix.os == 'windows-latest' }}
56+
run: mvn clean -e install '-Dmaven.test.skip=true'
57+
58+
- name: Set CI_RUN Environment Variable
59+
run: echo "CI_RUN=true" >> $GITHUB_ENV
60+
61+
- name: Run Framework test
62+
run: mvn test -Dtest=FrameworkTest
63+
64+
- name: Run tests with Maven on Windows with Firefox
65+
if: ${{ matrix.os == 'windows-latest' }}
66+
run: mvn test -Pfirefox '-Dsurefire.reportNameSuffix=firefox'
67+
68+
- name: Run tests with Maven on macOS with Firefox
69+
if: ${{ matrix.os == 'macos-13' }}
70+
run: mvn test -Pfirefox -Dsurefire.reportNameSuffix=firefox
71+
72+
- name: Run tests with Maven on Windows with Chrome
73+
if: ${{ matrix.os == 'windows-latest' }}
74+
run: mvn test -Pchrome '-Dsurefire.reportNameSuffix=chrome'
75+
76+
- name: Run tests with Maven on macOS with Chrome
77+
if: ${{ matrix.os == 'macos-13' }}
78+
run: mvn test -Pchrome -Dsurefire.reportNameSuffix=chrome
79+
80+
- name: Run 'Smoke' group tests on Ubuntu
81+
if: ${{ matrix.os == 'ubuntu-latest' }}
82+
run: mvn test -Psmoke
83+
84+
- name: Run 'Regression' group tests on Ubuntu
85+
if: ${{ matrix.os == 'ubuntu-latest' }}
86+
run: mvn test -Pregression
87+
88+
- name: Run cross-browser testing on Ubuntu with Chrome and Firefox
89+
if: ${{ matrix.os == 'ubuntu-latest' }}
90+
run: mvn test -PcrossBrowser
91+
92+
- name: Run File loading test
93+
if: ${{ matrix.os == 'ubuntu-latest' }}
94+
run: mvn test -Dtest=FileLoadingTest
95+
96+
- name: Test Reporter
97+
uses: dorny/test-reporter@v1.9.1
98+
if: success() || failure()
4399
with:
44-
name: surefire-reports
45-
path: target/surefire-reports
100+
name: Opencart project test report for ${{ matrix.os }}
101+
path: target/surefire-reports/TEST-*.xml
102+
reporter: java-junit
46103

47-
- name: Generate Allure Report
48-
run: mvn allure:report
104+
- name: Load Allure test report history
105+
uses: actions/checkout@v4
106+
if: ${{ matrix.os == 'ubuntu-latest' }}
107+
continue-on-error: true
108+
with:
109+
ref: gh-pages
110+
path: gh-pages
49111

50-
- name: Upload Allure Report Artifact
51-
uses: actions/upload-artifact@v4
112+
- name: Build Allure test report
113+
uses: simple-elf/allure-report-action@v1.7
114+
if: ${{ matrix.os == 'ubuntu-latest' }}
52115
with:
53-
name: allure-report
54-
path: target/site/allure-maven-plugin
116+
gh_pages: gh-pages
117+
allure_history: allure-history
118+
allure_results: target/allure-results
55119

56-
- name: Deploy Allure Report to GitHub Pages
120+
- name: Publish Allure test report
57121
uses: peaceiris/actions-gh-pages@v3
122+
if: ${{ matrix.os == 'ubuntu-latest' }}
123+
with:
124+
github_token: ${{ secrets.GITHUB_TOKEN }}
125+
publish_branch: gh-pages
126+
publish_dir: allure-history
127+
128+
- name: Attach screenshots
129+
uses: actions/upload-artifact@v4
130+
if: always()
131+
with:
132+
path: screenshots
133+
134+
check-java-code-style:
135+
name: Check Java code style
136+
runs-on: ubuntu-latest
137+
138+
steps:
139+
- name: Clone code from repo
140+
uses: actions/checkout@v4
58141
with:
59-
github_token: ${{ secrets.EPOLIF_TOKEN }}
60-
publish_dir: target/site/allure-maven-plugin
142+
fetch-depth: 0

0 commit comments

Comments
 (0)