forked from SvetlanaAQA/LumaProjectPython_2024_spring
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (121 loc) · 4.18 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on:
pull_request:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
download-history:
name: Download history
runs-on: ubuntu-latest
steps:
- name: setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Get previous run artifact
run: >
ARTIFACT_ID=$(curl -L
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
"https://api.github.com/repos/py-AQA/LumaProjectPython_2024_spring/actions/artifacts?name=allure-results"
| python -c "import sys, json; print(json.load(sys.stdin)['artifacts'][0]['id']);")
&&
curl -L
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.TOKEN }}"
-H "X-GitHub-Api-Version: 2022-11-28"
https://api.github.com/repos/py-AQA/LumaProjectPython_2024_spring/actions/artifacts/$ARTIFACT_ID/zip
-o artifacts.zip &&
REPORT_ID=$(curl -L
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
"https://api.github.com/repos/py-AQA/LumaProjectPython_2024_spring/actions/artifacts?name=github-pages"
| python -c "import sys, json; print(json.load(sys.stdin)['artifacts'][0]['id']);")
&&
curl -L
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.TOKEN }}"
-H "X-GitHub-Api-Version: 2022-11-28"
https://api.github.com/repos/py-AQA/LumaProjectPython_2024_spring/actions/artifacts/$REPORT_ID/zip
-o pages.zip
- run: mkdir allure-results && unzip artifacts.zip -d allure-results
- run: mkdir old_pages pages_history && unzip pages.zip -d old_pages && tar -xvf old_pages/artifact.tar -C pages_history
- run: cp pages_history/history/* allure-results && cp -r pages_history/history allure-results
- name: Store allure history
uses: actions/upload-artifact@v3
with:
name: allure-results
path:
allure-results
retention-days: 1
run-test:
name: 'Run tests'
needs: download-history
runs-on: ubuntu-latest
steps:
- name: Git clone
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Run tests
run: |
pytest
env:
CI_RUN: true
PYTHONDONTWRITEBYTECODE: 1
PYTHONUNBUFFERED: 1
continue-on-error: true
- name: Store allure results
uses: actions/upload-artifact@v3
with:
name: allure-results
path:
allure-results
retention-days: 1
generate-report:
runs-on: ubuntu-latest
needs: run-test
name: Generate report
steps:
- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Install allure
run: |
sudo wget https://github.com/allure-framework/allure2/releases/download/2.29.0/allure-2.29.0.tgz && sudo tar -zxvf allure-2.29.0.tgz -C /opt/ && sudo ln -s /opt/allure-2.29.0/bin/allure /usr/bin/allure
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Run allure generate
run: |
allure generate -c allure-results -o _site
- name: Store generated report
uses: actions/upload-artifact@v3
with:
name: _site
path:
_site
retention-days: 1
publish-report:
runs-on: ubuntu-latest
needs: generate-report
name: Report publication
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
- name: Deploy to gitHub Pages
id: deployment
uses: actions/deploy-pages@v1.2.9