Skip to content

Commit

Permalink
fix ci (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
groupsky authored Nov 17, 2024
1 parent 9bf3cc0 commit 418eef6
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
uses: actions/checkout@v3.5.2

- name: Build all containers
run: docker-compose --env-file example.env --file docker-compose.yml up --build --force-recreate --no-start
run: docker compose --env-file example.env --file docker-compose.yml up --build --force-recreate --no-start
9 changes: 5 additions & 4 deletions .github/workflows/lights-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ jobs:
- name: Run containers
run: |
sudo chown -R 1000:1000 data/nodered
docker-compose --env-file example.env up --build --force-recreate -d
docker compose --env-file example.env up --build --force-recreate -d automations features broker
- name: Setup node
uses: actions/setup-node@v3.6.0
with:
node-version: 14
node-version: 22
node-version-file: docker/test/.nvmrc

- name: Run tests
run: |
docker-compose --env-file example.env ps
docker compose --env-file example.env ps
cd docker/test
npm ci
sleep 30
docker ps
docker-compose --env-file ../../example.env logs
docker compose --env-file ../../example.env logs
npm start
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ cd homy
* Initialize the OPNVPN configuration files and certificates

```bash
docker-compose run --rm openvpn ovpn_genconfig -Ddbu udp://VPN.SERVERNAME.COM
docker-compose run --rm openvpn ovpn_initpki
docker compose run --rm openvpn ovpn_genconfig -Ddbu udp://VPN.SERVERNAME.COM
docker compose run --rm openvpn ovpn_initpki
```

* Start the containers

```bash
docker-compose up -d
docker compose up -d
```

* All is up and running
Expand All @@ -41,22 +41,22 @@ A good solution is available at [ufw-docker](https://github.com/chaifeng/ufw-doc
```bash
export CLIENTNAME="your_client_name"
# with a passphrase (recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME
docker compose run --rm openvpn easyrsa build-client-full $CLIENTNAME
# without a passphrase (not recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME nopass
docker compose run --rm openvpn easyrsa build-client-full $CLIENTNAME nopass
```

* Retrieve the client configuration with embedded certificates

```bash
docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
docker compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
```

* Revoke a client certificate

```bash
# Keep the corresponding crt, key and req files.
docker-compose run --rm openvpn ovpn_revokeclient $CLIENTNAME
docker compose run --rm openvpn ovpn_revokeclient $CLIENTNAME
# Remove the corresponding crt, key and req files.
docker-compose run --rm openvpn ovpn_revokeclient $CLIENTNAME remove
docker compose run --rm openvpn ovpn_revokeclient $CLIENTNAME remove
```
76 changes: 0 additions & 76 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ services:
network_mode: none
security_opt:
- no-new-privileges:true
configs:
- source: ingressgen_template_nginx
target: /etc/docker-gen/templates/nginx.tmpl
environment:
- TARGET_CONTAINER=$INGRESS_NAME
volumes:
- ${INGRESS_DATA_PATH}:/etc/nginx/conf.d
- /var/run/docker.sock:/tmp/docker.sock:ro
# fallback in case configs are not supported
- ${INGRESSGEN_TEMPLATE_NGINX_FILE}:/etc/docker-gen/templates/nginx.tmpl:ro

vpn:
Expand All @@ -46,11 +42,6 @@ services:
cap_add:
- NET_ADMIN
- SYS_MODULE
configs:
- source: vpn_template_peer
target: /config/templates/peer.conf
- source: vpn_template_server
target: /config/templates/server.conf
environment:
- PUID=${PUID}
- PGID=${PGID}
Expand Down Expand Up @@ -97,11 +88,6 @@ services:
- egress
security_opt:
- no-new-privileges:true
configs:
- source: nodered_flows
target: /data/flows.json
- source: nodered_settings
target: /data/settings.js
secrets:
- nodered_credentials_key
environment:
Expand All @@ -125,19 +111,6 @@ services:
- egress
security_opt:
- no-new-privileges:true
configs:
- source: homeassistant_configuration
target: /config/configuration.yaml
- source: homeassistant_automations
target: /config/configuration/automations.yaml
- source: homeassistant_customize
target: /config/configuration/customize.yaml
- source: homeassistant_groups
target: /config/configuration/groups.yaml
- source: homeassistant_scenes
target: /config/configuration/scenes.yaml
- source: homeassistant_scripts
target: /config/configuration/scripts.yaml
environment:
- TZ=${TZ}
- EXTERNAL_URL=http://${HOMEASSISTANT_DOMAIN}
Expand Down Expand Up @@ -208,9 +181,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: main_power
target: /etc/config.js
secrets:
- influxdb_write_user
- influxdb_write_user_password
Expand Down Expand Up @@ -246,9 +216,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: secondary_power
target: /etc/config.js
secrets:
- influxdb_write_user
- influxdb_write_user_password
Expand Down Expand Up @@ -285,9 +252,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: tetriary_power
target: /etc/config.js
secrets:
- influxdb_write_user
- influxdb_write_user_password
Expand Down Expand Up @@ -324,9 +288,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: monitoring
target: /etc/config.js
secrets:
- influxdb_write_user
- influxdb_write_user_password
Expand Down Expand Up @@ -364,9 +325,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: monitoring
target: /etc/config.js
secrets:
- influxdb_write_user
- influxdb_write_user_password
Expand Down Expand Up @@ -508,9 +466,6 @@ services:
- automation
security_opt:
- no-new-privileges:true
configs:
- source: influxdb_config
target: /etc/influxdb/influxdb.conf
secrets:
- influxdb_admin_user
- influxdb_admin_password
Expand Down Expand Up @@ -551,11 +506,6 @@ services:
- egress
security_opt:
- no-new-privileges:true
configs:
- source: grafana_config
target: /etc/grafana/grafana.ini
- source: grafana_datasource_influxdb
target: /etc/grafana/provisioning/datasources/influxdb.yaml
secrets:
- influxdb_read_user
- influxdb_read_user_password
Expand Down Expand Up @@ -872,32 +822,6 @@ networks:
test-internal2:
internal: true

configs:
grafana_config:
file: ${GRAFANA_CONFIG_FILE}
grafana_datasource_influxdb:
file: ${GRAFANA_CONFIG_DATASOURCE_INFLUXDB_FILE}
influxdb_config:
file: ${INFLUXDB_CONFIG_FILE}
ingressgen_template_nginx:
file: ${INGRESSGEN_TEMPLATE_NGINX_FILE}
vpn_template_peer:
file: ${VPN_TEMPLATE_PEER_FILE}
vpn_template_server:
file: ${VPN_TEMPLATE_SERVER_FILE}
main_power:
file: ${MAIN_POWER_CONFIG_FILE}
monitoring:
file: ${CONFIG_PATH}/modbus-serial/monitoring.config.js
nodered_flows:
file: ${NODERED_CONFIG_FLOWS_FILE}
nodered_settings:
file: ${NODERED_CONFIG_SETTINGS_FILE}
secondary_power:
file: ${SECONDARY_POWER_CONFIG_FILE}
tetriary_power:
file: ${TETRIARY_POWER_CONFIG_FILE}

secrets:
influxdb_admin_user:
file: ${INFLUXDB_SECRET_ADMIN_USER_FILE}
Expand Down
1 change: 1 addition & 0 deletions docker/test/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
61 changes: 40 additions & 21 deletions docker/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,53 @@ const brokerUrl = process.env.BROKER || 'mqtt://localhost'
console.log(`connecting ${brokerUrl}`)
const client = mqtt.connect(brokerUrl)
const timer = setTimeout(() => {
console.error('Timeout!')
process.exit(1)
}, 1000)
console.error('Timeout!')
process.exit(1)
}, 2000)

const publish = (topic, payload) => {
console.log(`> [${topic}]: ${JSON.stringify(payload)}`)
return client.publish(topic, JSON.stringify(payload))
}

client.on('connect', () => {
console.log('connected, sending...')
client.subscribe('/homy/ard1/output', (err) => {
if (err) {
console.log('Error sending', err)
process.exit(1)
}
console.log(`> [${'/homy/ard1/input'}]: ${JSON.stringify({ t: 'ic', i: 22, p: 44, l: 0, v: 1 })}`)
client.publish('/homy/ard1/input', JSON.stringify({ t: 'ic', i: 22, p: 44, l: 0, v: 1 }))
})
console.log('connected, sending...')
client.subscribe(['#'], async (err) => {
if (err) {
console.log('Error sending', err)
process.exit(1)
}
await publish('/modbus/dry-switches/mbsl32di2/reading', {
"inputs": 0,
"_tz": Date.now(),
"_ms": 7,
"_addr": 32,
"_type": "mbsl32di",
"device": "mbsl32di2"
})
await publish('/modbus/dry-switches/mbsl32di2/reading', {
"inputs": 1 << 27,
"_tz": Date.now(),
"_ms": 7,
"_addr": 32,
"_type": "mbsl32di",
"device": "mbsl32di2"
})
})
})

client.on('message', (topic, message) => {
console.log(`< [${topic}]: ${message}`)
// message is Buffer
if (topic === '/homy/ard1/output') {
const msg = JSON.parse(message)
if (msg.pin === 20 && msg.value === -1) {
clearTimeout(timer)
client.end()
console.log(`< [${topic}]: ${message}`)
// message is Buffer
if (topic === '/modbus/dry-switches/relays00-15/write') {
const msg = JSON.parse(message)
if (msg.out8 === true) {
clearTimeout(timer)
client.end()
}
}
}
})

client.on('error', (err) => {
console.log('error', err)
console.log('error', err)
})
1 change: 1 addition & 0 deletions secrets/ovms_mqtt_password
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ovms-mqtt-password
1 change: 1 addition & 0 deletions secrets/ovms_mqtt_user
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ovms-mqtt-user
2 changes: 1 addition & 1 deletion test/test_routing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source ../example.env

export DOMAIN=

dc="docker-compose --env-file ../example.env -f ../docker-compose.yml"
dc="docker compose --env-file ../example.env -f ../docker-compose.yml"

sudo iptables-save > /tmp/iptables.backup

Expand Down
2 changes: 1 addition & 1 deletion test_infrastructure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TIMEOUT=3

export DOMAIN=

dc="docker-compose --env-file example.env"
dc="docker compose --env-file example.env"
dct="$dc --file docker-compose.yml --file docker-compose.test.yml"
vpn="$dct run test-vpn"
ext="$dct run test-external"
Expand Down

0 comments on commit 418eef6

Please sign in to comment.