Skip to content

Bump charset-normalizer from 3.4.0 to 3.4.1 in /02_mqtt-cluster (#1434) #1847

Bump charset-normalizer from 3.4.0 to 3.4.1 in /02_mqtt-cluster (#1434)

Bump charset-normalizer from 3.4.0 to 3.4.1 in /02_mqtt-cluster (#1434) #1847

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: UNS GraphQL Client
on:
push:
branches:
- "**"
paths:
- "02_mqtt-cluster/**/*.py*"
- "02_mqtt-cluster/pyproject.toml"
- "02_mqtt-cluster/poetry.lock"
- "07_uns_graphql/**/*.py"
- "07_uns_graphql/pyproject.toml"
- "07_uns_graphql/poetry.lock"
- "07_uns_graphql/Dockerfile"
- ".github/workflows/uns_graphql-app.yml"
- ".github/include/**"
pull_request:
branches:
- "**"
paths:
- "02_mqtt-cluster/**/*.py*"
- "02_mqtt-cluster/pyproject.toml"
- "02_mqtt-cluster/poetry.lock"
- "07_uns_graphql/**/*.py"
- "07_uns_graphql/pyproject.toml"
- "07_uns_graphql/poetry.lock"
- "07_uns_graphql/Dockerfile"
- ".github/workflows/uns_graphql-app.yml"
- ".github/include/**"
workflow_dispatch:
inputs:
pytest_add_opts: # trunk-ignore(checkov/CKV_GHA_7)
description: "additional pytest options"
type: string
permissions:
contents: read
jobs:
generate_random_password:
runs-on: ubuntu-latest
outputs:
neo4j_pwd: ${{ steps.random_strings.outputs.neo4j_pwd}}
# trunk-ignore(actionlint/expression)
postgres_pwd: ${{ steps.random_strings.outputs.postgres_pwd }}
uns_historian_pwd: ${{ steps.random_strings.outputs.uns_historian_pwd}}
steps:
- id: random_strings
run: |
echo "neo4j_pwd=$(openssl rand -base64 32 | tr -dc '[:alnum:]')" >> $GITHUB_OUTPUT
echo "postgres_pwd=$(openssl rand -base64 32 | tr -dc '[:alnum:]')" >> $GITHUB_OUTPUT
echo "uns_historian_pwd=$(openssl rand -base64 32 | tr -dc '[:alnum:]')" >> $GITHUB_OUTPUT
build_code:
runs-on: ubuntu-latest
needs: generate_random_password
environment: dev
env:
UNS_mqtt__host: "localhost"
UNS_mqtt__port: 1883
UNS_graphdb__url: "bolt://localhost:7687"
UNS_graphdb__username: "neo4j"
UNS_graphdb__password: ${{ needs.generate_random_password.outputs.neo4j_pwd }}
UNS_historian__hostname: "localhost"
UNS_historian__database: "uns_historian"
UNS_historian__table: "unifiednamespace"
UNS_historian__username: "uns_dbuser"
UNS_historian__password: ${{ needs.generate_random_password.outputs.uns_historian_pwd }}
POSTGRES_PASSWORD: ${{ needs.generate_random_password.outputs.postgres_pwd }}
UNS_kafka.config: "{ 'group.id' = 'uns_graphql', 'client.id' = 'uns_graphql_client', 'bootstrap.servers' ='localhost:9092' }"
services:
uns_mqtt:
image: "emqx/emqx:latest"
ports:
- "1883:1883"
uns_graphdb:
image: "neo4j:latest"
ports:
- "7474:7474"
- "7687:7687"
env:
NEO4J_AUTH: neo4j/${{ env.UNS_graphdb__password }}
apoc.export.file.enabled: true
apoc.import.file.enabled: true
apoc.import.file.use_neo4j_config: true
NEO4J_PLUGINS: '["apoc"]'
uns_timescaledb:
image: "timescale/timescaledb:latest-pg16"
ports:
- "5432:5432"
env:
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
uns_kafka:
image: "bitnami/kafka:latest"
ports:
- "9092:9092"
env:
ALLOW_PLAINTEXT_LISTENER: "yes"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9092"
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: controller,broker
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "0@uns_kafka:9093"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
steps:
- uses: actions/checkout@v4
- name: Setup with python environment
uses: ./.github/include/setup_python/
with:
module: 07_uns_graphql
- name: Create Database for Integration Testing
env:
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
UNS_historian__password: ${{ env.UNS_historian__password }}
run: |
echo "CREATE database $UNS_historian__database;
\c $UNS_historian__database;
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE ROLE $UNS_historian__username
LOGIN
PASSWORD '$UNS_historian__password';
ALTER DATABASE $UNS_historian__database OWNER TO $UNS_historian__username;
" | PGPASSWORD=${POSTGRES_PASSWORD} psql -h ${UNS_historian__hostname} -U postgres -p 5432
echo "CREATE TABLE $UNS_historian__table (
time TIMESTAMPTZ NOT NULL,
topic text NOT NULL,
client_id text,
mqtt_msg JSONB,
CONSTRAINT unique_event UNIQUE (time, topic, client_id, mqtt_msg)
);
SELECT create_hypertable('$UNS_historian__table', 'time');
" | PGPASSWORD=${UNS_historian__password} psql -h ${UNS_historian__hostname} -U $UNS_historian__username -d $UNS_historian__database -p 5432
- name: Run all type of tests
uses: ./.github/include/execute_tests/
timeout-minutes: 3
with:
module: 07_uns_graphql
integration_tests: true
SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }}
pytest_flags: ${{ inputs.pytest_add_opts }}
- name: Create graphQL schema
env:
schema_file: "./schema/uns_schema.graphql"
run: |
cd 07_uns_graphql
# create the schema
poetry run strawberry export-schema \
uns_graphql.uns_graphql_app:UNSGraphql.schema \
--output $schema_file
if git diff --quiet -- "$schema_file"; then
echo "Schema Unchanged"
else
# check in the modified file
git config --global user.email "actions@github.com"
git config --global user.name "Github Actions"
# Ensure that this check-in does not triggering another build
git add $schema_file
git commit -m "updated schema file for graphql api"
fi
build_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compile and Test Dockerfile
uses: ./.github/include/test_docker_builds/
with:
module: 07_uns_graphql
image_name: uns/graphql