Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/push to quay.io #5

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions .github/workflows/mock-provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ on:
- main
pull_request:
workflow_call:
secrets:
QUAY_IO_TOKEN:
required: true
QUAY_IO_USERNAME:
required: true
workflow_dispatch:

concurrency:
Expand All @@ -35,26 +40,6 @@ jobs:
uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2
secrets: inherit

get_tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.eval_tag.outputs.tag }}
steps:
- name: Get tag from workflow / workflow dispatch or fallback to main
id: eval_tag
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
IMAGE_TAG="${{ github.event.inputs.tag }}"
elif [ -n "${{ inputs.tag }}" ]; then
IMAGE_TAG="${{ inputs.tag }}"
else
### if not called from dispatch or call, it must be merging to main
IMAGE_TAG="main"
fi
echo "### Using image tag: $IMAGE_TAG"
echo "tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT


build-container:
runs-on: ubuntu-latest
needs: check_ghcr_push
Expand All @@ -70,6 +55,7 @@ jobs:
# list of Docker images to use as base name for tags
images: |
ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider
quay.io/eclipse-kuksa/mock-provider
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
Expand All @@ -78,21 +64,31 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Log in to the Container registry
- name: Log in to ghcr.io container registry
if: needs.check_ghcr_push.outputs.push == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to quay.io container registry
if: needs.check_ghcr_push.outputs.push == 'true'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_TOKEN }}



- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build container and push to ghcr.io (and ttl.sh)
- name: Build container and push to ghcr.io, quay.io and ttl.sh
id: ghcr-build
if: needs.check_ghcr_push.outputs.push == 'true'
uses: docker/build-push-action@v5
Expand Down
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ When developing further vehicle applications, it can be very useful to be able t

## Component diagram


```mermaid
flowchart LR
BrokerIF(( ))
Expand All @@ -39,7 +38,6 @@ so you cannot connect to a Databroker requiring TLS or Authorization.
The [default mock](mock/mock.py) contains VSS signals that must exist in the VSS catalog loaded
by the Databroker. As of today VSS 3.0 onwards shall match the default mock in this repository.


Firstly, you will need to install all necessary Python dependencies by issuing the following command in your favorite terminal:

```bash
Expand All @@ -56,7 +54,7 @@ python3 mockprovider.py

As an alternative, you can build and execute the container from the [Dockerfile](./Dockerfile).

```bash
```console
$ docker build -f Dockerfile -t mock-provider:latest .
$ docker run --net=host mock-provider:latest
INFO:mock_service:Initialization ...
Expand All @@ -65,6 +63,20 @@ INFO:kuksa_client.grpc:No Root CA present, it will not be possible to use a secu
...
```

#### Published Container Images

Images are also published to the ghcr registry

```console
docker run --rm --net=host ghcr.io/eclipse-kuksa/kuksa-mock-provider/mock-provider:main
```

If the ghcr registry is not easily accessible to you, e.g. if you are a China mainland user, we also made the container images available at quay.io:

```console
docker run --rm --net=host quay.io/eclipse-kuksa/mock-provider:main
```

### Running with Devcontainer

A decontainer is provided. To run you must first install dependencies.
Expand All @@ -83,23 +95,24 @@ INFO:kuksa_client.grpc:No Root CA present, it will not be possible to use a secu

## Configuration

### KUKSA Mock Provider
### KUKSA Mock Provider Configuration

| parameter | default value | Environment variable | description |
|----------------|-----------------------|----------------------------------------------------------------------------------|---------------------------------|
| listen address | `"127.0.0.1:50053"` | `MOCK_ADDR` | Listen for rpc calls |
| broker address | `"127.0.0.1:55555"` | `VDB_ADDRESS`| The address of the KUKSA.val databroker to connect to |


Configuration options have the following priority (highest at top):

1. environment variable
2. default value

### Mocking Configuration

By default, the vehicle mock service reads the configuration for the datapoints to mock from the [`mock.py`](mock/mock.py) Python file at runtime. This file is a good starting point edit own mock configurations.
By default, the vehicle mock service reads the configuration for the datapoints to mock from the [`mock.py`](mock/mock.py) Python file at runtime. This file is a good starting point edit own mock configurations.

The default configuration contains behavior for:

* `Vehicle.Speed`
* `Vehicle.Cabin.Seat.Row1.Pos1.Position`
* `Vehicle.Body.Windshield.Front.Wiping.System.Mode`
Expand All @@ -109,11 +122,12 @@ The default configuration contains behavior for:
This allows the vehicle mock service to be used with the [Velocitas Seat Adjuster](https://eclipse.dev/velocitas/docs/about/use_cases/seat_adjuster/) example, as well as the initial [Vehicle App template](https://github.com/eclipse-velocitas/vehicle-app-python-template). Furthermore, it can be used to develop a wiping application for the front wipers.

### Custom mocking configuration

If the mocked datapoints are not enough, the `mock.py` in this repository can be modified and mounted into the vehicle mock service container - it will then overwrite the default mock configuration with the custom one.

The full Python mocking DSL is available [here](./doc/pydoc/mocking-dsl.md)

# Running showcase GUI
## Running showcase GUI

Firstly, you will need to install all necessary Python dependencies by using the following command in your favorite terminal:

Expand All @@ -124,29 +138,32 @@ python3 -m pip install -r ./requirements.txt

To run the GUI do the following in your favorite terminal:

```bash
```console
python3 showcase_gui/GUI.py
```

If you run it from mock directory the mock datapoints defined by mock.py get used as well:
```bash

```console
cd mock
python3 ../showcase_gui/GUI.py
```

Depending on your Python installation, you might need to install Tk on your system (e.g. `brew install tkinter` for MacOs or `sudo apt install python3-tk` for Ubuntu).

# Generating API documentation
## Generating API documentation

The [API documentation](./doc/pydoc/mocking-dsl.md) is generated from Python docs and embedded into markdown files for easy rendering on Github without external hosting. The workflow `ensure-docs-up2date` makes sure that the API docs are up to date before merging a pull request. To update the docs, run

```bash
./update-api-docs.sh
```

# Using mockservice dynamically
## Using mockservice dynamically

To use the mockservice dynamically you need to use the same process. For an example see [threaded_mock.py](examples/threaded_mock.py).

# What's not supported?
## What's not supported?

Any form of array support e.g no VSS datapoint that has DataType.*ARRAY.
If values in Kuksa Databroker are modified outside of behaviors, the changes won't be picked up by the mock service. Instead try to model another behavior that listens to ACTUATOR_TARGET/VALUE and set it like this.