Skip to content

Commit b70ae92

Browse files
authored
Merge pull request #18 from Sensirion/add-github-action
Add GitHub Workflow
2 parents cc647ee + 4ba3ebc commit b70ae92

File tree

9 files changed

+661
-321
lines changed

9 files changed

+661
-321
lines changed

.github/workflows/c.check.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
push:
3+
pull_request:
4+
branches:
5+
- master
6+
7+
jobs:
8+
code-analysis:
9+
runs-on: "ubuntu-22.04"
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad
13+
with:
14+
packages: clang-format
15+
version: 1.0
16+
- name: clang-format
17+
run: find . -type f -iregex ".*\.\(c\|h\|cpp\|ino\)" -exec clang-format -i -style=file {} \; && git diff --exit-code
18+
19+
raspberry-pi-example-sources:
20+
runs-on: "ubuntu-22.04"
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: run-download
24+
run: |
25+
cd ./examples/raspberry-pi
26+
ls
27+
make download
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: raspi-source-dist
31+
path: ./examples/raspberry-pi/*
32+
if-no-files-found: error
33+
build-raspberry-pi-examples:
34+
runs-on: "ubuntu-22.04"
35+
needs: raspberry-pi-example-sources
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/download-artifact@v4
39+
with:
40+
name: raspi-source-dist
41+
path: ./examples/raspberry-pi/build-test
42+
- name: test-build
43+
run: |
44+
cd ./examples/raspberry-pi/build-test
45+
ls
46+
make algorithm_example_usage
47+
make low_power_example
+240
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
on:
2+
push:
3+
pull_request:
4+
branches:
5+
- master
6+
7+
jobs:
8+
generate-wrapper:
9+
runs-on: "ubuntu-22.04"
10+
defaults:
11+
run:
12+
working-directory: ./python-wrapper
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Install dependencies
16+
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad
17+
with:
18+
packages: gcc g++ swig
19+
version: 1.0
20+
- name: generate wrapper
21+
run: ./generate_swig_wrapper.sh
22+
shell: bash
23+
- uses: actions/upload-artifact@v4
24+
with:
25+
name: python-sources
26+
path: python-wrapper/sensirion_gas_index_algorithm/**
27+
if-no-files-found: error
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: swig-sources
31+
path: python-wrapper/swig/**
32+
if-no-files-found: error
33+
check_readme_rst_syntax:
34+
runs-on: "ubuntu-22.04"
35+
defaults:
36+
run:
37+
working-directory: ./python-wrapper
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: 3.8
43+
- name: install rst linter
44+
run: pip install restructuredtext-lint pygments
45+
- name: run
46+
run: rst-lint *.rst
47+
build:
48+
continue-on-error: true
49+
strategy:
50+
matrix:
51+
py-version: ["3.8", "3.9"]
52+
os: [ubuntu-22.04, windows-2019, macOS-15]
53+
fail-fast: false
54+
runs-on: ${{ matrix.os }}
55+
needs: generate-wrapper
56+
defaults:
57+
run:
58+
working-directory: ./python-wrapper
59+
steps:
60+
- uses: actions/checkout@v4
61+
- uses: actions/download-artifact@v4
62+
with:
63+
name: python-sources
64+
path: python-wrapper/sensirion_gas_index_algorithm
65+
- uses: actions/download-artifact@v4
66+
with:
67+
name: swig-sources
68+
path: python-wrapper/swig
69+
- uses: actions/setup-python@v5
70+
with:
71+
python-version: ${{ matrix.py-version }}
72+
- name: install package
73+
run: |
74+
pip3 install -e .[test]
75+
pip3 install wheel
76+
- name: static test
77+
run: flake8
78+
- name: unit test
79+
run: pytest
80+
- name: create wheel
81+
run: python3 setup.py bdist_wheel
82+
- uses: actions/upload-artifact@v4
83+
with:
84+
name: py_${{ matrix.py-version }}_${{ matrix.os}}_build
85+
path: python-wrapper/dist/**
86+
if-no-files-found: error
87+
py3p8_linux_sdist:
88+
runs-on: "ubuntu-22.04"
89+
needs: generate-wrapper
90+
defaults:
91+
run:
92+
working-directory: ./python-wrapper
93+
steps:
94+
- uses: actions/checkout@v4
95+
- uses: actions/download-artifact@v4
96+
with:
97+
name: python-sources
98+
path: python-wrapper/sensirion_gas_index_algorithm
99+
- uses: actions/download-artifact@v4
100+
with:
101+
name: swig-sources
102+
path: python-wrapper/swig
103+
- uses: actions/setup-python@v5
104+
with:
105+
python-version: 3.8
106+
- name: create dist package
107+
run: python3 setup.py sdist
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: py_source_dist
111+
path: python-wrapper/dist/**
112+
if-no-files-found: error
113+
build_pages:
114+
runs-on: "ubuntu-22.04"
115+
needs: generate-wrapper
116+
defaults:
117+
run:
118+
working-directory: ./python-wrapper
119+
steps:
120+
- uses: actions/checkout@v4
121+
- uses: actions/download-artifact@v4
122+
with:
123+
name: python-sources
124+
path: python-wrapper/sensirion_gas_index_algorithm
125+
- uses: actions/download-artifact@v4
126+
with:
127+
name: swig-sources
128+
path: python-wrapper/swig
129+
- uses: actions/setup-python@v5
130+
with:
131+
python-version: 3.8
132+
cache: "pip"
133+
- name: Install the project dependencies
134+
run: |
135+
python setup.py install
136+
python -m pip install -r docs/requirements.txt
137+
- name: Build documentation
138+
run: cd ./docs && make html
139+
- name: Upload html
140+
uses: actions/upload-pages-artifact@v3
141+
with:
142+
path: python-wrapper/docs/_build/html
143+
deploy_pages:
144+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
145+
runs-on: "ubuntu-22.04"
146+
needs: build_pages
147+
permissions:
148+
pages: write # to deploy to Pages
149+
id-token: write # to verify the deployment originates from an appropriate source
150+
# Deploy to the github-pages environment
151+
environment:
152+
name: github-pages
153+
url: ${{ steps.deployment.outputs.page_url }}
154+
steps:
155+
- name: Deploy to GitHub Pages
156+
id: deployment
157+
uses: actions/deploy-pages@v2
158+
with:
159+
token: ${{ secrets.GITHUB_TOKEN }}
160+
deploy_pypi:
161+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
162+
runs-on: "ubuntu-22.04"
163+
permissions:
164+
id-token: write
165+
needs: ["py3p8_linux_sdist", "build"]
166+
steps:
167+
- name: download python source dist artifacts
168+
uses: actions/download-artifact@v4
169+
with:
170+
path: python-wrapper/dist
171+
name: py_source_dist
172+
- name: download win python build artifacts
173+
uses: actions/download-artifact@v4
174+
with:
175+
path: python-wrapper/dist
176+
merge-multiple: true
177+
pattern: py_*windows*_build
178+
- name: download mac build artifacts
179+
uses: actions/download-artifact@v4
180+
with:
181+
path: python-wrapper/dist
182+
merge-multiple: true
183+
pattern: py_*macOS*_build
184+
# pypi does not accept the linux wheels with _x86_64, thus not uploading any linux wheels
185+
- name: Publish package distributions to PyPI
186+
uses: pypa/gh-action-pypi-publish@release/v1
187+
with:
188+
password: ${{ secrets.PYPI_API_TOKEN }}
189+
github-release:
190+
name: Create GitHub Release and add signature for python packages
191+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
192+
needs:
193+
- build
194+
- py3p8_linux_sdist
195+
runs-on: ubuntu-22.04
196+
defaults:
197+
run:
198+
working-directory: ./python-wrapper
199+
permissions:
200+
contents: write
201+
id-token: write
202+
steps:
203+
- uses: actions/checkout@v4
204+
- name: download python source dist artifacts
205+
uses: actions/download-artifact@v4
206+
with:
207+
path: python-wrapper/dist
208+
merge-multiple: true
209+
name: py_source_dist
210+
- name: download python build artifacts
211+
uses: actions/download-artifact@v4
212+
with:
213+
path: python-wrapper/dist
214+
merge-multiple: true
215+
pattern: py_*_build
216+
- name: Create GitHub Release
217+
env:
218+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219+
run: |
220+
if [[ "$(gh release view '${{ github.ref_name }}' 2>&1)" == "release not found" ]]; then
221+
gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes ""
222+
fi
223+
- name: Upload artifacts to GitHub Release
224+
env:
225+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226+
# Upload release artifacts before the signing, such that artifacts are still uploaded if signing fails
227+
run: |
228+
gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'
229+
- name: Sign the dists with Sigstore
230+
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46
231+
with:
232+
inputs: >-
233+
./python-wrapper/dist/*.tar.gz
234+
./python-wrapper/dist/*.whl
235+
- name: Upload signatures to GitHub Release
236+
env:
237+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
238+
# upload sigstore-produced signatures and certificates from dist
239+
run: |
240+
gh release upload '${{ github.ref_name }}' dist/*.sigstore.json --repo '${{ github.repository }}'

.gitlab-ci.yml

-34
This file was deleted.

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ Continuous | 1 s | 6.3mW
117117

118118
**Contributions are welcome!**
119119

120-
We develop and test this algorithm using our company internal tools (version
121-
control, continuous integration, code review etc.) and automatically
122-
synchronize the master branch with GitHub. But this doesn't mean that we don't
123-
respond to issues or don't accept pull requests on GitHub. In fact, you're very
124-
welcome to open issues or create pull requests :)
125-
126120
This Sensirion library uses
127121
[`clang-format`](https://releases.llvm.org/download.html) to standardize the
128122
formatting of all our `.c` and `.h` files. Make sure your contributions are

examples/raspberry-pi/algorithm_example_usage.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
*/
3131

3232
#include "sensirion_gas_index_algorithm.h"
33-
#include <stdio.h> // printf
3433
#include <math.h>
34+
#include <stdio.h> // printf
3535

3636
#include "sensirion_common.h"
3737
#include "sensirion_i2c_hal.h"

0 commit comments

Comments
 (0)