Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

CI/CD: Introduce reusable workflows (#2696)

Koena37155efe07c
diff --git a/.github/actions/check-if-main-repo/action.yml b/.github/actions/check-if-main-repo/action.yml
new file mode 100644
index 000000000..7b2b8eb79
--- /dev/null
+++ b/.github/actions/check-if-main-repo/action.yml
@@ -0,0 +1,41 @@
+name: Check if main repo
+description: Resolves- and checks if it is run from the main repository, and resolves the OpenRemote version
+
+outputs:
+ value:
+ description: Whether this is the main repository which builds the manager
+ value: ${{ steps.is_main_repo.outputs.value }}
+ repository:
+ description: The main GitHub repository name
+ value: ${{ steps.is_main_repo.outputs.repository }}
+ version:
+ description: The openremote version defined in the main repo
+ value: ${{ steps.is_main_repo.outputs.version }}
+
+runs:
+ using: composite
+ steps:
+ - name: Check if main repo
+ id: is_main_repo
+ shell: bash
+ run: |
+ if [ -f manager/src/main/java/org/openremote/manager/Main.java ]; then
+ echo "value=true" >> $GITHUB_OUTPUT
+ else
+ if [ -e 'openremote' ]; then
+ echo "::error::openremote submodule no longer supported, see custom project template!"
+ exit 1
+ fi
+
+ echo "value=false" >> $GITHUB_OUTPUT
+ echo "repository=$(sed -E 's#(.+)/.+#\1/openremote#' <<< $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT
+
+ version=$(cat gradle.properties | grep openremoteVersion | sed -E 's#.+=(.+)#\1#' | xargs)
+
+ if [ -z "$version" ]; then
+ echo "openremoteVersion must be set in gradle.properties"
+ exit 1
+ fi
+
+ echo "version=$version" >> $GITHUB_OUTPUT
+ fi
diff --git a/.github/actions/get-version-details/action.yml b/.github/actions/get-version-details/action.yml
new file mode 100644
index 000000000..3b9424a09
--- /dev/null
+++ b/.github/actions/get-version-details/action.yml
@@ -0,0 +1,39 @@
+name: Get version details
+description: Resolves the current base-, with qualifier and release version
+
+outputs:
+ version:
+ description: The base project version without qualifiers (like -SNAPSHOT)
+ value: ${{ steps.get-version-details.outputs.version }}
+ version_with_qualifier:
+ description: The complete version string including any qualifiers (e.g., -SNAPSHOT)
+ value: ${{ steps.get-version-details.outputs.version_with_qualifier }}
+ is_release:
+ description: Whether this is a release
+ value: ${{ steps.get-version-details.outputs.is_release }}
+
+runs:
+ using: composite
+ steps:
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: 21
+ cache: "gradle"
+
+ - name: Get version details
+ id: get-version-details
+ shell: bash
+ run: |
+ set -o pipefail # exit build with error when pipes fail
+ ./gradlew currentVersion | tee /tmp/currentVersion
+ versionWithQualifier=$(grep "Project version" /tmp/currentVersion | sed 's#Project version: ##')
+ version=$(sed -E 's#-.+##' <<< $versionWithQualifier)
+ isRelease=false
+ if [ "$version" == "$versionWithQualifier" ]; then
+ isRelease=true
+ fi
+ echo "version=$version" >> $GITHUB_OUTPUT
+ echo "version_with_qualifier=$versionWithQualifier" >> $GITHUB_OUTPUT
+ echo "is_release=$isRelease" >> $GITHUB_OUTPUT
diff --git a/.github/actions/process-cicd-json/action.yml b/.github/actions/process-cicd-json/action.yml
new file mode 100644
index 000000000..391c134f6
--- /dev/null
+++ b/.github/actions/process-cicd-json/action.yml
@@ -0,0 +1,140 @@
+name: Process ci_cd.json file
+description: Processes the ci_cd.json file to determine artifact publishing tags and deployments
+
+inputs:
+ IS_MAIN_REPO:
+ description: Whether this is the main repository that builds the manager
+ MANAGER_VERSION:
+ description: The manager version specified in the main repository
+ IS_RELEASE:
+ description: Whether this is a release
+ VERSION:
+ description: The current version
+
+outputs:
+ dockerTags:
+ description: The Docker tags to be published
+ value: ${{ steps.ci-cd-output.outputs.dockerTags }}
+ mavenTag:
+ description: The Maven version tag to be published
+ value: ${{ steps.ci-cd-output.outputs.mavenTag }}
+ npmTag:
+ description: The NPM version tag to be published
+ value: ${{ steps.ci-cd-output.outputs.npmTag }}
+ deploys:
+ description: The deployments to be done
+ value: ${{ steps.ci-cd-output.outputs.deploys }}
+
+runs:
+ using: composite
+ steps:
+ - name: Process ci_cd.json file
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && (github.ref_type == 'tag' || (github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request')) }}
+ id: ci-cd-output
+ shell: python
+ run: |
+ import json
+ import os
+
+ eventName = os.getenv('GITHUB_EVENT_NAME')
+ refName = os.getenv('GITHUB_REF_NAME')
+ refType = os.getenv('GITHUB_REF_TYPE')
+ repoOwner = os.getenv('GITHUB_REPOSITORY_OWNER')
+ isMainRepo = os.getenv('IS_MAIN_REPO') == 'true'
+ isRelease = os.getenv('IS_RELEASE') == 'true'
+ managerVersion = os.getenv('MANAGER_VERSION')
+ version = os.getenv('VERSION')
+ deploys = None
+ dockerPublishTags = None
+ mavenPublishTag = None
+ npmPublishTag = None
+ deployEnvironment = None
+ eventConfig = ()
+
+ f = open(".ci_cd/ci_cd.json")
+ data = json.load(f)
+ f.close()
+
+ if isRelease:
+ eventName = "release"
+
+ if data is not None and eventName in data:
+ eventConfig = data[eventName]
+
+ if eventName == "push" and refType == "branch" and refName in eventConfig:
+ eventConfig = eventConfig[refName]
+
+ if eventConfig is not None:
+ deploys = eventConfig['deploy'] if 'deploy' in eventConfig else None
+ if 'distribute' in eventConfig:
+ if 'docker' in eventConfig['distribute']:
+ dockerPublishTags = eventConfig['distribute']['docker']
+ if 'maven' in eventConfig['distribute']:
+ mavenPublishTag = eventConfig['distribute']['maven']
+ if 'npm' in eventConfig['distribute']:
+ npmPublishTag = eventConfig['distribute']['npm']
+
+ if isMainRepo and ((eventName == "release" and isRelease) or (eventName != "release" and not isRelease)):
+
+ if dockerPublishTags is not None:
+ if "$version" in dockerPublishTags:
+ firstDockerTag = version
+ dockerPublishTags = dockerPublishTags.replace("$version", version)
+ else:
+ dockerPublishTags = dockerPublishTags.replace("$version", version)
+ firstDockerTag = dockerPublishTags.split(",")[0]
+
+ os.system(f"echo 'firstDockerTag={firstDockerTag}' >> $GITHUB_OUTPUT")
+ os.system(f" echo 'Manager tags to push to docker hub: {dockerPublishTags}'")
+ dockerPublishTags = " ".join(map(lambda t: f"-t openremote/manager:{t.strip()}", dockerPublishTags.split(",")))
+ if repoOwner == 'openremote':
+ os.system(f"echo 'dockerTags={dockerPublishTags}' >> $GITHUB_OUTPUT")
+
+ if mavenPublishTag is not None and repoOwner == 'openremote':
+ mavenPublishTag = mavenPublishTag.replace("$version", version)
+ os.system(f" echo 'Maven publish version: {mavenPublishTag}'")
+ os.system(f"echo 'mavenTag={mavenPublishTag}' >> $GITHUB_OUTPUT")
+
+ if npmPublishTag is not None and repoOwner == 'openremote':
+ npmPublishTag = npmPublishTag.replace("$version", version)
+ os.system(f" echo 'npm publish version: {npmPublishTag}'")
+ os.system(f"echo 'npmTag={npmPublishTag}' >> $GITHUB_OUTPUT")
+
+ deployStr = None
+ if deploys is not None and repoOwner == 'openremote':
+ if not isinstance(deploys, list):
+ deploys = [deploys]
+
+ deployStr = ""
+ managerTagDefault = '#ref'
+
+ for deploy in deploys:
+ if 'environment' in deploy:
+ deployStr += deploy['environment']
+ deployStr += ":"
+ if 'managerTag' in deploy:
+ if isMainRepo:
+ deployStr += deploy['managerTag']
+ else:
+ # Custom projects manager docker image must match the openremoteVersion from gradle.properties
+ deployStr += managerVersion
+ else:
+ if isMainRepo:
+ os.system("echo 'Manager tag not specified so using commit SHA'")
+ deployStr += managerTagDefault
+ else:
+ # Custom projects manager docker image must match the openremoteVersion from gradle.properties
+ deployStr += managerVersion
+
+ deployStr += ";"
+
+ deployStr = deployStr.rstrip(";")
+
+ if deployStr is not None and len(deployStr) > 0:
+ print(f"Deployments to deploy: {deployStr}")
+ os.system(f"echo 'deploys={deployStr}' >> $GITHUB_OUTPUT")
+ env:
+ IS_MAIN_REPO: ${{ inputs.IS_MAIN_REPO }}
+ MANAGER_VERSION: ${{ inputs.MANAGER_VERSION }}
+ IS_RELEASE: ${{ inputs.IS_RELEASE }}
+ VERSION: ${{ inputs.VERSION }}
diff --git a/.github/workflows/build-deployment-image.yml b/.github/workflows/build-deployment-image.yml
new file mode 100644
index 000000000..991b5bef6
--- /dev/null
+++ b/.github/workflows/build-deployment-image.yml
@@ -0,0 +1,62 @@
+# Currently only used to test if it builds before merging to master
+name: Build deployment image
+
+on:
+ workflow_call:
+ inputs:
+ tag:
+ type: string
+ required: true
+
+jobs:
+ build-deployment-image:
+ name: Deployment image
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: 21
+ cache: "gradle"
+
+ - name: Check deployment build.gradle
+ id: check_deployment_gradle
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ fail: true # Deployment must have a build.gradle file to prepare the deployment files in the deployment/build dir
+ files: "deployment/build.gradle"
+
+ - name: Check deployment dockerfile
+ id: check_deployment_dockerfile
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ fail: true
+ files: "deployment/Dockerfile"
+
+ - name: Build deployment
+ shell: bash
+ run: ./gradlew -p deployment installDist # TODO: optimize the task graph
+
+ - name: Install QEMU
+ uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
+ with:
+ platforms: linux/amd64,linux/aarch64
+ - name: Install Buildx
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
+ - name: Build deployment image
+ timeout-minutes: 20
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: deployment/build
+ platforms: linux/amd64,linux/aarch64
+ load: false
+ push: false
+ tags: openremote/deployment:${{ inputs.tag }}
+ build-args: |
+ GIT_COMMIT=${{ github.sha }}
+ env:
+ DOCKER_BUILD_SUMMARY: false
+ DOCKER_BUILD_RECORD_UPLOAD: false
diff --git a/.github/workflows/build-manager-image.yml b/.github/workflows/build-manager-image.yml
new file mode 100644
index 000000000..2730b88a4
--- /dev/null
+++ b/.github/workflows/build-manager-image.yml
@@ -0,0 +1,122 @@
+name: Build manager image
+
+on:
+ workflow_call:
+ secrets:
+ DOCKERHUB_USER:
+ required: true
+ DOCKERHUB_PASSWORD:
+ required: true
+ inputs:
+ TAGS:
+ type: string
+ default: ""
+ description: Comma separated list of docker image tags
+
+jobs:
+ build-manager-image:
+ name: Manager image
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-manager-build
+ path: manager/build
+
+ - name: Install QEMU
+ uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
+ with:
+ platforms: linux/amd64,linux/aarch64
+
+ - name: Install Buildx
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
+
+ - name: Parse tags and evaluate conditions
+ id: meta
+ shell: bash
+ run: |
+ COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
+
+ FORMATTED_TAGS="openremote/manager:$COMMIT_SHA_SHORT"
+ FIRST_TAG="openremote/manager:$COMMIT_SHA_SHORT"
+ SHOULD_PUSH="false"
+
+ if [ -n "${{ inputs.TAGS }}" ]; then
+ SHOULD_PUSH="true"
+
+ IFS=',' read -ra TAGS <<< "${{ inputs.TAGS }}"
+ for tag in "${TAGS[@]}"; do
+ CLEAN_TAG=$(echo "$tag" | xargs)
+ FULL_TAG="openremote/manager:$CLEAN_TAG"
+
+ # Make the first explicit tag our primary reference
+ if [ "$FIRST_TAG" == "openremote/manager:$COMMIT_SHA_SHORT" ]; then
+ FIRST_TAG=$FULL_TAG
+ fi
+
+ FORMATTED_TAGS="$FORMATTED_TAGS,$FULL_TAG"
+ done
+ fi
+
+ echo "formatted_tags=$FORMATTED_TAGS" | tee -a $GITHUB_OUTPUT
+ echo "first_tag=$FIRST_TAG" | tee -a $GITHUB_OUTPUT
+ echo "should_push=$SHOULD_PUSH" | tee -a $GITHUB_OUTPUT
+
+ - name: Build and load manager image for Grype scan
+ timeout-minutes: 20
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: manager/build/install/manager
+ platforms: linux/amd64 # "ubuntu-latest" runs on x86 GitHub runners
+ load: true # Load image locally for Grype Scan
+ push: false
+ tags: ${{ steps.parse-tags.outputs.formatted_tags }}
+ build-args: |
+ GIT_COMMIT=${{ github.sha }}
+ cache-from: type=gha,scope=manager
+ env:
+ DOCKER_BUILD_SUMMARY: false
+ DOCKER_BUILD_RECORD_UPLOAD: false
+
+ - name: Scan manager docker image
+ uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0
+ id: manager-anchore-scan
+ with:
+ image: ${{ steps.manager-docker-command.outputs.first_tag }}
+ fail-build: true
+ severity-cutoff: critical
+
+ - name: Upload Anchore scan SARIF report
+ uses: github/codeql-action/upload-sarif@b8bb9f28b8d3f992092362369c57161b755dea45 # v4.35.0
+ if: ${{ always() && steps.meta.outputs.should_push == 'true' }}
+ with:
+ sarif_file: ${{ steps.manager-anchore-scan.outputs.sarif }}
+
+ - name: Inspect Anchore scan SARIF report
+ if: ${{ always() && steps.meta.outputs.should_push == 'true' }}
+ run: cat ${{ steps.manager-anchore-scan.outputs.sarif }}
+
+ - name: Login to DockerHub
+ uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
+ if: ${{ success() && steps.meta.outputs.should_push == 'true' }}
+ with:
+ username: ${{ secrets.DOCKERHUB_USER }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
+
+ - name: Build multi-platform manager image
+ timeout-minutes: 20
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: manager/build/install/manager
+ platforms: linux/amd64,linux/aarch64
+ load: false
+ push: ${{ steps.meta.outputs.should_push == 'true' }}
+ tags: ${{ steps.parse-tags.outputs.formatted_tags }}
+ build-args: |
+ GIT_COMMIT=${{ github.sha }}
+ cache-from: type=gha,scope=manager
+ cache-to: type=gha,mode=max,scope=manager
+ env:
+ DOCKER_BUILD_SUMMARY: false
+ DOCKER_BUILD_RECORD_UPLOAD: false
diff --git a/.github/workflows/build-snapshot-image.yml b/.github/workflows/build-snapshot-image.yml
new file mode 100644
index 000000000..f2d4d3ca4
--- /dev/null
+++ b/.github/workflows/build-snapshot-image.yml
@@ -0,0 +1,65 @@
+name: Build snapshot image
+
+on:
+ workflow_call:
+ secrets:
+ AWS_DEVELOPERS_ACCOUNT_ID:
+ required: true
+ AWS_ECR_PUSH_ROLE:
+ required: true
+ inputs:
+ PUSH:
+ type: boolean
+
+permissions:
+ id-token: write
+
+jobs:
+ snapshot-image:
+ name: Snapshot image
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-manager-build
+ path: manager/build
+
+ - name: Install QEMU
+ uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
+ with:
+ platforms: linux/amd64,linux/aarch64
+
+ - name: Install Buildx
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
+
+ - name: Configure AWS Credentials
+ if: ${{ inputs.PUSH }}
+ uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
+ with:
+ aws-region: eu-west-1
+ role-to-assume: "arn:aws:iam::${{ secrets.AWS_DEVELOPERS_ACCOUNT_ID }}:role/${{ secrets.AWS_ECR_PUSH_ROLE }}"
+
+ - name: Login to private ECR
+ if: ${{ inputs.PUSH }}
+ uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2.1.3
+
+ - name: Resolve snapshot image tag
+ id: meta
+ shell: bash
+ run: |
+ COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
+ echo "shortSha=$COMMIT_SHA_SHORT" >> $GITHUB_OUTPUT
+
+ - name: Build snapshot image
+ timeout-minutes: 20
+ uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+ with:
+ context: manager/build/install/manager
+ platforms: linux/amd64,linux/aarch64
+ load: false
+ push: ${{ inputs.PUSH }}
+ tags: ${{ secrets.AWS_DEVELOPERS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/openremote/manager:${{ steps.meta.outputs.shortSha }}
+ build-args: |
+ GIT_COMMIT=${{ github.sha }}
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 62eb8d392..65bd03e5e 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -57,14 +57,14 @@ name: CI/CD
on:
# Push on master excluding tags
- push:
- branches:
- - 'master'
- tags:
- - '[0-9]+.[0-9]+.[0-9]+'
+ # push:
+ # branches:
+ # - 'master'
+ # tags:
+ # - '[0-9]+.[0-9]+.[0-9]+'
# PR
- pull_request:
+ # pull_request:
# Manual trigger
workflow_dispatch:
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
new file mode 100644
index 000000000..b8eb583ad
--- /dev/null
+++ b/.github/workflows/code-coverage.yml
@@ -0,0 +1,31 @@
+name: Code Coverage
+on: workflow_call
+
+jobs:
+ code-coverage:
+ name: Code Coverage
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-unit-test-outputs
+ path: .
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-integration-test-outputs
+ path: test/build
+ - run: ./gradlew combinedCoverageReport
+ timeout-minutes: 20
+ - name: Archive JaCoCo coverage report
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-coverage-report
+ path: build/reports/jacoco/combinedCoverageReport/html
diff --git a/.github/workflows/custom-review.yml b/.github/workflows/custom-review.yml
new file mode 100644
index 000000000..3d7f3e18a
--- /dev/null
+++ b/.github/workflows/custom-review.yml
@@ -0,0 +1,63 @@
+name: Custom review
+
+on:
+ workflow_call:
+ inputs:
+ INPUTS:
+ type: string
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ detect-changes:
+ name: Detect whether code changed
+ runs-on: ubuntu-latest
+ outputs: # See https://github.com/tj-actions/changed-files/tree/2bb135777322059ee3a3c9239999b159ff49febc#outputs-
+ any_modified: ${{ steps.changed-files.outputs.backend_any_modified == 'true' || steps.changed-files.outputs.ui_any_modified == 'true' }}
+ backend_any_modified: ${{ steps.changed-files.outputs.backend_any_modified }}
+ ui_any_modified: ${{ steps.changed-files.outputs.ui_any_modified }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 1 # Works for pull_request events
+ - name: Detect changes
+ id: changed-files
+ uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
+ with:
+ files_yaml: |
+ ui:
+ - 'ui/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ backend:
+ - '!.ci_cd/**'
+ - '!deployment/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ - '!yarn.lock'
+
+ install-dist:
+ name: Build
+ needs: detect-changes
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/install-dist.yml"
+
+ unit-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/unit-tests.yml"
+
+ integration-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/integration-tests.yml"
+
+ # code-coverage:
+ # name: Test
+ # needs: [unit-tests, integration-tests]
+ # if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ # uses: "./.github/workflows/code-coverage.yml"
diff --git a/.github/workflows/custom-staging.yml b/.github/workflows/custom-staging.yml
new file mode 100644
index 000000000..c0aeb19b2
--- /dev/null
+++ b/.github/workflows/custom-staging.yml
@@ -0,0 +1,68 @@
+name: Custom staging
+
+on:
+ workflow_call:
+ inputs:
+ INPUTS:
+ type: string
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ detect-changes:
+ name: Detect whether code changed
+ runs-on: ubuntu-latest
+ outputs: # See https://github.com/tj-actions/changed-files/tree/2bb135777322059ee3a3c9239999b159ff49febc#outputs-
+ any_modified: ${{ steps.changed-files.outputs.backend_any_modified == 'true' || steps.changed-files.outputs.ui_any_modified == 'true' }}
+ backend_any_modified: ${{ steps.changed-files.outputs.backend_any_modified }}
+ ui_any_modified: ${{ steps.changed-files.outputs.ui_any_modified }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 2 # Must be 2 for push events to compare to previous commit
+ - name: Detect changes
+ id: changed-files
+ uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
+ with:
+ files_yaml: |
+ ui:
+ - 'ui/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ backend:
+ - '!.ci_cd/**'
+ - '!deployment/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ - '!yarn.lock'
+
+ install-dist:
+ name: Build
+ needs: detect-changes
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/install-dist.yml"
+
+ unit-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/unit-tests.yml"
+
+ integration-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/integration-tests.yml"
+
+ # code-coverage:
+ # name: Test
+ # needs: [unit-tests, integration-tests]
+ # if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ # uses: "./.github/workflows/code-coverage.yml"
+
+ # deployment:
+ # name: Deploy
+ # needs: [unit-tests, integration-tests]
+ # uses: "./.github/workflows/deployment.yml"
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 000000000..6f4b37e21
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,59 @@
+# This workflow only exists to allow manual deployments e.g. to test servers.
+#
+# It leverages existing reusable workflows similar to the staging.yml environment workflow but unlike the staging.yml workflow
+# it only includes the required jobs for deployments: install-dist, build-manager-image and deploy.
+name: Deploy
+
+on:
+ # Manual trigger
+ workflow_dispatch:
+ inputs:
+ ENVIRONMENT:
+ description: 'Environment to use (if any)'
+ MANAGER_TAG:
+ description: 'Manager docker tag to pull'
+ CLEAN_INSTALL:
+ description: 'Delete data before starting'
+ type: boolean
+ COMMIT:
+ description: 'Repo branch or commit SHA to checkout'
+ OR_HOSTNAME:
+ description: 'Host to deploy to (e.g. demo.openremote.app)'
+ OR_ADMIN_PASSWORD:
+ description: 'Admin password override'
+
+ workflow_call:
+ inputs:
+ INPUTS:
+ type: string
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ is-main-repo:
+ name: Is main repository
+ runs-on: ubuntu-latest
+ outputs:
+ value: ${{ steps.is_main_repo.outputs.value }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Check if main repo
+ id: is_main_repo
+ uses: openremote/openremote/.github/actions/check-if-main-repo@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ install-dist:
+ name: Build
+ needs: is-main-repo
+ if: ${{ needs.is-main-repo.outputs.value == 'true' }}
+ uses: "./.github/workflows/install-dist.yml"
+
+ deployment:
+ name: Deployment
+ needs: install-dist
+ if: always()
+ uses: "./.github/workflows/deployment.yml"
+ with:
+ INPUTS: ${{ toJSON(inputs) }}
+ secrets: inherit
diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml
new file mode 100644
index 000000000..362511650
--- /dev/null
+++ b/.github/workflows/deployment.yml
@@ -0,0 +1,342 @@
+name: Deployment
+on:
+ workflow_call:
+ inputs:
+ INPUTS:
+ type: string
+
+jobs:
+ deployment:
+ name: Deployment
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ lfs: true # Enable Git LFS plugin to fetch *.mbtiles
+
+ - name: Get version details
+ id: get-version-details
+ uses: openremote/openremote/.github/actions/get-version-details@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Check ci_cd existence
+ id: check_cicd_json
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: ".ci_cd/ci_cd.json"
+
+ - name: Check if main repo
+ id: is_main_repo
+ uses: openremote/openremote/.github/actions/check-if-main-repo@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Checkout main repo
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ if: ${{ steps.is_main_repo.outputs.value == 'false' }}
+ with:
+ repository: ${{ steps.is_main_repo.outputs.repository }}
+ path: openremote
+ ref: ${{ steps.is_main_repo.outputs.version }}
+ sparse-checkout: |
+ .ci_cd
+ profile
+ sparse-checkout-cone-mode: false
+
+ - name: Process ci_cd.json file
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && (github.ref_type == 'tag' || (github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request')) }}
+ id: ci-cd-output
+ uses: openremote/openremote/.github/actions/process-cicd-json@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+ with:
+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}
+ MANAGER_VERSION: ${{ steps.is_main_repo.outputs.version }}
+ IS_RELEASE: ${{ steps.get-version-details.outputs.is_release }}
+ VERSION: ${{ steps.get-version-details.outputs.version }}
+
+ - name: Install QEMU
+ uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
+ with:
+ platforms: linux/aarch64 #,linux/amd64 Only ARM is currently in use
+
+ - name: Install Buildx
+ id: buildx
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
+
+ # --------------------------------------------------------------------------------------
+ # Download manager build directory
+ # --------------------------------------------------------------------------------------
+
+ - name: Download manager build directory
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ if: ${{ steps.is_main_repo.outputs.value == 'true' }}
+ with:
+ name: or-manager-build
+ path: manager/build
+ continue-on-error: true
+
+ # --------------------------------------------------------------------------------------
+ # Download/build deployment build directory
+ # --------------------------------------------------------------------------------------
+
+ - name: Check deployment build.gradle
+ id: check_deployment_gradle
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ fail: true # Deployment must have a build.gradle file to prepare the deployment files in the deployment/build dir
+ files: "deployment/build.gradle"
+
+ - name: Check deployment dockerfile
+ id: check_deployment_dockerfile
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ fail: true
+ files: "deployment/Dockerfile"
+
+ - name: Build deployment
+ shell: bash
+ run: |
+ if [ -n "${{ secrets._TEMP_GFE_PASSWORD }}" ]; then
+ export GFE_PASSWORD=${{ secrets._TEMP_GFE_PASSWORD }}
+ fi
+ ./gradlew -p deployment installDist # TODO: optimize the task graph
+
+ # --------------------------------------------------------------------------------------
+ # Deploy
+ # --------------------------------------------------------------------------------------
+
+ - name: Process inputs
+ id: process-inputs
+ shell: python
+ run: |
+ import os
+ import json
+
+ # Overlay all inputs and secrets onto this jobs outputs
+ callerInputs = os.getenv("CALLER_INPUTS")
+ inputs = os.getenv("INPUTS")
+ eventName = os.getenv("GITHUB_EVENT_NAME")
+
+ if inputs is not None and inputs != '':
+ inputs = json.loads(inputs)
+ if eventName == 'workflow_call' and callerInputs is not None and callerInputs != 'null':
+ os.system(f"echo 'Processing caller inputs'")
+ inputs = json.loads(callerInputs)
+
+ if inputs is not None and 'INPUTS' in inputs:
+ os.system("echo 'Processing inputs from caller'")
+ inputs = json.loads(inputs['INPUTS'])
+
+ # Iterate over inputs and assign them as outputs on this step
+
+ if inputs is not None and inputs != 'null':
+ for key, value in inputs.items():
+ os.system(f"echo 'Outputting input: {key}'")
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}<<EEOOFF\n{value}\nEEOOFF' >> $GITHUB_OUTPUT")
+ else:
+ os.system(f"echo '{key}={value}' >> $GITHUB_OUTPUT")
+ env:
+ CALLER_INPUTS: ${{ inputs.INPUTS }}
+ INPUTS: ${{ toJSON(github.event.inputs) }}
+
+ - name: Public IP
+ id: ip-address
+ shell: bash
+ run: |
+ OPTS="-sf -m 5"
+
+ # Try Primary v4 -> Fallback v4 -> Default to empty
+ PUBLIC_IPV4=$(curl $OPTS v4.ident.me || curl $OPTS 4.tnedi.me || true)
+
+ # Try Primary v6 -> Fallback v6 -> Default to empty
+ PUBLIC_IPV6=$(curl $OPTS v6.ident.me || curl $OPTS 6.tnedi.me || true)
+
+ # Validation: Ensure at least one IP was found
+ if [[ -z "$PUBLIC_IPV4" && -z "$PUBLIC_IPV6" ]]; then
+ echo "::error::Could not determine Public IP (both v4 and v6 failed)."
+ exit 1
+ fi
+
+ echo "ipv4=$PUBLIC_IPV4" >> $GITHUB_OUTPUT
+ echo "ipv6=$PUBLIC_IPV6" >> $GITHUB_OUTPUT
+
+ - name: Sanitize deployments value
+ id: deployments
+ shell: python
+ run: |
+ import os
+ import sys
+
+ repoOwner = os.getenv('GITHUB_REPOSITORY_OWNER')
+ isMainRepo = os.getenv('IS_MAIN_REPO') == 'true'
+ deployments = os.getenv('DEPLOYMENTS')
+ eventName = os.getenv('GITHUB_EVENT_NAME')
+ refType = os.getenv('GITHUB_REF_TYPE')
+ inputTag = os.getenv('INPUT_MANAGER_TAG')
+ inputEnv = os.getenv('INPUT_ENVIRONMENT')
+ managerVersion = os.getenv('MANAGER_VERSION')
+
+ if eventName == 'workflow_dispatch' and refType != 'tag' and repoOwner == 'openremote':
+ if isMainRepo:
+ tag=inputTag
+ if not inputTag:
+ tag='#ref'
+ else:
+ tag=managerVersion
+ deployments=f'{inputEnv}:{tag}'
+
+ if not isMainRepo:
+ if "-SNAPSHOT" in deployments:
+ os.system("echo 'SNAPSHOT manager docker images not currently supported for custom project deployment'")
+ sys.exit(1)
+ os.system(f"echo 'value={deployments}' >> $GITHUB_OUTPUT")
+ env:
+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}
+ MANAGER_VERSION: ${{ steps.is_main_repo.outputs.version }}
+ DEPLOYMENTS: ${{ steps.ci-cd-output.outputs.deploys }}
+ INPUT_ENVIRONMENT: ${{ steps.process-inputs.outputs.ENVIRONMENT }}
+ INPUT_MANAGER_TAG: ${{ steps.process-inputs.outputs.MANAGER_TAG }}
+
+ - name: Output image tag
+ id: get-image-tag
+ shell: bash
+ run: |
+ echo "refTag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
+
+ - name: Do deployments
+ shell: python
+ run: |
+ import json
+ import os
+ import sys
+ import subprocess
+
+ deployments = os.getenv("DEPLOYMENTS")
+ deployments = deployments.split(";")
+ managerRef = os.getenv("MANAGER_REF")
+ deploymentRef = os.getenv("DEPLOYMENT_REF")
+ isMainRepo = os.getenv("IS_MAIN_REPO") == 'true'
+ inputs = json.loads(os.getenv("INPUTS", "{}"))
+ secrets = json.loads(os.getenv("SECRETS", "{}"))
+ inputsAndSecrets = secrets | inputs
+ ipv4 = os.getenv("IPV4")
+ ipv6 = os.getenv("IPV6")
+
+ failure = False
+
+ # Clean-up AWS credentials related variable that might have been set by Configure AWS Credentials for ECR upload
+ os.environ.pop("AWS_ACCESS_KEY_ID", None)
+ os.environ.pop("AWS_SECRET_ACCESS_KEY", None)
+ os.environ.pop("AWS_SESSION_TOKEN", None)
+
+ # Determine deploy script to use
+ deployScript = ".ci_cd/deploy.sh"
+
+ if not os.path.exists(deployScript) and not isMainRepo:
+ deployScript = "openremote/.ci_cd/deploy.sh"
+
+ if not os.path.exists(deployScript):
+ os.system(f"Deploy script not found '{deployScript}'")
+ sys.exit(1)
+
+ for deployment in deployments:
+ dep = deployment.split(":")
+ env = dep[0]
+ managerTag = dep[1]
+ managerTagFound = True
+
+ os.putenv("MANAGER_TAG", managerTag)
+ os.putenv("ENVIRONMENT", env)
+
+ # Clean stale ssh credentials and temp files
+ os.system("rm temp.env 2>/dev/null")
+ os.system("rm ssh.key 2>/dev/null")
+ os.system("rm -r temp 2>/dev/null")
+ os.system("mkdir temp")
+
+ # ------------------------------------------------------
+ # Output env variables to temp env file for POSIX shell
+ # ------------------------------------------------------
+
+ # Output inputs and secrets (spacial handling for SSH_KEY and some other variables)
+ # _$ENV_ prefixed keys are output last (to override any non env specific keys)
+ environment = (env if env else "").upper()
+ prefix = "_" + environment + "_"
+
+ for key, value in inputsAndSecrets.items():
+ if "." in key:
+ continue
+
+ envFile = "temp/env"
+
+ # Look for temp and env prefixed keys
+ if key.startswith("_"):
+ if key.startswith("_TEMP_"):
+ key = key.replace("_TEMP_", "")
+ envFile = "temp.env"
+ elif key.startswith(prefix):
+ key = key.replace(prefix, "")
+ else:
+ continue
+
+ if key == "github_token":
+ continue
+ else:
+ os.system(f"echo 'Secret found {key}...'")
+ if key == "SSH_KEY":
+ os.system(f"echo \"{value}\" > ssh.key")
+ else:
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}='\"'\"'' >> {envFile}")
+ os.system(f"echo '{value}'\"'\"'' >> {envFile}")
+ else:
+ os.system(f"echo '{key}='\"'\"'{value}'\"'\"'' >> {envFile}")
+
+ # Output new line
+ os.system(f"echo '\n' >> {envFile}")
+
+ # Output env file if exists
+ if os.path.exists(".ci_cd/env/.env"):
+ os.system(f"echo 'Outputting .ci_cd/env/.env to temp/env'")
+ os.system("cat .ci_cd/env/.env >> temp/env")
+ # Output new line
+ os.system(f"echo '\n' >> {envFile}")
+
+ # Output environment specific env file if exists
+ if env is not None and env != '' and os.path.exists(f".ci_cd/env/{env}.env"):
+ os.system(f"echo 'Outputting .ci_cd/env/{env}.env to temp/env'")
+ os.system(f"cat .ci_cd/env/{env}.env >> temp/env")
+ # Output new line
+ os.system(f"echo '\n' >> {envFile}")
+
+ # Set CIDR environment variable
+ if ipv4 is not None and ipv4 != '':
+ os.putenv("CIDR", ipv4 + '/32')
+ elif ipv6 is not None and ipv6 != '':
+ os.putenv("CIDR", ipv6 + '/64')
+
+ # Execute deploy script
+ os.system(f"echo 'Executing deploy script for deployment: managerTag={managerTag} deploymentTag={deploymentRef} environment={env}'")
+ # Uncomment this in combination with the SSH debug step afterwards to debug deployment script
+ #sys.exit(0)
+ result = subprocess.run(f"bash {deployScript}", shell=True)
+
+ if result.returncode != 0:
+ os.system(f"echo 'Deployment failed: managerTag={managerTag} deploymentTag={deploymentRef} environment={env}'")
+ failure = True
+ continue
+
+ if failure == True:
+ os.system("echo 'One or more deployments failed'")
+ sys.exit(1)
+ env:
+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}
+ DEPLOYMENTS: ${{ steps.deployments.outputs.value }}
+ BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
+ MANAGER_DOCKER_BUILD_PATH: manager/build/install/manager
+ DEPLOYMENT_DOCKER_BUILD_PATH: deployment/build
+ MANAGER_REF: ${{ steps.get-image-tag.outputs.refTag }}
+ DEPLOYMENT_REF: ${{ steps.get-image-tag.outputs.refTag }}
+ INPUTS: ${{ toJSON(steps.process-inputs.outputs) }}
+ SECRETS: ${{ toJSON(secrets) }}
+ IPV4: ${{ steps.ip-address.outputs.ipv4 }}
+ IPV6: ${{ steps.ip-address.outputs.ipv6 }}
diff --git a/.github/workflows/install-browsers.yml b/.github/workflows/install-browsers.yml
new file mode 100644
index 000000000..2f756e9c8
--- /dev/null
+++ b/.github/workflows/install-browsers.yml
@@ -0,0 +1,17 @@
+name: Install browsers
+on: workflow_call
+
+jobs:
+ install-browsers:
+ name: Install browsers
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Install Playwright browsers
+ timeout-minutes: 20
+ run: npx playwright@$(jq -r ".devDependencies.playwright" ui/test/package.json) install chromium-headless-shell
+ - name: Upload Playwright browsers
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: playwright-browsers
+ path: /home/runner/.cache/ms-playwright
diff --git a/.github/workflows/install-dist.yml b/.github/workflows/install-dist.yml
new file mode 100644
index 000000000..aea1d19f2
--- /dev/null
+++ b/.github/workflows/install-dist.yml
@@ -0,0 +1,98 @@
+name: Install Dist
+
+on:
+ workflow_call:
+ inputs:
+ VERSION_WITH_QUALIFIER:
+ type: string
+ outputs:
+ npmTag:
+ description: The NPM package.json version
+ value: ${{ jobs.install-dist.outputs.npmTag }}
+
+jobs:
+ install-dist:
+ name: Install Dist
+ runs-on: ubuntu-latest
+ outputs:
+ npmTag: ${{ steps.update-package-json.outputs.tag }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ lfs: true # Enable Git LFS plugin to fetch *.mbtiles
+
+ - name: Check if main repo
+ id: is_main_repo
+ uses: openremote/openremote/.github/actions/check-if-main-repo@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+
+ - name: Update version in package.json files
+ id: update-package-json
+ if: ${{ inputs.VERSION_WITH_QUALIFIER != '' }}
+ run: |
+ VERSION=$(awk '{print tolower($0)}' <<< $VERSION)
+
+ QUALIFIER=$(sed -E 's/.+-([a-z]+).*/\1/g' <<< $VERSION)
+ if [ "$QUALIFIER" == "$VERSION" ]; then
+ QUALIFIER=""
+ fi
+
+ if [ "$QUALIFIER" == "" ]; then
+ TAG="latest"
+ else
+ if [ "$QUALIFIER" == "snapshot" ]; then
+ # Add a timestamp to snapshot versions
+ VERSION="$VERSION.$(date +'%Y%m%d%H%M%S')"
+ else
+ # Separate qualifiers from numbers of alpha, beta, rc versions
+ VERSION=$(sed "s/$QUALIFIER/$QUALIFIER./g" <<< $VERSION)
+ fi
+ TAG="$QUALIFIER"
+ fi
+
+ find ui -maxdepth 3 -name package.json | xargs -I{} sed -i -E "s#\"version\": \".+\",#\"version\": \"$VERSION\",#" {}
+
+ echo "tag=$TAG" >> $GITHUB_OUTPUT
+ env:
+ VERSION: ${{ inputs.VERSION_WITH_QUALIFIER }}
+
+ - name: Run Install Dist
+ timeout-minutes: 20
+ run: ./gradlew installDist -x :deployment:installDist
+
+ - name: Archive manager build
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-manager-build
+ if-no-files-found: error
+ path: |
+ manager/build
+
+ - name: Archive UI component build
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-ui-component-build
+ if-no-files-found: error
+ path: |
+ ui/component/model/src/model.ts
+ ui/component/rest/src/restclient.ts
+ ui/component/**/custom-elements.json
+ ui/component/**/custom-elements-jsx.d.ts
+ ui/component/**/dist
+ ui/component/**/lib
+ ui/component/**/tsconfig.tsbuildinfo
+
+ - name: Archive MDI fonts
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ if: ${{ steps.is_main_repo.outputs.value == 'true' }}
+ with:
+ name: mdi-fonts
+ if-no-files-found: error
+ path: |
+ ui/app/shared/fonts/Material Design Icons
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
new file mode 100644
index 000000000..9a2bd4f51
--- /dev/null
+++ b/.github/workflows/integration-tests.yml
@@ -0,0 +1,48 @@
+name: Integration Tests
+on: workflow_call
+
+jobs:
+ integration-tests:
+ name: Integration Tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ lfs: true # Enable Git LFS plugin to fetch *.mbtiles
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - name: Pull Docker images
+ run: docker compose -f profile/dev-testing.yml pull # Only Keycloak and PostgreSQL for running integration tests
+ - name: Run integration tests
+ timeout-minutes: 20
+ run: |
+ # Run Integration Tests
+ # Make temp dir with 777 mask as docker seems to run as root
+ mkdir -pm 777 tmp
+
+ # Start the stack
+ docker compose -f profile/dev-testing.yml up -d --no-build
+
+ # Run the tests
+ ./gradlew :test:test
+ - name: Archive integration test results
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-integration-test-results
+ path: test/build/reports/tests
+ - name: Archive JaCoCo coverage outputs
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-integration-test-outputs
+ path: |
+ test/build/classes/java/main/**
+ test/build/classes/java/test/**
+ test/build/jacoco/*.exec
+ test/build/reports/tests/test/**
+ test/build/test-results/test/**
diff --git a/.github/workflows/publish-maven.yml b/.github/workflows/publish-maven.yml
new file mode 100644
index 000000000..6adfb103d
--- /dev/null
+++ b/.github/workflows/publish-maven.yml
@@ -0,0 +1,29 @@
+name: Maven
+on:
+ workflow_call:
+ inputs:
+ MAVEN_TAG:
+ type: string
+ required: true
+ secrets:
+ MAVEN_SIGNING_PASSWORD:
+ required: true
+ MAVEN_SIGNING_KEY:
+ required: true
+ MAVEN_USERNAME:
+ required: true
+ MAVEN_PASSWORD:
+ required: true
+
+jobs:
+ maven-publish:
+ name: Publish to Maven Central Sonatype
+ runs-on: ubuntu-latest
+ env:
+ MAVEN_TAG: ${{ inputs.MAVEN_TAG }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Publish to Maven Central Sonatype
+ run: ./gradlew publishToSonatype --no-parallel -PsigningKey=${{ secrets.MAVEN_SIGNING_KEY }} -PsigningPassword=${{ secrets.MAVEN_SIGNING_PASSWORD }} -PpublishUsername=${{ secrets.MAVEN_USERNAME }} -PpublishPassword=${{ secrets.MAVEN_PASSWORD }}"
+ - name: Release to Maven Central Sonatype
+ run: ./gradlew findSonatypeStagingRepository closeAndReleaseSonatypeStagingRepository -PpublishUsername=${{ secrets.MAVEN_USERNAME }} -PpublishPassword=${{ secrets.MAVEN_PASSWORD }}
diff --git a/.github/workflows/publish-npm-dry-run.yml b/.github/workflows/publish-npm-dry-run.yml
new file mode 100644
index 000000000..a8c685a01
--- /dev/null
+++ b/.github/workflows/publish-npm-dry-run.yml
@@ -0,0 +1,22 @@
+name: NPM publish dry run
+on: workflow_call
+
+jobs:
+ npm-dry-run:
+ name: NPM publish dry run
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-ui-component-build
+ path: ui/component
+ - name: Update when the `tsbuildinfo` files were last modified to 'now'
+ run: find . -name "*.tsbuildinfo" -exec touch {} +
+ # You can see how the TypeScript compiler invalidates the build artifacts by running:
+ # - `npx tsc -b --verbose`: to see if the artifacts are up-to-date
+ # - `find src | xargs touch`: to update component inputs
+ - run: yarn --immutable
+ - name: Run NPM publish dry run
+ timeout-minutes: 20
+ run: yarn workspaces foreach --all --no-private --topological npm publish --dry-run
diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml
new file mode 100644
index 000000000..f5ab2dc7e
--- /dev/null
+++ b/.github/workflows/publish-npm.yml
@@ -0,0 +1,31 @@
+name: NPM
+on:
+ workflow_call:
+ inputs:
+ tag:
+ required: true
+ type: string
+ secrets:
+ NPM_AUTH_TOKEN:
+ required: true
+
+jobs:
+ npm-publish:
+ name: Publish to NPM
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-ui-component-build
+ path: ui/component
+ - name: Update when the `tsbuildinfo` files were last modified to 'now'
+ run: find . -name "*.tsbuildinfo" -exec touch {} +
+ - run: yarn --immutable
+ - name: Publish to NPM
+ run: |
+ echo 'npmRegistries:' >> .yarnrc.yml
+ echo '"https://registry.yarnpkg.com":' >> .yarnrc.yml
+ echo "npmAuthToken: ${{ secrets.NPM_AUTH_TOKEN }}" >> .yarnrc.yml
+
+ yarn workspaces foreach --all --no-private --topological npm publish --tag ${{ inputs.tag }}
diff --git a/.github/workflows/push-snapshot-image.yml b/.github/workflows/push-snapshot-image.yml
new file mode 100644
index 000000000..37cacec0b
--- /dev/null
+++ b/.github/workflows/push-snapshot-image.yml
@@ -0,0 +1,23 @@
+name: Push Snapshot Image
+
+on:
+ workflow_dispatch:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ install-dist:
+ name: Build
+ uses: "./.github/workflows/install-dist.yml"
+
+ build-snapshot-image:
+ name: Build
+ needs: [install-dist]
+ uses: "./.github/workflows/build-snapshot-image.yml"
+ with:
+ PUSH: true
+ secrets:
+ AWS_DEVELOPERS_ACCOUNT_ID: ${{ secrets.OR_AWS_DEVELOPERS_ACCOUNT_ID }}
+ AWS_ECR_PUSH_ROLE: ${{ secrets.OR_GH_AWS_ECR_PUSH_ROLE }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index cd7578453..ceef68063 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -58,7 +58,7 @@ jobs:
- name: Create release
run: |
git push --follow-tags
- gh workflow run ci_cd.yml --ref $RELEASED_VERSION
+ gh workflow run staging.yml --ref $RELEASED_VERSION
gh release create $RELEASED_VERSION --generate-notes
env:
GH_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml
new file mode 100644
index 000000000..6c15dbe7a
--- /dev/null
+++ b/.github/workflows/review.yml
@@ -0,0 +1,121 @@
+name: Review
+
+on:
+ pull_request:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ detect-changes:
+ name: Detect whether code changed
+ runs-on: ubuntu-latest
+ outputs: # See https://github.com/tj-actions/changed-files/tree/2bb135777322059ee3a3c9239999b159ff49febc#outputs-
+ any_modified: ${{ steps.changed-files.outputs.backend_any_modified == 'true' || steps.changed-files.outputs.ui_any_modified == 'true' }}
+ backend_any_modified: ${{ steps.changed-files.outputs.backend_any_modified }}
+ ui_any_modified: ${{ steps.changed-files.outputs.ui_any_modified }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Detect changes
+ id: changed-files
+ uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
+ with:
+ files_yaml: |
+ ui:
+ - 'ui/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ backend:
+ - '!.ci_cd/**'
+ - '!deployment/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ - '!yarn.lock'
+
+ ui-check-dependencies:
+ name: Lint
+ needs: detect-changes
+ if: needs.detect-changes.outputs.ui_any_modified == 'true'
+ uses: "./.github/workflows/ui-check-dependencies.yml"
+
+ ui-check-outdated-translations:
+ name: Lint
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/ui-check-outdated-translations.yml"
+
+ install-browsers:
+ name: Build
+ needs: detect-changes
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/install-browsers.yml"
+
+ install-dist:
+ name: Build
+ needs: detect-changes
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/install-dist.yml"
+
+ unit-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/unit-tests.yml"
+
+ integration-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/integration-tests.yml"
+
+ code-coverage:
+ name: Test
+ needs: [unit-tests, integration-tests]
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/code-coverage.yml"
+
+ ui-component-tests:
+ name: Test
+ needs: [detect-changes, install-dist, install-browsers]
+ if: needs.detect-changes.outputs.ui_any_modified == 'true'
+ uses: "./.github/workflows/ui-component-tests.yml"
+
+ ui-app-tests:
+ name: Test
+ needs: [detect-changes, install-dist, install-browsers]
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/ui-app-tests.yml"
+
+ build-manager-image:
+ name: Build
+ needs: [detect-changes, install-dist]
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/build-manager-image.yml"
+ secrets:
+ DOCKERHUB_USER: ${{ secrets._TEMP_DOCKERHUB_USER }}
+ DOCKERHUB_PASSWORD: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
+
+ build-deployment-image: # Only here to check if it can build successfully
+ name: Build
+ needs: [detect-changes, install-dist]
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/build-deployment-image.yml"
+ with:
+ tag: develop
+
+ publish-npm-dry-run:
+ name: Publish
+ needs: [detect-changes, install-dist]
+ if: needs.detect-changes.outputs.ui_any_modified == 'true'
+ uses: "./.github/workflows/publish-npm-dry-run.yml"
+
+ get-version-details: # Only here to check if it can build successfully
+ name: Build / Get version details
+ needs: detect-changes
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Get version details
+ id: get-version-details
+ uses: openremote/openremote/.github/actions/get-version-details@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml
new file mode 100644
index 000000000..f9fc90840
--- /dev/null
+++ b/.github/workflows/staging.yml
@@ -0,0 +1,194 @@
+name: Staging
+
+on:
+ push:
+ branches: [master]
+ tags:
+ - '[0-9]+.[0-9]+.[0-9]+'
+ workflow_dispatch:
+ inputs:
+ ENVIRONMENT:
+ description: 'Environment to use (if any)'
+ MANAGER_TAG:
+ description: 'Manager docker tag to pull'
+ CLEAN_INSTALL:
+ description: 'Delete data before starting'
+ type: boolean
+ COMMIT:
+ description: 'Repo branch or commit SHA to checkout'
+ OR_HOSTNAME:
+ description: 'Host to deploy to (e.g. demo.openremote.app)'
+ OR_ADMIN_PASSWORD:
+ description: 'Admin password override'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ detect-changes:
+ name: Detect whether code changed
+ runs-on: ubuntu-latest
+ outputs:
+ # Code changes
+ # See https://github.com/tj-actions/changed-files/tree/2bb135777322059ee3a3c9239999b159ff49febc#outputs-
+ any_modified: ${{ steps.changed-files.outputs.backend_any_modified == 'true' || steps.changed-files.outputs.ui_any_modified == 'true' }}
+ backend_any_modified: ${{ steps.changed-files.outputs.backend_any_modified }}
+ ui_any_modified: ${{ steps.changed-files.outputs.ui_any_modified }}
+ # Version details
+ version: ${{ steps.get-version-details.outputs.version }}
+ version_with_qualifier: ${{ steps.get-version-details.outputs.version_with_qualifier }}
+ is_release: ${{ steps.get-version-details.outputs.is_release }}
+ # Processed ci_cd.json outputs
+ dockerTags: ${{ steps.ci-cd-output.outputs.dockerTags }}
+ mavenTag: ${{ steps.ci-cd-output.outputs.mavenTag }}
+ npmTag: ${{ steps.ci-cd-output.outputs.npmTag }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 2 # Must be 2 for push events to compare to previous commit
+
+ - name: Detect changes
+ id: changed-files
+ uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
+ with:
+ files_yaml: |
+ ui:
+ - 'ui/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ backend:
+ - '!.ci_cd/**'
+ - '!deployment/**'
+ - '!**/*.md'
+ - '!**/*.yml'
+ - '!yarn.lock'
+
+ - name: Get version details
+ id: get-version-details
+ uses: openremote/openremote/.github/actions/get-version-details@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Check ci_cd existence
+ id: check_cicd_json
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: ".ci_cd/ci_cd.json"
+
+ - name: Check if main repo
+ id: is_main_repo
+ uses: openremote/openremote/.github/actions/check-if-main-repo@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Process ci_cd.json file
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && (github.ref_type == 'tag' || (github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request')) }}
+ id: ci-cd-output
+ uses: openremote/openremote/.github/actions/process-cicd-json@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+ with:
+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }} # Shouldn't be needed in this context
+ MANAGER_VERSION: ${{ steps.is_main_repo.outputs.version }}
+ IS_RELEASE: ${{ steps.get-version-details.outputs.is_release }}
+ VERSION: ${{ steps.get-version-details.outputs.version }}
+
+ ui-check-dependencies:
+ name: Lint
+ needs: detect-changes
+ if: needs.detect-changes.outputs.ui_any_modified == 'true'
+ uses: "./.github/workflows/ui-check-dependencies.yml"
+
+ ui-check-outdated-translations:
+ name: Lint
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/ui-check-outdated-translations.yml"
+
+ install-browsers:
+ name: Build
+ needs: detect-changes
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/install-browsers.yml"
+
+ install-dist:
+ name: Build
+ needs: detect-changes
+ uses: "./.github/workflows/install-dist.yml"
+ with:
+ VERSION_WITH_QUALIFIER: ${{ needs.detect-changes.outputs.version_with_qualifier }}
+
+ unit-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/unit-tests.yml"
+
+ integration-tests:
+ name: Test
+ needs: detect-changes
+ if: needs.detect-changes.outputs.backend_any_modified == 'true'
+ uses: "./.github/workflows/integration-tests.yml"
+
+ ui-component-tests:
+ name: Test
+ needs: [detect-changes, install-dist, install-browsers]
+ if: needs.detect-changes.outputs.ui_any_modified == 'true'
+ uses: "./.github/workflows/ui-component-tests.yml"
+
+ ui-app-tests:
+ name: Test
+ needs: [detect-changes, install-dist, install-browsers]
+ if: needs.detect-changes.outputs.any_modified == 'true'
+ uses: "./.github/workflows/ui-app-tests.yml"
+
+ build-manager-image:
+ name: Build
+ needs: [detect-changes, install-dist, unit-tests, integration-tests, ui-check-outdated-translations, ui-component-tests, ui-app-tests]
+ if: | # If a dependency isn't successful (e.g. skipped) the condition isn't evaluated without always()
+ always() &&
+ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
+ uses: "./.github/workflows/build-manager-image.yml"
+ with:
+ tags: ${{ needs.detect-changes.outputs.dockerTags }}
+ secrets:
+ DOCKERHUB_USER: ${{ secrets._TEMP_DOCKERHUB_USER }}
+ DOCKERHUB_PASSWORD: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
+
+ # build-deployment-image: # TODO: enable when we have private registries for custom projects
+ # name: Build
+ # needs: [install-dist]
+ # uses: "./.github/workflows/build-deployment-image.yml"
+
+ publish-maven:
+ name: Publish
+ needs: [detect-changes, install-dist, unit-tests, integration-tests, ui-check-outdated-translations, ui-component-tests, ui-app-tests]
+ if: | # If a dependency isn't successful (e.g. skipped) the condition isn't evaluated without always()
+ always() &&
+ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
+ uses: "./.github/workflows/publish-maven.yml"
+ with:
+ MAVEN_TAG: ${{ needs.detect-changes.outputs.mavenTag }}
+ secrets:
+ MAVEN_SIGNING_PASSWORD: ${{ secrets._TEMP_MAVEN_SIGNING_PASSWORD }}
+ MAVEN_SIGNING_KEY: ${{ secrets._TEMP_MAVEN_SIGNING_KEY }}
+ MAVEN_USERNAME: ${{ secrets._TEMP_MAVEN_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets._TEMP_MAVEN_PASSWORD }}
+
+ publish-npm:
+ name: Publish
+ needs: [detect-changes, install-dist, unit-tests, integration-tests, ui-check-outdated-translations, ui-component-tests, ui-app-tests]
+ if: | # If a dependency isn't successful (e.g. skipped) the condition isn't evaluated without always()
+ always() &&
+ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
+ uses: "./.github/workflows/publish-npm.yml"
+ with:
+ tag: ${{ needs.install-dist.outputs.npmTag }}
+ secrets:
+ NPM_AUTH_TOKEN: ${{ secrets._TEMP_NPM_AUTH_TOKEN }}
+
+ deployment:
+ name: Deploy
+ needs: [detect-changes, unit-tests, integration-tests, ui-check-outdated-translations, ui-component-tests, ui-app-tests]
+ if: | # If a dependency isn't successful (e.g. skipped) the condition isn't evaluated without always()
+ always() &&
+ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
+ uses: "./.github/workflows/deployment.yml"
+ with:
+ INPUTS: ${{ toJSON(inputs) }}
+ secrets: inherit
diff --git a/.github/workflows/ui-app-tests.yml b/.github/workflows/ui-app-tests.yml
new file mode 100644
index 000000000..81cf6b653
--- /dev/null
+++ b/.github/workflows/ui-app-tests.yml
@@ -0,0 +1,52 @@
+name: UI App Tests
+on: workflow_call
+
+jobs:
+ ui-app-tests:
+ name: UI App Tests
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ shardIndex: [1, 2, 3, 4]
+ shardCount: [4]
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ lfs: true # Enable Git LFS plugin to fetch *.mbtiles
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-manager-build
+ path: manager/build
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-ui-component-build
+ path: ui/component
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: playwright-browsers
+ path: /home/runner/.cache/ms-playwright
+ - name: Make Playwright browser binaries executable
+ run: chmod -R +x /home/runner/.cache/ms-playwright
+ # - name: Install Playwright browsers dependencies
+ # run: npx playwright@$(jq -r ".devDependencies.playwright" ui/test/package.json) install-deps chromium-headless-shell
+ - name: Set up JDK 21 and gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - name: Run UI App Tests
+ timeout-minutes: 20
+ run: |
+ # Start the stack
+ docker compose -f profile/dev-testing.yml up -d --no-build
+
+ # Run the tests
+ ./gradlew -p ui/app npmTest -Pargs="--shard=${{ matrix.shardIndex }}/${{ matrix.shardCount }}"
+ - name: Archive UI app test results
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-ui-app-test-results-${{ matrix.shardIndex }}
+ path: ui/app/*/app-test-report/**
diff --git a/.github/workflows/ui-check-dependencies.yml b/.github/workflows/ui-check-dependencies.yml
new file mode 100644
index 000000000..167b19581
--- /dev/null
+++ b/.github/workflows/ui-check-dependencies.yml
@@ -0,0 +1,18 @@
+name: UI Check Dependencies
+on: workflow_call
+
+jobs:
+ ui-check-dependencies:
+ name: UI Check Dependencies
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Set up JDK 21 and gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - name: Check UI dependencies
+ timeout-minutes: 20
+ run: ./gradlew knip
diff --git a/.github/workflows/ui-check-outdated-translations.yml b/.github/workflows/ui-check-outdated-translations.yml
new file mode 100644
index 000000000..0fa1a10cf
--- /dev/null
+++ b/.github/workflows/ui-check-outdated-translations.yml
@@ -0,0 +1,32 @@
+name: UI Check Outdated Translations
+on: workflow_call
+
+jobs:
+ ui-check-outdated-translations:
+ name: Check for outdated translations
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - name: Check for outdated translations
+ timeout-minutes: 20
+ run: |
+ # Check Outdated Translations
+ ./gradlew -p ui/app/shared processTranslations --no-parallel
+
+ out=$(git status --porcelain | grep "ui/app/shared/locales" || true)
+ if [[ -z "$out" ]]; then
+ echo "✅ No pipeline changes detected."
+ else
+ echo "❌ Pipeline files have changed. Please run:
+ \`\`\`sh
+ ./gradlew -p ui/app/shared processTranslations --no-parallel
+ \`\`\`
+ $out" >> $GITHUB_STEP_SUMMARY
+ exit 1
+ fi
diff --git a/.github/workflows/ui-component-tests.yml b/.github/workflows/ui-component-tests.yml
new file mode 100644
index 000000000..f30b9273e
--- /dev/null
+++ b/.github/workflows/ui-component-tests.yml
@@ -0,0 +1,42 @@
+name: UI Component Tests
+on: workflow_call
+
+jobs:
+ ui-component-tests:
+ name: UI Component Tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: mdi-fonts
+ path: ui/app/shared/fonts/Material Design Icons
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: or-ui-component-build
+ path: ui/component
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: playwright-browsers
+ path: /home/runner/.cache/ms-playwright
+ - name: Make Playwright browser binaries executable
+ run: chmod -R +x /home/runner/.cache/ms-playwright
+ # - name: Install Playwright browsers dependencies
+ # run: npx playwright@$(jq -r ".devDependencies.playwright" ui/test/package.json) install-deps chromium-headless-shell
+ - name: Update when the `tsbuildinfo` files were last modified to 'now'
+ run: find . -name "*.tsbuildinfo" -exec touch {} +
+ - name: Run UI component tests
+ timeout-minutes: 20
+ run: ./gradlew -p ui/component npmTest
+ - name: Archive UI component test results
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-ui-component-test-results
+ path: ui/component/*/component-test-report/**
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
new file mode 100644
index 000000000..05d975546
--- /dev/null
+++ b/.github/workflows/unit-tests.yml
@@ -0,0 +1,48 @@
+name: Unit Tests
+on: workflow_call
+
+jobs:
+ unit-tests:
+ name: Unit Tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Set up JDK 21 and Gradle cache
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: "temurin"
+ java-version: "21"
+ cache: "gradle"
+
+ - name: Check if main repo
+ id: is_main_repo
+ uses: openremote/openremote/.github/actions/check-if-main-repo@9bf40702cf69c4b3de5f719f4c14b1240d9762d3
+
+ - name: Run unit tests
+ timeout-minutes: 20
+ run: |
+ if [ "${{ steps.is_main_repo.outputs.value }}" = "true" ]; then
+ ./gradlew test -x :test:test -x npmTest unitTestReport
+ else
+ ./gradlew test -x :test:test
+ fi
+
+ - name: Archive unit test results
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-unit-test-results
+ path: build/reports/tests/test/aggregated-results/
+
+ - name: Archive JaCoCo coverage outputs
+ if: always()
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: or-unit-test-outputs
+ path: |
+ **/build/classes/java/main/**
+ **/build/classes/java/test/**
+ **/build/jacoco/*.exec
+ **/build/reports/tests/test/**
+ **/build/test-results/test/**
diff --git a/ui/app/manager/build.gradle b/ui/app/manager/build.gradle
index 8ca2084ce..82eaf33d9 100644
--- a/ui/app/manager/build.gradle
+++ b/ui/app/manager/build.gradle
@@ -76,12 +76,13 @@ tasks.register('npmBuild', Exec) {
}
tasks.register('npmTest', Exec) {
- dependsOn getYarnInstallTask(), resolveTask(":ui:test:clean")
+ dependsOn resolveTask(":ui:test:installTestDeps"), resolveTask(":ui:test:clean")
commandLine npmCommand("yarn"), "run", "test"
+ args((findProperty('args')?.toString()?.tokenize()) ?: [])
}
tasks.register('npmTestUI', Exec) {
- dependsOn getYarnInstallTask(), resolveTask(":ui:test:clean")
+ dependsOn resolveTask(":ui:test:installTestDeps"), resolveTask(":ui:test:clean")
commandLine npmCommand("yarn"), "run", "test", "--ui"
}
diff --git a/ui/app/storybook/build.gradle b/ui/app/storybook/build.gradle
index 3084b60b4..da0f5557a 100644
--- a/ui/app/storybook/build.gradle
+++ b/ui/app/storybook/build.gradle
@@ -77,12 +77,13 @@ tasks.register('npmBuild', Exec) {
}
tasks.register('npmTest', Exec) {
- dependsOn getYarnInstallTask(), resolveTask(":ui:test:clean")
+ dependsOn resolveTask(":ui:test:installTestDeps"), resolveTask(":ui:test:clean")
commandLine npmCommand("yarn"), "run", "test"
+ args((findProperty('args')?.toString()?.tokenize()) ?: [])
}
tasks.register('npmTestUI', Exec) {
- dependsOn getYarnInstallTask(), resolveTask(":ui:test:clean")
+ dependsOn resolveTask(":ui:test:installTestDeps"), resolveTask(":ui:test:clean")
commandLine npmCommand("yarn"), "run", "test", "--ui"
}
diff --git a/ui/build.gradle b/ui/build.gradle
index 58dc5863f..f5104ba69 100644
--- a/ui/build.gradle
+++ b/ui/build.gradle
@@ -15,6 +15,17 @@ afterEvaluate {
}
}
-task modelWatch {
+tasks.register("modelWatch") {
dependsOn resolveTask(":ui:component:model:build"), resolveTask(":ui:component:rest:build")
}
+
+tasks.register("installKnipDeps", Exec) {
+ // Required to load the `rspack.config.js` and `rsbuild.config.ts` files, ref https://knip.dev/reference/known-issues#exceptions-from-config-files
+ commandLine npmCommand("yarn"), "workspaces", "focus", "@openremote/util", "@openremote/manager", "@openremote/storybook"
+}
+
+tasks.register("knip", Exec) {
+ dependsOn installKnipDeps
+ workingDir project.rootDir
+ commandLine npmCommand("npx"), "[email protected]", "-c", "ui/knip.jsonc"
+}
diff --git a/ui/component/core/package.json b/ui/component/core/package.json
index 8c0ecb027..575a2c601 100644
--- a/ui/component/core/package.json
+++ b/ui/component/core/package.json
@@ -15,6 +15,7 @@
"dist"
],
"scripts": {
+ "build": "npx tsc -b",
"test": "echo \"No tests\" && exit 0",
"prepack": "npx rspack"
},
diff --git a/ui/component/or-asset-viewer/package.json b/ui/component/or-asset-viewer/package.json
index 972d2ff2f..0cdb07143 100644
--- a/ui/component/or-asset-viewer/package.json
+++ b/ui/component/or-asset-viewer/package.json
@@ -14,6 +14,7 @@
},
"types": "lib/index.d.ts",
"scripts": {
+ "build": "npx tsc -b",
"analyze": "npx cem analyze --config ../custom-elements-manifest.config.mjs",
"test": "npx tsc -b && npx playwright test",
"prepack": "npx rspack"
diff --git a/ui/component/or-gauge/@types/gaugeJS.d.ts b/ui/component/or-gauge/@types/gaugeJS.d.ts
index 2ff38b12c..e60b70947 100644
--- a/ui/component/or-gauge/@types/gaugeJS.d.ts
+++ b/ui/component/or-gauge/@types/gaugeJS.d.ts
@@ -1,121 +1,3 @@
-declare module 'gaugeJS' {
-
- interface PointerOptions {
- length: number;
- strokeWidth: number;
- color: string;
- }
- interface BaseOptions {
- angle: number;
- lineWidth: number;
- radiusScale: number;
- pointer: PointerOptions;
- limitMax: boolean;
- limitMin: boolean;
- colorStart: string;
- colorStop: string;
- strokeColor: string;
- generateGradient: boolean;
- highDpiSupport: boolean;
- }
-
- interface StaticZoneOptions {
- strokeStyle: string;
- min: number;
- max: number;
- }
-
- export interface GaugeOptions extends BaseOptions {
- percentColors?: Array<[number, string]> | undefined;
- staticLabels?: {
- font: string;
- labels: number[];
- color?: string | undefined;
- fractionDigits?: number | undefined;
- } | undefined;
- staticZones?: StaticZoneOptions[] | Array<StaticZoneOptions & { height: number; }> | undefined;
- renderTicks?: {
- divisions: number;
- divWidth: number;
- divLength: number;
- divColor: string;
- subDivisions: number;
- subWidth: number;
- subLength: number;
- subColor: string;
- } | undefined;
- pointer: PointerOptions & {
- iconPath?: string | undefined;
- iconScale?: number | undefined;
- iconAngle?: number | undefined;
- };
- }
- export interface TextRendererElement {
- innerHTML: string;
- style: {
- fontSize: string;
- };
- }
-
- export class TextRenderer {
- constructor(element: TextRendererElement, fractionalDigits: number);
-
- private render(gauge: Gauge): string;
- }
-
- export class ValueUpdater {
- /**
- * The animation speed of the gauge pointer (default is 32)
- */
- animationSpeed: number;
-
- constructor(addToAnimationQueue?: boolean | null, clear?: boolean | null);
-
- update(force?: boolean | null): boolean;
- }
-
- export class BaseGauge extends ValueUpdater {
- /**
- * ?
- * @param textField
- */
- setTextField(textField: TextRenderer | TextRendererElement): TextRenderer;
-
- /**
- * Sets the minimum gauge value (prefer over gauge.minValue)
- * @param minValue
- */
- setMinValue(minValue: number): number[] | undefined;
-
- /**
- * Configure the gauge renderer with the given options.
- * @param options The configuration options for the gauge.
- */
- setOptions(options?: GaugeOptions | null): this;
- }
-
- export class Gauge extends BaseGauge {
- /**
- * The max gauge value.
- */
- maxValue: number;
-
- /**
- * Creates a new gauge renderer for the given canvas element.
- * @param canvas The canvas element to render to.
- */
- constructor(canvas: HTMLCanvasElement);
-
- /**
- * Configure the gauge renderer with the given options.
- * @param options The configuration options for the gauge.
- */
- setOptions(options?: GaugeOptions | null): this;
-
- /**
- * Sets the current value of the gauge pointer.
- * @param value
- */
- set(value: number): boolean;
- }
+declare module "gaugeJS" {
+ export * from "gaugejs";
}
diff --git a/ui/component/or-gauge/package.json b/ui/component/or-gauge/package.json
index db3860e4b..2fdc8ab1d 100644
--- a/ui/component/or-gauge/package.json
+++ b/ui/component/or-gauge/package.json
@@ -25,12 +25,13 @@
"@openremote/model": "workspace:*",
"@openremote/or-icon": "workspace:*",
"@openremote/or-translate": "workspace:*",
- "gaugeJS": "^1.3.7",
+ "gaugeJS": "1.3.9",
"lit": "^3.3.1",
"lodash.debounce": "^4.0.8"
},
"devDependencies": {
"@openremote/util": "workspace:*",
+ "@types/gaugejs": "1.3.5",
"@types/lodash.debounce": "^4"
},
"publishConfig": {
diff --git a/ui/component/or-log-viewer/package.json b/ui/component/or-log-viewer/package.json
index 75f4df9c8..1aad482dd 100644
--- a/ui/component/or-log-viewer/package.json
+++ b/ui/component/or-log-viewer/package.json
@@ -15,6 +15,7 @@
"types": "lib/index.d.ts",
"scripts": {
"analyze": "npx cem analyze --config ../custom-elements-manifest.config.mjs",
+ "build": "npx tsc -b",
"test": "echo \"No tests\" && exit 0",
"prepack": "npx rspack"
},
@@ -33,7 +34,8 @@
"moment": "^2.29.4"
},
"devDependencies": {
- "@openremote/util": "workspace:*"
+ "@openremote/util": "workspace:*",
+ "@types/http-link-header": "1.0.7"
},
"publishConfig": {
"access": "public"
diff --git a/ui/component/or-log-viewer/src/index.ts b/ui/component/or-log-viewer/src/index.ts
index a2a8b5e0d..f22c0feef 100644
--- a/ui/component/or-log-viewer/src/index.ts
+++ b/ui/component/or-log-viewer/src/index.ts
@@ -19,13 +19,12 @@ import moment from "moment";
import "@openremote/or-mwc-components/or-mwc-menu";
import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/or-mwc-menu";
import {ListItem} from "@openremote/or-mwc-components/or-mwc-list";
-import { GenericAxiosResponse } from "axios";
+import type { GenericAxiosResponse } from "axios";
import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";
import { when } from "lit/directives/when.js";
-
+import { parse } from "http-link-header";
// TODO: Add webpack/rollup to build so consumers aren't forced to use the same tooling
-const linkParser = require("http-link-header");
const tableStyle = require("@material/data-table/dist/mdc.data-table.css");
export interface ViewerConfig {
@@ -508,8 +507,8 @@ export class OrLogViewer extends translate(i18next)(LitElement) {
protected _getPageCount(response: GenericAxiosResponse<any>): number | undefined {
const linkHeaders = response.headers["link"] as any;
if (linkHeaders) {
- const links = linkParser.parse(linkHeaders);
- let lastLink = links.rel("last");
+ const links = parse(linkHeaders);
+ let lastLink: any = links.rel("last");
if (Array.isArray(lastLink) && lastLink.length > 0) {
lastLink = lastLink[0];
}
diff --git a/ui/component/or-vaadin-components/package.json b/ui/component/or-vaadin-components/package.json
index a1ac61505..8d09ea3a0 100644
--- a/ui/component/or-vaadin-components/package.json
+++ b/ui/component/or-vaadin-components/package.json
@@ -4,8 +4,6 @@
"description": "Vaadin Components packaged as components aligned with the OpenRemote design system",
"customElements": "custom-elements.json",
"main": "dist/umd/index.bundle.js",
- "module": "lib/index.js",
- "types": "src/index.d.ts",
"exports": {
".": "./lib/index.js",
"./*": "./lib/*.js",
diff --git a/ui/test/build.gradle b/ui/test/build.gradle
index 5766041b7..7dcfbd4f7 100644
--- a/ui/test/build.gradle
+++ b/ui/test/build.gradle
@@ -1,3 +1,15 @@
tasks.register("clean", Delete) {
delete "tmp"
}
+
+tasks.register("installBrowsers", Exec) {
+ mustRunAfter(resolveTask(":deployment:installDist"))
+ commandLine npmCommand("npx"), "playwright", "install", "chromium"
+}
+
+tasks.register('installTestDeps', Exec) {
+ onlyIf {
+ !gradle.taskGraph.hasTask(":yarnInstall")
+ }
+ commandLine npmCommand("yarn"), "workspaces", "focus", "@openremote/test", "@openremote/model", "@openremote/rest", "@openremote/core"
+}
diff --git a/ui/util/package.json b/ui/util/package.json
index 435651ed2..c0753e71c 100644
--- a/ui/util/package.json
+++ b/ui/util/package.json
@@ -28,6 +28,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"html-webpack-plugin": "^5.6.6",
+ "moment": "^2.29.4",
"moment-locales-webpack-plugin": "^1.2.0",
"prettier": "^2.5.1",
"querystring-es3": "^0.2.1",
diff --git a/yarn.lock b/yarn.lock
index 659dafaa7..a1008202f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2074,8 +2074,9 @@ __metadata:
"@openremote/or-icon": "workspace:*"
"@openremote/or-translate": "workspace:*"
"@openremote/util": "workspace:*"
+ "@types/gaugejs": "npm:1.3.5"
"@types/lodash.debounce": "npm:^4"
- gaugeJS: "npm:^1.3.7"
+ gaugeJS: "npm:1.3.9"
lit: "npm:^3.3.1"
lodash.debounce: "npm:^4.0.8"
languageName: unknown
@@ -2118,6 +2119,7 @@ __metadata:
"@openremote/or-mwc-components": "workspace:*"
"@openremote/or-translate": "workspace:*"
"@openremote/util": "workspace:*"
+ "@types/http-link-header": "npm:1.0.7"
axios: "npm:1.16.1"
http-link-header: "npm:^1.1.3"
lit: "npm:^3.3.1"
@@ -2390,6 +2392,7 @@ __metadata:
eslint-plugin-node: "npm:^11.1.0"
eslint-plugin-promise: "npm:^6.0.0"
html-webpack-plugin: "npm:^5.6.6"
+ moment: "npm:^2.29.4"
moment-locales-webpack-plugin: "npm:^1.2.0"
prettier: "npm:^2.5.1"
querystring-es3: "npm:^0.2.1"
@@ -3389,6 +3392,13 @@ __metadata:
languageName: node
linkType: hard
+"@types/gaugejs@npm:1.3.5":
+ version: 1.3.5
+ resolution: "@types/gaugejs@npm:1.3.5"
+ checksum: 10c0/c88a0f9718936d41f2c5a95f56f52ddb0ace49b4d2347fa397597de462da8e37e9f3a80a553066df86446e3ee3fa640f0718a6cc67661155d43e8f3975b64c33
+ languageName: node
+ linkType: hard
+
"@types/geojson-vt@npm:3.2.5":
version: 3.2.5
resolution: "@types/geojson-vt@npm:3.2.5"
@@ -3433,6 +3443,15 @@ __metadata:
languageName: node
linkType: hard
+"@types/http-link-header@npm:1.0.7":
+ version: 1.0.7
+ resolution: "@types/http-link-header@npm:1.0.7"
+ dependencies:
+ "@types/node": "npm:*"
+ checksum: 10c0/ffde4514a286ee62fab86bd5164958f5c9ad9d8012eaeb4f5536efa6157e6cf9f93121d5a39bf160c3712554d945300a223a9f8b1f3fb08cc70b73f539767338
+ languageName: node
+ linkType: hard
+
"@types/http-proxy@npm:^1.17.8":
version: 1.17.14
resolution: "@types/http-proxy@npm:1.17.14"
@@ -7232,10 +7251,10 @@ __metadata:
languageName: node
linkType: hard
-"gaugeJS@npm:^1.3.7":
- version: 1.3.7
- resolution: "gaugeJS@npm:1.3.7"
- checksum: 10c0/178cfec48146da9b7919aa11c948059686671c5c31253c41c18e8b9350527576fd50ff8153dfeda6516139f831f9960765f610c00df650bc9ea5a90928356b0b
+"gaugeJS@npm:1.3.9":
+ version: 1.3.9
+ resolution: "gaugeJS@npm:1.3.9"
+ checksum: 10c0/ee2ad6b740942d96c1a0d043f53b656afa0ad0fb9b9f9e0e8fe4c0a23c8327d4bfe22b867442e074dde993409677adceae8cf23f85f4a1d7bad8b80b2cb4aa73
languageName: node
linkType: hard