Skip to content

Use pyproject.toml in place of setup.py #67

Use pyproject.toml in place of setup.py

Use pyproject.toml in place of setup.py #67

Workflow file for this run

# This file is part of Astarte.
#
# Copyright 2024 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Check examples
on: [pull_request, create]
env:
PB_REL: https://github.com/protocolbuffers/protobuf/releases
jobs:
check-examples-mqtt:
runs-on: ubuntu-latest
concurrency:
group: check-examples-mqtt-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Create Astarte Cluster
id: astarte
uses: astarte-platform/astarte-cluster-action@v1
with:
astarte_version: "1.1.1"
- name: Install interfaces
run: |
astartectl realm-management interfaces sync $GITHUB_WORKSPACE/examples/datastreams/interfaces/*.json --non-interactive
astartectl realm-management interfaces sync $GITHUB_WORKSPACE/examples/event_listener/interfaces/*.json --non-interactive
astartectl realm-management interfaces sync $GITHUB_WORKSPACE/examples/example_device/interfaces/*.json --non-interactive
astartectl realm-management interfaces ls
- name: Setup the configuration file for the datastream example
working-directory: ./examples/datastreams
run: |
echo "REALM = \"test\"" > config.toml
echo "PAIRING_URL = \"https://api.autotest.astarte-platform.org/pairing\"" >> config.toml
DEVICE_ID=$(astartectl utils device-id generate-random)
echo "DEVICE_ID = \"$DEVICE_ID\"" >> config.toml
CREDENTIALS_SECRET=$(astartectl pairing agent register --compact-output -- "$DEVICE_ID")
echo "CREDENTIALS_SECRET = \"$CREDENTIALS_SECRET\"" >> config.toml
cat config.toml
- name: Setup the configuration file for the event_listener example
working-directory: ./examples/event_listener
run: |
echo "REALM = \"test\"" > config.toml
echo "PAIRING_URL = \"https://api.autotest.astarte-platform.org/pairing\"" >> config.toml
DEVICE_ID=$(astartectl utils device-id generate-random)
echo "DEVICE_ID = \"$DEVICE_ID\"" >> config.toml
CREDENTIALS_SECRET=$(astartectl pairing agent register --compact-output -- "$DEVICE_ID")
echo "CREDENTIALS_SECRET = \"$CREDENTIALS_SECRET\"" >> config.toml
cat config.toml
- name: Setup the configuration file for the example device example
working-directory: ./examples/example_device
run: |
echo "REALM = \"test\"" > config.toml
echo "PAIRING_URL = \"https://api.autotest.astarte-platform.org/pairing\"" >> config.toml
DEVICE_ID=$(astartectl utils device-id generate-random)
echo "DEVICE_ID = \"$DEVICE_ID\"" >> config.toml
CREDENTIALS_SECRET=$(astartectl pairing agent register --compact-output -- "$DEVICE_ID")
echo "CREDENTIALS_SECRET = \"$CREDENTIALS_SECRET\"" >> config.toml
cat config.toml
- name: Install the Astarte device Python module
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -e .
- name: Execute the datastream example
working-directory: ./examples/datastreams
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 ./main.py -d 10
- name: Execute the event_listener example
working-directory: ./examples/event_listener
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 ./event_listener.py -d 10
- name: Execute the example_device example
working-directory: ./examples/example_device
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 ./example_device.py -d 10
check-examples-grpc:
runs-on: ubuntu-latest
concurrency:
group: check-examples-grpc-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 30
steps:
- name: Checkout astarte-device-sdk-python
uses: actions/checkout@v4
with:
path: astarte-device-sdk-python
- name: Checkout astarte-message-hub
uses: actions/checkout@v4
with:
repository: astarte-platform/astarte-message-hub
path: astarte-message-hub
ref: v0.5.4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install Protoc
run: |
curl -LO $PB_REL/download/v26.1/protoc-26.1-linux-x86_64.zip
unzip protoc-26.1-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Create Astarte Cluster
id: astarte
uses: astarte-platform/astarte-cluster-action@v1
with:
astarte_version: "1.1.1"
- name: Install interface
run: |
astartectl realm-management interfaces sync $GITHUB_WORKSPACE/astarte-device-sdk-python/examples/grpc/interfaces/*.json --non-interactive
astartectl realm-management interfaces ls
- name: Setup the configuration file for the grpc example
working-directory: ./astarte-device-sdk-python/examples/grpc
run: |
echo "SERVER_ADDR = \"localhost:50051\"" > config.toml
echo "NODE_UUID = \"98bb9fe5-b4ce-4dea-9b88-8d1f8525e4b4\"" >> config.toml
cat config.toml
- name: Set up configuration file for the message hub
working-directory: ./astarte-message-hub
run: |
echo "realm = \"test\"" > message-hub-config.toml
echo "pairing_url = \"https://api.autotest.astarte-platform.org/pairing\"" >> message-hub-config.toml
echo "grpc_socket_port = 50051" >> message-hub-config.toml
DEVICE_ID=$(astartectl utils device-id generate-random)
echo "device_id = \"$DEVICE_ID\"" >> message-hub-config.toml
CREDENTIALS_SECRET=$(astartectl pairing agent register --compact-output -- "$DEVICE_ID")
echo "credentials_secret = \"$CREDENTIALS_SECRET\"" >> message-hub-config.toml
echo "store_directory = \"./tmp\"" >> message-hub-config.toml
cat message-hub-config.toml
- name: Create folder for binary
run: |
mkdir ./astarte-message-hub/target
mkdir ./astarte-message-hub/target/release
- name: Restore cached astarte-message-hub binary
id: cache-astarte-message-hub-restore
uses: actions/cache/restore@v3
with:
path: ./astarte-message-hub/target/release/astarte-message-hub
key: astarte-message-hub-v0.5.4
- name: Build message hub
if: steps.cache-astarte-message-hub-restore.outputs.cache-hit != 'true'
working-directory: ./astarte-message-hub
run: cargo build --release
- name: Save grpc_python_plugin
if: steps.cache-astarte-message-hub-restore.outputs.cache-hit != 'true'
id: cache-astarte-message-hub-save
uses: actions/cache/save@v3
with:
path: ./astarte-message-hub/target/release/astarte-message-hub
key: ${{ steps.cache-astarte-message-hub-restore.outputs.cache-primary-key }}
- name: Install the Astarte device Python module
working-directory: ./astarte-device-sdk-python
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -e .
- name: Wait for 5 seconds
run: sleep 5
- name: Run message hub
working-directory: ./astarte-message-hub
run: nohup ./target/release/astarte-message-hub > nohup.out 2> nohup.err < /dev/null &
- name: Wait for 5 seconds
run: sleep 5
- name: Run grpc example
working-directory: ./astarte-device-sdk-python/examples/grpc
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 main.py -d 10