feat: add MQTT enable/disable control for automation instances (#1064) #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automations Tests | |
on: | |
push: | |
paths: | |
- 'docker/automations/**' | |
- '.github/workflows/automations-tests.yml' | |
pull_request: | |
paths: | |
- 'docker/automations/**' | |
- '.github/workflows/automations-tests.yml' | |
jobs: | |
version-check: | |
runs-on: ubuntu-latest | |
outputs: | |
node-version: ${{ steps.nvmrc.outputs.node-version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5.0.0 | |
- name: Read Node version from .nvmrc | |
id: nvmrc | |
run: | | |
NODE_VERSION=$(cat docker/automations/.nvmrc) | |
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT | |
echo "Node version from .nvmrc: $NODE_VERSION" | |
- name: Check Node version consistency | |
run: | | |
NODE_VERSION=$(cat docker/automations/.nvmrc) | |
DOCKERFILE_VERSION=$(grep "FROM node:" docker/automations/Dockerfile | cut -d: -f2 | cut -d- -f1) | |
WORKFLOW_VERSION=$(grep -A 10 "node-version-file:" .github/workflows/automations-tests.yml | head -1 | grep -o "[0-9]*" || echo "$NODE_VERSION") | |
echo "Node version in .nvmrc: $NODE_VERSION" | |
echo "Node version in Dockerfile: $DOCKERFILE_VERSION" | |
echo "Expected workflow version: $NODE_VERSION" | |
if [ "$NODE_VERSION" != "$DOCKERFILE_VERSION" ]; then | |
echo "ERROR: Node version mismatch between .nvmrc ($NODE_VERSION) and Dockerfile ($DOCKERFILE_VERSION)" | |
exit 1 | |
fi | |
echo "✅ All Node versions are consistent" | |
test: | |
runs-on: ubuntu-latest | |
needs: version-check | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5.0.0 | |
- name: Setup Node.js from .nvmrc | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'docker/automations/.nvmrc' | |
cache: 'npm' | |
cache-dependency-path: 'docker/automations/package-lock.json' | |
- name: Install dependencies | |
working-directory: docker/automations | |
run: npm ci | |
- name: Run tests | |
working-directory: docker/automations | |
run: npm test | |
- name: Run test coverage | |
working-directory: docker/automations | |
run: npm test -- --coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: docker/automations/coverage/lcov.info | |
directory: docker/automations/coverage | |
flags: automations | |
name: automations-coverage | |
fail_ci_if_error: false | |
docker-build: | |
runs-on: ubuntu-latest | |
needs: [version-check, test] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5.0.0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: docker/automations/ | |
push: false | |
load: true | |
tags: automations-test | |
cache-from: type=gha,scope=automations | |
cache-to: type=gha,mode=max,scope=automations,ignore-error=true | |
- name: Verify Docker image was built successfully | |
run: | | |
# Check that the image exists | |
docker images automations-test | |
# Verify the image can be inspected | |
docker inspect automations-test > /dev/null | |
echo "✅ Docker image built successfully" | |
- name: Cleanup | |
if: always() | |
run: | | |
docker rmi automations-test || true |