Skip to content

Commit

Permalink
feat: added automations (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyTheocharis authored Dec 9, 2024
1 parent 8b7b51f commit c9a225f
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 12 deletions.
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "none"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "none"
"version": "1.23"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
Expand Down Expand Up @@ -48,7 +45,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "cd tests && docker-compose -f docker-compose.yaml -f docker-compose-modbus.yaml up -d && cd .. && make all",
"postCreateCommand": "",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
Expand Down
104 changes: 104 additions & 0 deletions .gitpod/automations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
tasks:
make-all:
name: Make All
command: |
make all
triggeredBy:
- manual
- postEnvironmentStart
# - postDevcontainerStart

services:
start-opcplc-server:
name: start-opcplc-server
description: Start opcplc docker containers for testing
commands:
start: |
cd tests && docker-compose -f docker-compose.yaml up
ready: |
cd tests
# Define the list of services to check
services=("opcplc")
max_retries=30
delay=2
for service in "${services[@]}"; do
echo "Checking status of service: $service"
for ((i=1;i<=max_retries;i++)); do
# Get the container ID for the service
container_id=$(docker-compose -f docker-compose.yaml -f docker-compose-modbus.yaml ps -q $service)
if [ -z "$container_id" ]; then
echo "Service $service not found. Retrying in $delay seconds..."
else
# Check if the container is running
status=$(docker inspect -f '{{.State.Running}}' $container_id 2>/dev/null)
if [ "$status" == "true" ]; then
echo "Service $service is running."
break
else
echo "Service $service is not running yet. Attempt $i/$max_retries."
fi
fi
if [ $i -eq $max_retries ]; then
echo "Service $service failed to start within the expected time."
exit 1
fi
sleep $delay
done
done
echo "All services are up and running."
exit 0
stop: |
echo "Stopping Docker Compose testing services..."
cd tests && docker-compose -f docker-compose.yaml down
triggeredBy:
- postEnvironmentStart
# - postDevcontainerStart

start-modbus-server:
name: start-modbus-server
description: Start modbus docker containers for testing
commands:
start: |
cd tests && docker-compose -f docker-compose-modbus.yaml up
ready: |
cd tests
# Define the list of services to check
services=("modbus-server")
max_retries=30
delay=2
for service in "${services[@]}"; do
echo "Checking status of service: $service"
for ((i=1;i<=max_retries;i++)); do
# Get the container ID for the service
container_id=$(docker-compose -f docker-compose.yaml -f docker-compose-modbus.yaml ps -q $service)
if [ -z "$container_id" ]; then
echo "Service $service not found. Retrying in $delay seconds..."
else
# Check if the container is running
status=$(docker inspect -f '{{.State.Running}}' $container_id 2>/dev/null)
if [ "$status" == "true" ]; then
echo "Service $service is running."
break
else
echo "Service $service is not running yet. Attempt $i/$max_retries."
fi
fi
if [ $i -eq $max_retries ]; then
echo "Service $service failed to start within the expected time."
exit 1
fi
sleep $delay
done
done
echo "All services are up and running."
exit 0
stop: |
echo "Stopping Docker Compose testing services..."
cd tests && docker-compose -f docker-compose-modbus.yaml down
triggeredBy:
- postEnvironmentStart
# - postDevcontainerStart
7 changes: 1 addition & 6 deletions .idea/benthos-umh.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:
opcplc:
image: mcr.microsoft.com/iotedge/opc-plc:2.9.11
Expand Down

0 comments on commit c9a225f

Please sign in to comment.