Skip to content

Commit d7ba917

Browse files
committed
build: fix github ci
1 parent 7e1151a commit d7ba917

12 files changed

+283
-38
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
name: test_ci
2-
3-
on: [push, pull_request]
1+
name: Push/PR workflow
42

3+
on:
4+
push:
5+
pull_request:
6+
env:
7+
repository: https://github.com/powerapi-ng/powerapi
58
jobs:
69
lint_and_test:
710
runs-on: ubuntu-latest
811
strategy:
912
matrix:
10-
python-version: [3.9]
13+
python-version: [3.7]
1114
services:
1215
mongo:
1316
image: mongo:latest
@@ -18,10 +21,10 @@ jobs:
1821
ports:
1922
- 8086:8086
2023
steps:
21-
- name: Install environment
24+
- name: Install tools
2225
run: |
23-
sudo apt-get update
24-
sudo apt install -y libvirt-dev
26+
sudo apt update
27+
sudo apt install -y libvirt-dev procps
2528
- uses: actions/checkout@v2
2629
- name: Set up Python ${{ matrix.python-version }}
2730
uses: actions/setup-python@v2
@@ -31,24 +34,26 @@ jobs:
3134
uses: actions/cache@v2
3235
with:
3336
path: ~/.cache/pip
34-
key: ${{ runner.os }}-pip-${{ hashFiles('powerapi/__init__.json') }}
37+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
3538
restore-keys: |
3639
${{ runner.os }}-pip-
3740
${{ runner.os }}-
3841
- name: Install dependencies
3942
run: |
43+
python3 -m venv venv
44+
. venv/bin/activate
4045
python -m pip install --upgrade pip
4146
pip install flake8 pylint
42-
pip3 install -e ".[mongodb, influxdb, prometheus, libvirt]"
47+
pip install -e ".[mongodb, influxdb, prometheus, libvirt]"
4348
- name: Test with pytest
44-
run: python3 setup.py test
49+
run: |
50+
. venv/bin/activate
51+
python setup.py test
4552
- name: Lint with flake8
46-
run: flake8 powerapi
53+
run: |
54+
. venv/bin/activate
55+
flake8 powerapi
4756
- name: Lint with pylint
48-
run: pylint powerapi
49-
build_pip:
50-
runs-on: ubuntu-latest
51-
if: github.event.release
52-
needs: lint_and_test
53-
steps:
54-
- run: echo TAG $GITHUB_REF
57+
run: |
58+
. venv/bin/activate
59+
pylint powerapi

.github/workflows/release_ci.yml

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
name: Release workflow
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
branches:
8+
- ci-migration
9+
env:
10+
repository: https://github.com/powerapi-ng/powerapi
11+
jobs:
12+
lint_and_test:
13+
name: Lint and test
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: [3.9]
18+
# services:
19+
# mongo:
20+
# image: mongo:latest
21+
# ports:
22+
# - 27017:27017
23+
# influx:
24+
# image: influxdb:1.8
25+
# ports:
26+
# - 8086:8086
27+
steps:
28+
- name: Install tools
29+
run: |
30+
sudo apt update
31+
sudo apt install -y libvirt-dev procps
32+
- uses: actions/checkout@v2
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Convert to python3.6 code
38+
if: ${{ matrix.python-version == 3.6 }}
39+
run: ./to_36.sh
40+
- name: Cache pip
41+
uses: actions/cache@v2
42+
with:
43+
path: ~/.cache/pip
44+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
45+
restore-keys: |
46+
${{ runner.os }}-pip-
47+
${{ runner.os }}-
48+
- name: Install dependencies
49+
run: |
50+
python3 -m venv venv
51+
. venv/bin/activate
52+
python -m pip install --upgrade pip
53+
pip install flake8 pylint
54+
pip install -e ".[mongodb, influxdb, prometheus, libvirt]"
55+
# - name: Test with pytest
56+
# run: |
57+
# . venv/bin/activate
58+
# python setup.py test
59+
# - name: Lint with flake8
60+
# if: ${{ matrix.python-version != 3.6 }}
61+
# run: |
62+
# . venv/bin/activate
63+
# flake8 powerapi
64+
# - name: Lint with pylint
65+
# if: ${{ matrix.python-version != 3.6 }}
66+
# run: |
67+
# . venv/bin/activate
68+
# pylint powerapi
69+
check_release:
70+
name: Check release and version correspondance
71+
runs-on: ubuntu-latest
72+
needs: lint_and_test
73+
outputs:
74+
version: ${{ steps.step2.outputs.version }}
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Check tag and package version
78+
id: step2
79+
run: |
80+
export GIT_TAG=$(echo $GITHUB_REF | sed -e 's/refs\/tags\/v//g')
81+
test $GIT_TAG == $(grep __version__ powerapi/__init__.py | cut -d \" -f 2)
82+
echo "::set-output name=version::$GIT_TAG"
83+
# build_pypi:
84+
# name: Push package on pypi
85+
# runs-on: ubuntu-latest
86+
# env:
87+
# PYPI_PASS: ${{ secrets.PYPI_PASS }}
88+
# needs: check_release
89+
# steps:
90+
# - uses: actions/checkout@v2
91+
# - name: Prepare environement
92+
# run: pip install -U pip twine
93+
# - name: Init .pypirc
94+
# run: |
95+
# echo -e "[pypi]" >> ~/.pypirc
96+
# echo -e "username = powerapi" >> ~/.pypirc
97+
# echo -e "password = $PYPI_PASS" >> ~/.pypirc
98+
# - name: Generate package
99+
# run: |
100+
# python3 -m venv venv
101+
# . venv/bin/activate
102+
# python3 setup.py sdist bdist_wheel
103+
# - name: Upload to pypi
104+
# run: twine upload dist/*
105+
# build_and_push_to_dockerHub:
106+
# name: Build and push docker image to DockerHub
107+
# runs-on: ubuntu-latest
108+
# needs: check_release
109+
# steps:
110+
# - uses: actions/checkout@v2
111+
# - name: Log in to Docker Hub
112+
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
113+
# with:
114+
# username: ${{ secrets.DOCKER_USERNAME }}
115+
# password: ${{ secrets.DOCKER_PASSWORD }}
116+
# - name: Build and push Cpython image
117+
# uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
118+
# with:
119+
# context: .
120+
# push: true
121+
# file: Dockerfile-cpython
122+
# tags: powerapi/powerapi:latest, powerapi/powerapi:${{needs.check_release.outputs.version}}
123+
# - name: Build and push pypy image
124+
# uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
125+
# with:
126+
# context: .
127+
# push: true
128+
# file: Dockerfile-pypy
129+
# tags: powerapi/powerapi-pypy:latest, powerapi/powerapi:pypy-${{needs.check_release.outputs.version}}
130+
build_deb_package:
131+
name: Build debian binary package
132+
runs-on: ubuntu-latest
133+
needs: check_release
134+
container:
135+
image: powerapi/powerapi-build-deb
136+
steps:
137+
- uses: actions/checkout@v2
138+
- name: Set up Python 3.6
139+
uses: actions/setup-python@v2
140+
with:
141+
python-version: 3.6
142+
- name: Cache pip
143+
uses: actions/cache@v2
144+
with:
145+
path: ~/.cache/pip
146+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
147+
restore-keys: |
148+
${{ runner.os }}-pip-
149+
${{ runner.os }}-
150+
- name: Remove tests
151+
run: |
152+
rm -R ./tests
153+
sed -i 's/setup_requires =//g' setup.cfg
154+
sed -i 's/pytest-runner >=3.9.2//g' setup.cfg
155+
sed -i 's/test = pytest//g' setup.cfg
156+
sed -i 's/\[aliases\]//g' setup.cfg
157+
sed -i 's/test_suite = tests//g' setup.cfg
158+
sed -i 's/tests_require =//g' setup.cfg
159+
sed -i 's/pytest >=3.9.2//g' setup.cfg
160+
sed -i 's/pytest-asyncio >=0.14.0//g' setup.cfg
161+
sed -i 's/mock >=2.0//g' setup.cfg
162+
sed -i 's/requests >=2.0//g' setup.cfg
163+
- name: Convert to python3.6 code
164+
run: ./to_36.sh
165+
- name: Create source package
166+
run: |
167+
apt install -y python3-setuptools python3-stdeb python3-numpy
168+
mkdir package
169+
mv LICENSE README.md contributing.md powerapi setup.* package/
170+
tar czvf powerapi.tar.gz package
171+
py2dsc powerapi.tar.gz
172+
sed -i '/Depends: ${misc:Depends}, ${python3:Depends}/a Suggests: python3-libvirt,python3-pymongo,python3-prometheus-client,python3-influxdb' ./deb_dist/powerapi-${{needs.check_release.outputs.version}}/debian/control
173+
- name: Build binary package and upload it github release page
174+
env:
175+
VERSION: ${{needs.check_release.outputs.version}}
176+
run: |
177+
cd ./deb_dist/powerapi-$VERSION
178+
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage
179+
mkdir -p ~/deb
180+
cp ../python3-powerapi_$VERSION-1_all.deb ~/deb/
181+
ls ~/deb/
182+
- uses: actions/upload-artifact@v2
183+
with:
184+
name: deb_package
185+
path: ~/deb/
186+
187+
publish_release:
188+
name: Publish release on github
189+
runs-on: ubuntu-latest
190+
needs: [check_release, build_deb_package]
191+
steps:
192+
- uses: actions/checkout@v2
193+
- uses: actions/download-artifact@v2
194+
with:
195+
name: deb_package
196+
path: ~/deb
197+
- name: Create pre-changelog
198+
id: pre-changelog
199+
uses: TriPSs/conventional-changelog-action@v3
200+
with:
201+
github-token: ${{ secrets.github_token }}
202+
preset: angular
203+
output-file: ~/pre-changelog.md
204+
release-count: 2
205+
- name: Create Changelog
206+
env:
207+
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.clean_changelog }}
208+
run: |
209+
sudo apt install -y npm
210+
sudo npm install -g conventional-changelog-cli
211+
conventional-changelog -p angular -r 2 | grep -v "^# \[\]" | sed 's/^#//g' > ~/final-changelog.md
212+
cat ~/final-changelog.md
213+
cat ~/final-changelog.md >> CHANGELOG.md
214+
- name: Download thespian debian package
215+
run: |
216+
wget https://github.com/powerapi-ng/powerapi-ci-env/raw/main/python3-thespian_3.10.0-1_all.deb
217+
cp python3-thespian_3.10.0-1_all.deb ~/deb
218+
- name: Create Release
219+
env:
220+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221+
VERSION: ${{needs.check_release.outputs.version}}
222+
run: gh release create $VERSION -d -t $VERSION -F ~/final-changelog.md ~/deb/*

powerapi/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
__version__ = "1.0.0-prerelease"
30+
__version__ = "1.0.54-prerelease"

powerapi/report/hwpc_report.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
from __future__ import annotations
3030

3131
from datetime import datetime
32-
from typing import Dict, List, Tuple
32+
from typing import Dict
3333

34-
from powerapi.report.report import Report, BadInputData, CSV_HEADER_COMMON
34+
from powerapi.report.report import Report, BadInputData, CSV_HEADER_COMMON, CsvLines
3535

3636

3737
CSV_HEADER_HWPC = CSV_HEADER_COMMON + ['socket', 'cpu']
@@ -115,7 +115,7 @@ def to_mongodb(report: HWPCReport) -> Dict:
115115
return HWPCReport.to_json(report)
116116

117117
@staticmethod
118-
def from_csv_lines(lines: List[Tuple[str, Dict[str, str]]]) -> HWPCReport:
118+
def from_csv_lines(lines: CsvLines) -> HWPCReport:
119119
"""
120120
:param lines: list of pre-parsed lines. a line is a tuple composed with :
121121
- the file name where the line were read

powerapi/report/power_report.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
from __future__ import annotations
3030

3131
from datetime import datetime
32-
from typing import Dict, List, Tuple, Any
32+
from typing import Dict, Any, List, Tuple
3333

34-
from powerapi.report.report import Report, CSV_HEADER_COMMON, BadInputData
34+
from powerapi.report.report import Report, CSV_HEADER_COMMON, BadInputData, CsvLines
3535

3636

3737
CSV_HEADER_POWER = CSV_HEADER_COMMON + ['power', 'socket']
@@ -76,7 +76,7 @@ def from_json(data: Dict) -> Report:
7676
raise BadInputData(exn.args[0], data) from exn
7777

7878
@staticmethod
79-
def from_csv_lines(lines: List[Tuple[str, Dict]]) -> PowerReport:
79+
def from_csv_lines(lines: CsvLines) -> PowerReport:
8080
"""
8181
:param lines: list of pre-parsed lines. a line is a tuple composed with :
8282
- the file name where the line were read
@@ -105,7 +105,7 @@ def from_csv_lines(lines: List[Tuple[str, Dict]]) -> PowerReport:
105105
raise BadInputData(exn.args[0], row) from exn
106106

107107
@staticmethod
108-
def to_csv_lines(report: PowerReport, tags: List[str]) -> Tuple[List[str], Dict]:
108+
def to_csv_lines(report: PowerReport, tags: List[str]) -> CsvLines:
109109
"""
110110
convert a power report into csv lines
111111
:param report: Report that will be converted into csv lines

powerapi/report/procfs_report.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232

3333
from datetime import datetime
34-
from typing import Dict, List, Tuple
34+
from typing import Dict
3535

36-
from powerapi.report.report import Report, BadInputData, CSV_HEADER_COMMON
36+
from powerapi.report.report import Report, BadInputData, CSV_HEADER_COMMON, CsvLines
3737

3838

3939
CSV_HEADER_PROCFS = CSV_HEADER_COMMON + ['socket', 'cpu']
@@ -99,7 +99,7 @@ def to_mongodb(report: ProcfsReport) -> Dict:
9999
return ProcfsReport.to_json(report)
100100

101101
@staticmethod
102-
def from_csv_lines(lines: List[Tuple[str, Dict]]) -> ProcfsReport:
102+
def from_csv_lines(lines: CsvLines) -> ProcfsReport:
103103
""" Extract a ProcfsReport from a csv"""
104104
sensor_name = None
105105
target = None

powerapi/report/report.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
from __future__ import annotations
3131

3232
from datetime import datetime
33-
from typing import Dict
33+
from typing import Dict, NewType, Tuple, List
3434
from powerapi.exception import PowerAPIExceptionWithMessage
3535
from powerapi.message import Message
3636

3737

3838
CSV_HEADER_COMMON = ['timestamp', 'sensor', 'target']
39+
CsvLines = NewType('CsvLines', Tuple[List[str], Dict[str, str]])
3940

4041

4142
class BadInputData(PowerAPIExceptionWithMessage):

powerapi/test_utils/report/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)