Skip to content

[Time Series] PR workflow (by @hteeyeoh via push) #11

[Time Series] PR workflow (by @hteeyeoh via push)

[Time Series] PR workflow (by @hteeyeoh via push) #11

#
# Apache v2 license
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
name: "[Time Series] PR workflow"
run-name: "[Time Series] PR workflow (by @${{ github.actor }} via ${{ github.event_name }})"
on:
push:
branches:
- 'main'
paths:
- 'microservices/time-series-analytics/*'
- 'microservices/time-series-analytics/config/**'
- 'microservices/time-series-analytics/docker/**'
- 'microservices/time-series-analytics/src/**'
- 'microservices/time-series-analytics/tests/**'
- 'microservices/time-series-analytics/tick_scripts/**'
- 'microservices/time-series-analytics/udfs/**'
pull_request:
paths:
- 'microservices/time-series-analytics/*'
- 'microservices/time-series-analytics/config/**'
- 'microservices/time-series-analytics/docker/**'
- 'microservices/time-series-analytics/src/**'
- 'microservices/time-series-analytics/tests/**'
- 'microservices/time-series-analytics/tick_scripts/**'
- 'microservices/time-series-analytics/udfs/**'
workflow_call:
workflow_dispatch:
permissions:
contents: read
packages: read
pull-requests: read
jobs:
timeseries-pre-merge-build:
permissions:
contents: read
packages: read # needed for actions/checkout
runs-on: ubuntu-24.04
steps:
- name: Runner workspace path
run: |
echo "Cleaning up previous run"
if [ -n "$(docker ps -aq)" ]; then
docker stop $(docker ps -aq)
fi
if [ -n "$(docker ps -aq)" ]; then
docker rm $(docker ps -aq)
fi
docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi -f
- uses: actions/checkout@v1
with:
path: timeseries
persist-credentials: false
- name: Build
run: |
cd ./microservices/time-series-analytics/docker
sed -i "s/DOCKER_REGISTRY=.*/DOCKER_REGISTRY=admin/g" .env
docker compose down -v
docker compose build
- name: Deploy
run: |
cd "${{ github.workspace }}"
cd ./microservices/time-series-analytics/docker
echo "Deploying time-series-analytics microservices"
docker compose up -d
- name: Undeploy
run: |
cd "${{ github.workspace }}"
cd ./microservices/time-series-analytics/docker
docker compose down -v
timeseries-unit-test:
name: Timeseries Unit Test
permissions:
contents: read
packages: read # needed for actions/checkout
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v1
with:
path: timeseries
persist-credentials: false
- name: Run unit tests
run: |
cd "${{ github.workspace }}"
cd ./microservices/time-series-analytics
echo "Running unit tests"
./tests/run_tests.sh
coverage=$(grep 'TOTAL' /tmp/unit-test-results.txt | awk '{print $4}')
# Extract test summary
summary=$(grep -Eo '[0-9]+ (passed|failed|skipped)' /tmp/unit-test-results.txt)
# Calculate total number of test cases
total_tests=$(echo "$summary" | awk '{sum += $1} END {print sum}')
# Extract number of passed tests
passed_tests=$(echo "$summary" | grep 'passed' | awk '{print $1}')
# Extract number of failed tests
failed_tests=$(echo "$summary" | grep 'failed' | awk '{print $1}')
# Print results
echo "Coverage: $coverage" >> $GITHUB_STEP_SUMMARY
echo "Total tests: $total_tests" >> $GITHUB_STEP_SUMMARY
echo "Passed tests: $passed_tests" >> $GITHUB_STEP_SUMMARY
echo "Failed tests: $failed_tests" >> $GITHUB_STEP_SUMMARY
- name: Upload HTML unit test coverage to Github
uses: actions/upload-artifact@v4
with:
name: unit-test-coverage
path: /tmp/htmlcov
- name: Upload XML unit test coverage to Github
uses: actions/upload-artifact@v4
with:
name: unit-test-report
path: /tmp/report.txt
timeseries-scans:
uses: ./.github/workflows/timeseries-scans-virus-bandit-pylint.yaml