Skip to content

Commit cc0805a

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

File tree

6 files changed

+201
-1
lines changed

6 files changed

+201
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
run: gh run download ${{ inputs.artifact-run-id }} --repo openDAQ/openDAQ --pattern ${{ inputs.opendaq-artifact-name }} --dir ${{ inputs.destination-directory }}
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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build simple device module with openDAQ framework and run tests
2+
3+
on:
4+
workflow_diplatch:
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+
workflow_call:
25+
inputs:
26+
runner:
27+
description: "Runner label"
28+
required: true
29+
type: string
30+
31+
branch:
32+
description: "Branch to checkout"
33+
required: true
34+
type: string
35+
36+
artifact-run-id:
37+
required: true
38+
type: string
39+
40+
artifact-name:
41+
required: true
42+
type: string
43+
44+
jobs:
45+
build:
46+
runs-on: ${{ inputs.runner }}
47+
48+
steps:
49+
- name: Checkout openDAQ module repository
50+
uses: actions/checkout@v4
51+
with:
52+
ref: ${{ inputs.branch }}
53+
54+
- name: Download openDAQ framework package
55+
uses: ./.github/actions/opendaq-github-download-artifact
56+
with:
57+
opendaq-artifact-run-id: ${{ inputs.artifact-run-id }}
58+
opendaq-artifact-name: ${{ inputs.artifact-name }}
59+
60+
- name: Install openDAQ framework package
61+
uses: ./.github/actions/framework-install
62+
with:
63+
opendaq-framework-package-filename: ${{ runner.temp }}/${{ inputs.opendaq-framework-filename }}
64+
65+
- name: Configure simple device module with CMake
66+
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DEXAMPLE_MODULE_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
67+
68+
- name: Build simple device module with CMake
69+
run: cmake --build build/output --config Release
70+
71+
- name: Run simple device module tests with CMake
72+
run: ctest --test-dir build/output --output-on-failure -C Release -V
73+

.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)