-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Sensirion/add-github-action
Add GitHub Workflow
- Loading branch information
Showing
9 changed files
with
661 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
code-analysis: | ||
runs-on: "ubuntu-22.04" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad | ||
with: | ||
packages: clang-format | ||
version: 1.0 | ||
- name: clang-format | ||
run: find . -type f -iregex ".*\.\(c\|h\|cpp\|ino\)" -exec clang-format -i -style=file {} \; && git diff --exit-code | ||
|
||
raspberry-pi-example-sources: | ||
runs-on: "ubuntu-22.04" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: run-download | ||
run: | | ||
cd ./examples/raspberry-pi | ||
ls | ||
make download | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: raspi-source-dist | ||
path: ./examples/raspberry-pi/* | ||
if-no-files-found: error | ||
build-raspberry-pi-examples: | ||
runs-on: "ubuntu-22.04" | ||
needs: raspberry-pi-example-sources | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: raspi-source-dist | ||
path: ./examples/raspberry-pi/build-test | ||
- name: test-build | ||
run: | | ||
cd ./examples/raspberry-pi/build-test | ||
ls | ||
make algorithm_example_usage | ||
make low_power_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
generate-wrapper: | ||
runs-on: "ubuntu-22.04" | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad | ||
with: | ||
packages: gcc g++ swig | ||
version: 1.0 | ||
- name: generate wrapper | ||
run: ./generate_swig_wrapper.sh | ||
shell: bash | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-sources | ||
path: python-wrapper/sensirion_gas_index_algorithm/** | ||
if-no-files-found: error | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: swig-sources | ||
path: python-wrapper/swig/** | ||
if-no-files-found: error | ||
check_readme_rst_syntax: | ||
runs-on: "ubuntu-22.04" | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
- name: install rst linter | ||
run: pip install restructuredtext-lint pygments | ||
- name: run | ||
run: rst-lint *.rst | ||
build: | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
py-version: ["3.8", "3.9"] | ||
os: [ubuntu-22.04, windows-2019, macOS-15] | ||
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
needs: generate-wrapper | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: python-sources | ||
path: python-wrapper/sensirion_gas_index_algorithm | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: swig-sources | ||
path: python-wrapper/swig | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.py-version }} | ||
- name: install package | ||
run: | | ||
pip3 install -e .[test] | ||
pip3 install wheel | ||
- name: static test | ||
run: flake8 | ||
- name: unit test | ||
run: pytest | ||
- name: create wheel | ||
run: python3 setup.py bdist_wheel | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: py_${{ matrix.py-version }}_${{ matrix.os}}_build | ||
path: python-wrapper/dist/** | ||
if-no-files-found: error | ||
py3p8_linux_sdist: | ||
runs-on: "ubuntu-22.04" | ||
needs: generate-wrapper | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: python-sources | ||
path: python-wrapper/sensirion_gas_index_algorithm | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: swig-sources | ||
path: python-wrapper/swig | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
- name: create dist package | ||
run: python3 setup.py sdist | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: py_source_dist | ||
path: python-wrapper/dist/** | ||
if-no-files-found: error | ||
build_pages: | ||
runs-on: "ubuntu-22.04" | ||
needs: generate-wrapper | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: python-sources | ||
path: python-wrapper/sensirion_gas_index_algorithm | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: swig-sources | ||
path: python-wrapper/swig | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: "pip" | ||
- name: Install the project dependencies | ||
run: | | ||
python setup.py install | ||
python -m pip install -r docs/requirements.txt | ||
- name: Build documentation | ||
run: cd ./docs && make html | ||
- name: Upload html | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: python-wrapper/docs/_build/html | ||
deploy_pages: | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
runs-on: "ubuntu-22.04" | ||
needs: build_pages | ||
permissions: | ||
pages: write # to deploy to Pages | ||
id-token: write # to verify the deployment originates from an appropriate source | ||
# Deploy to the github-pages environment | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
deploy_pypi: | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
runs-on: "ubuntu-22.04" | ||
permissions: | ||
id-token: write | ||
needs: ["py3p8_linux_sdist", "build"] | ||
steps: | ||
- name: download python source dist artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: python-wrapper/dist | ||
name: py_source_dist | ||
- name: download win python build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: python-wrapper/dist | ||
merge-multiple: true | ||
pattern: py_*windows*_build | ||
- name: download mac build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: python-wrapper/dist | ||
merge-multiple: true | ||
pattern: py_*macOS*_build | ||
# pypi does not accept the linux wheels with _x86_64, thus not uploading any linux wheels | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
github-release: | ||
name: Create GitHub Release and add signature for python packages | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
needs: | ||
- build | ||
- py3p8_linux_sdist | ||
runs-on: ubuntu-22.04 | ||
defaults: | ||
run: | ||
working-directory: ./python-wrapper | ||
permissions: | ||
contents: write | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: download python source dist artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: python-wrapper/dist | ||
merge-multiple: true | ||
name: py_source_dist | ||
- name: download python build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: python-wrapper/dist | ||
merge-multiple: true | ||
pattern: py_*_build | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
if [[ "$(gh release view '${{ github.ref_name }}' 2>&1)" == "release not found" ]]; then | ||
gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes "" | ||
fi | ||
- name: Upload artifacts to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Upload release artifacts before the signing, such that artifacts are still uploaded if signing fails | ||
run: | | ||
gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46 | ||
with: | ||
inputs: >- | ||
./python-wrapper/dist/*.tar.gz | ||
./python-wrapper/dist/*.whl | ||
- name: Upload signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# upload sigstore-produced signatures and certificates from dist | ||
run: | | ||
gh release upload '${{ github.ref_name }}' dist/*.sigstore.json --repo '${{ github.repository }}' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.