Skip to content

Commit 5a87f5e

Browse files
committed
<TBBAS-2595> Create shared forkflow for build and test simple device module with optional openDAQ framework package
1 parent 165a61a commit 5a87f5e

File tree

6 files changed

+217
-1
lines changed

6 files changed

+217
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Download openDAQ framework package from GitHub
2+
description: "Download openDAQ package from GitHub"
3+
4+
inputs:
5+
source-type:
6+
description: "Where to publish the build result (artifact or release)"
7+
required: true
8+
9+
opendaq-package-filename:
10+
description: "Package filename to download"
11+
required: true
12+
13+
artifact-run-id:
14+
required: false
15+
16+
opendaq-release-version:
17+
required: false
18+
default: ''
19+
20+
destination-directory:
21+
required: false
22+
default: ${{ runner.temp }}
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Validate arguments
28+
shell: bash
29+
run: |
30+
echo "::group::Validating openDAQ package inputs"
31+
32+
# Array of allowed source-types
33+
expected_source_types=("artifact" "release")
34+
actual_source_type="${{ inputs.source-type }}"
35+
package_filename="${{ inputs.opendaq-package-filename }}"
36+
37+
# Validate that source-type is not empty
38+
if [[ -z "$actual_source_type" ]]; then
39+
echo "::error ::❌ openDAQ package source-type is empty. Expected: ${expected_source_types[*]}"
40+
exit 1
41+
fi
42+
43+
# Validate that source-type is one of the allowed values
44+
if [[ ! " ${expected_source_types[@]} " =~ " ${actual_source_type} " ]]; then
45+
echo "::error ::❌ openDAQ package source-type='${actual_source_type}' is not supported. Expected: ${expected_source_types[*]}"
46+
exit 1
47+
fi
48+
49+
echo "::notice ::✅ openDAQ package source-type '${actual_source_type}' is valid."
50+
51+
# Validate that package filename is not empty
52+
if [[ -z "$package_filename" ]]; then
53+
echo "::error ::❌ openDAQ package filename is empty. It must not be empty."
54+
exit 1
55+
fi
56+
57+
echo "::notice ::✅ openDAQ package filename '${package_filename}' is valid."
58+
59+
echo "::endgroup::"
60+
61+
- name: Download openDAQ release
62+
if: ${{ inputs.source-type == 'release' }}
63+
run: gh release download ${{ inputs.opendaq-release-version }} --repo openDAQ/openDAQ --pattern ${{ inputs.opendaq-package-filename }} --dir ${{ inputs.destination-directory }}
64+
65+
- name: Download openDAQ artifact
66+
if: ${{ inputs.source-type == 'artifact' }}
67+
run: gh run download ${{ inputs.artifact-run-id }} --repo openDAQ/openDAQ --pattern ${{ inputs.opendaq-package-filename }} --dir ${{ inputs.destination-directory }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Download openDAQ artifact from GitHub
2+
description: "Download openDAQ artifact from GitHub workflow by run ID and artifact name"
3+
4+
inputs:
5+
opendaq-artifact-run-id:
6+
required: true
7+
8+
opendaq-artifact-name:
9+
required: true
10+
11+
destination-dir:
12+
required: false
13+
default: ${{ runner.temp }}
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Download openDAQ artifact
19+
shell: bash
20+
run: |
21+
gh run download ${{ inputs.opendaq-artifact-run-id }} --repo openDAQ/openDAQ --pattern ${{ inputs.opendaq-artifact-name }} --dir ${{ inputs.destination-dir }}
22+
echo ${{ inputs.destination-dir }}/${{ inputs.opendaq-artifact-name }}/
23+
ls -la ${{ inputs.destination-dir }}/${{ inputs.opendaq-artifact-name }}/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Download openDAQ framework release package from GitHub
2+
description: "Download openDAQ package from GitHub"
3+
4+
inputs:
5+
opendaq-release-version:
6+
required: false
7+
default: ''
8+
9+
destination-dir:
10+
required: false
11+
default: ${{ runner.temp }}
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Download openDAQ release
17+
shell: bash
18+
run: |
19+
echo "::group::Do openDAQ package inputs"
20+
gh release download
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Download openDAQ framework release package from GitHub
2+
description: "Download openDAQ package from GitHub"
3+
4+
inputs:
5+
opendaq-release-version:
6+
required: false
7+
default: ''
8+
9+
destination-dir:
10+
required: false
11+
default: ${{ runner.temp }}
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Download openDAQ release
17+
shell: bash
18+
run: |
19+
echo "::group::Download openDAQ package "
20+
gh release download ${{ inputs.opendaq-release-version }} --repo openDAQ/openDAQ --pattern ${{ inputs.opendaq-package-filename }} --dir ${{ inputs.destination-directory }}
21+

.github/workflows/build-tests.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build simple device module with openDAQ framework and run tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
runner:
7+
description: "Runner label"
8+
required: true
9+
type: string
10+
11+
branch:
12+
description: "Branch to checkout"
13+
required: true
14+
type: string
15+
16+
artifact-run-id:
17+
required: true
18+
type: string
19+
20+
artifact-name:
21+
required: true
22+
type: string
23+
24+
file-name:
25+
required: true
26+
type: string
27+
28+
workflow_call:
29+
inputs:
30+
runner:
31+
description: "Runner label"
32+
required: true
33+
type: string
34+
35+
branch:
36+
description: "Branch to checkout"
37+
required: true
38+
type: string
39+
40+
artifact-run-id:
41+
required: true
42+
type: string
43+
44+
artifact-name:
45+
required: true
46+
type: string
47+
48+
file-name:
49+
required: true
50+
type: string
51+
52+
env:
53+
GH_TOKEN: ${{ github.token }}
54+
55+
jobs:
56+
build:
57+
runs-on: ${{ inputs.runner }}
58+
59+
steps:
60+
- name: Checkout openDAQ module repository
61+
uses: actions/checkout@v4
62+
with:
63+
repository: openDAQ/SimpleDeviceModule
64+
ref: ${{ inputs.branch }}
65+
66+
- name: Download openDAQ framework package
67+
uses: ./.github/actions/opendaq-github-download-artifact
68+
with:
69+
opendaq-artifact-run-id: ${{ inputs.artifact-run-id }}
70+
opendaq-artifact-name: ${{ inputs.artifact-name }}
71+
72+
- name: Install openDAQ framework package
73+
uses: ./.github/actions/framework-install
74+
with:
75+
opendaq-framework-package-filename: ${{ inputs.artifact-name }}/${{ inputs.file-name }}
76+
77+
- name: Configure simple device module with CMake
78+
run: cmake -B build/output -S . -G "Ninja" -DEXAMPLE_MODULE_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
79+
80+
- name: Build simple device module with CMake
81+
run: cmake --build build/output --config Release
82+
83+
- name: Run simple device module tests with CMake
84+
run: ctest --test-dir build/output --output-on-failure -C Release -V
85+

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
generator: "Visual Studio 17 2022"
3939

4040
runs-on: ${{ matrix.os }}
41-
41+
4242
steps:
4343
- name: Checkout simple device module repo
4444
uses: actions/checkout@v4

0 commit comments

Comments
 (0)