Skip to content

Commit 0b9418a

Browse files
committed
add action to upload tests results to allure-server
1 parent 739e3e6 commit 0b9418a

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_dispatch: # 👈 enables manual trigger
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
BASE_URL_FE: https://ultimateqa.com/complicated-page # <-- Set your actual BASE_URL here
18+
BASE_URL_API: https://jsonplaceholder.typicode.com
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: '22'
28+
29+
- name: Install Allure Commandline
30+
run: npm install -g allure-commandline --save-dev
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: '3.11'
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m venv .venv
40+
source .venv/bin/activate
41+
pip install --upgrade pip
42+
pip install -r requirements.txt
43+
44+
- name: Install all Playwright Browsers
45+
run: |
46+
source .venv/bin/activate
47+
python -m playwright install --with-deps
48+
49+
- name: Create .env file from workflow
50+
run: |
51+
echo "BASE_URL_FE=${BASE_URL_FE}" > .env
52+
echo "BASE_URL_API=${BASE_URL_API}" > .env
53+
54+
- name: Download previous Allure history
55+
run: |
56+
git config --global user.email "github-actions@users.noreply.github.com"
57+
git config --global user.name "GitHub Actions"
58+
git clone --depth=1 --branch gh_pages https://github.com/${{ github.repository }} gh-pages || echo "No previous gh-pages"
59+
mkdir -p allure-results/history
60+
cp -r gh-pages/history allure-results/ || echo "No history to copy"
61+
62+
63+
- name: Run tests(UI & API) with Pytest
64+
run: |
65+
source .venv/bin/activate
66+
pytest Ultimateqa/ui_tests api_tests -n auto --alluredir=allure-results
67+
68+
- name: Generate Allure Report
69+
if: always()
70+
run: |
71+
npx allure generate allure-results --clean -o allure-report
72+
sed -i "s|<base href=\"/\">|<base href=\"/${GITHUB_REPOSITORY#*/}/\">|" allure-report/index.html
73+
74+
75+
76+
- name: Zip Allure results
77+
if: always()
78+
run: zip -r allure-results.zip allure-results
79+
80+
- name: Upload Allure results to Allure Server on EC2
81+
if: always()
82+
run: |
83+
curl -X POST "http://3.93.58.184:8080/allure-docker-service/projects/my-project/results" \
84+
-H "accept: application/json" \
85+
-H "Authorization: Bearer ${{ secrets.ALLURE_TOKEN }}" \
86+
-H "Content-Type: multipart/form-data" \
87+
-F "results=@allure-results.zip;type=application/zip"
88+
89+
- name: Trigger Allure report generation
90+
if: always()
91+
run: |
92+
curl -X GET "http://3.93.58.184:8080/allure-docker-service/projects/my-project/report" \
93+
-H "Authorization: Bearer ${{ secrets.ALLURE_TOKEN }}"
94+
95+
- name: Output report link
96+
if: always()
97+
run: |
98+
echo "### ✅ [View Allure Report](http://3.93.58.184:8080/projects/my-project/latest/index.html)" >> $GITHUB_STEP_SUMMARY
99+
100+

0 commit comments

Comments
 (0)