Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

Commit 147e0d5

Browse files
author
Lauric Desauw
committed
feat: refactor the repositoty
1 parent c085699 commit 147e0d5

File tree

13 files changed

+1008
-39
lines changed

13 files changed

+1008
-39
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 160
3+
ignore = W504, F401
4+
exclude = powerapi/test_utils

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
jobs:
8+
check_version:
9+
name: Check sensor version
10+
runs-on: ubuntu-latest
11+
outputs:
12+
version: ${{ steps.step1.outputs.version }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Check tag and sensor version
16+
id: step1
17+
run: |
18+
export VERSION=$(echo $GITHUB_REF | sed -e 's/refs\/tags\/v//g')
19+
test $VERSION == $(grep Version control | cut -d ' ' -f 2)
20+
echo "::set-output name=version::$VERSION"
21+
build_pypi:
22+
name: Push package on pypi
23+
runs-on: ubuntu-latest
24+
env:
25+
PYPI_PASS: ${{ secrets.PYPI_PASS }}
26+
needs: check_release
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Prepare environement
30+
run: pip install -U pip twine
31+
- name: Init .pypirc
32+
run: |
33+
echo -e "[pypi]" >> ~/.pypirc
34+
echo -e "username = powerapi" >> ~/.pypirc
35+
echo -e "password = $PYPI_PASS" >> ~/.pypirc
36+
- name: Generate package
37+
run: |
38+
python3 -m venv venv
39+
. venv/bin/activate
40+
python3 -m pip install wheel
41+
python3 setup.py sdist bdist_wheel
42+
- name: Upload to pypi
43+
run: twine upload dist/*
44+
build_docker_image:
45+
name: Build and push docker image
46+
runs-on: ubuntu-latest
47+
needs: [check_version, build]
48+
steps:
49+
- uses: actions/checkout@v2
50+
- name: Log in to Docker Hub
51+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
52+
with:
53+
username: ${{ secrets.DOCKER_USERNAME }}
54+
password: ${{ secrets.DOCKER_PASSWORD }}
55+
- name: Build and push image
56+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
57+
with:
58+
context: .
59+
push: true
60+
file: Dockerfile
61+
tags: powerapi/procfs-sensor:latest, powerapi/procfs-sensor:${{needs.check_version.outputs.version}}
62+
build_deb:
63+
name: Build debian package
64+
needs: [check_version, build]
65+
runs-on: ubuntu-latest
66+
container:
67+
image: powerapi/procfs-sensor-build:latest
68+
env:
69+
VERSION: ${{needs.check_version.outputs.version}}
70+
steps:
71+
- uses: actions/checkout@v2
72+
- uses: actions/download-artifact@v2
73+
with:
74+
name: binary
75+
path: ~/bin/
76+
- name: Create package source
77+
run: |
78+
mkdir -p procfs-sensor-$VERSION/DEBIAN
79+
cp control procfs-sensor-$VERSION/DEBIAN/
80+
mkdir -p procfs-sensor-$VERSION/usr/bin/
81+
cp ~/bin/procfs-sensor procfs-sensor-$VERSION/usr/bin/procfs-sensor
82+
chmod +x procfs-sensor-$VERSION/usr/bin/procfs-sensor
83+
dpkg-deb --build procfs-sensor-$VERSION
84+
- uses: actions/upload-artifact@v2
85+
with:
86+
name: deb_package
87+
path: procfs-sensor-${{needs.check_version.outputs.version}}.deb
88+
publish_release:
89+
name: Publish release on github
90+
runs-on: ubuntu-latest
91+
needs: [check_version, build_deb]
92+
env:
93+
VERSION: ${{needs.check_version.outputs.version}}
94+
steps:
95+
- uses: actions/checkout@v2
96+
- uses: actions/download-artifact@v2
97+
with:
98+
name: binary
99+
path: ~/assets/
100+
- uses: actions/download-artifact@v2
101+
with:
102+
name: deb_package
103+
path: ~/assets/
104+
- name: Create Changelog
105+
env:
106+
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.clean_changelog }}
107+
run: |
108+
sudo apt install -y npm
109+
sudo npm install -g conventional-changelog-cli
110+
conventional-changelog -p angular -r 2 | grep -v "^# \[\]" | sed 's/^#//g' > ~/final-changelog.md
111+
cat ~/final-changelog.md
112+
cat ~/final-changelog.md >> CHANGELOG.md
113+
- name: Create Release
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
run: gh release create v$VERSION -d -t v$VERSION -F ~/final-changelog.md ~/assets/*

.gitignore

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
### Python ###
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
.hypothesis/
50+
.pytest_cache/
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Sphinx documentation
57+
docs/_build/
58+
59+
# Jupyter Notebook
60+
.ipynb_checkpoints
61+
62+
# IPython
63+
profile_default/
64+
ipython_config.py
65+
66+
# pyenv
67+
.python-version
68+
69+
# Environments
70+
.env
71+
.venv
72+
env/
73+
venv/
74+
ENV/
75+
env.bak/
76+
venv.bak/
77+
78+
# mypy
79+
.mypy_cache/
80+
.dmypy.json
81+
dmypy.json
82+
83+
# Pyre type checker
84+
.pyre/
85+
86+
### Emacs ###
87+
*~
88+
\#*\#
89+
/.emacs.desktop
90+
/.emacs.desktop.lock
91+
*.elc
92+
auto-save-list
93+
tramp
94+
.\#*
95+
96+
# Org-mode
97+
.org-id-locations
98+
*_archive
99+
100+
# flymake-mode
101+
*_flymake.*
102+
103+
# eshell files
104+
/eshell/history
105+
/eshell/lastdir
106+
107+
# elpa packages
108+
/elpa/
109+
110+
# reftex files
111+
*.rel
112+
113+
# AUCTeX auto folder
114+
/auto/
115+
116+
# cask packages
117+
.cask/
118+
dist/
119+
120+
# Flycheck
121+
flycheck_*.el
122+
123+
# server auth directory
124+
/server/
125+
126+
# projectiles files
127+
.projectile
128+
129+
# directory configuration
130+
.dir-locals.el
131+
132+
# network security
133+
/network-security.data
134+
135+
### Vim ###
136+
# Swap
137+
[._]*.s[a-v][a-z]
138+
[._]*.sw[a-p]
139+
[._]s[a-rt-v][a-z]
140+
[._]ss[a-gi-z]
141+
[._]sw[a-p]
142+
143+
# Session
144+
Session.vim
145+
146+
# Temporary
147+
.netrwhist
148+
# Auto-generated tag files
149+
tags
150+
# Persistent undo
151+
[._]*.un~
152+
153+
### IntelliJ IDEA ###
154+
.idea/

0 commit comments

Comments
 (0)