Skip to content

Commit bad87b4

Browse files
author
Aliaksandr Adziareika
committed
Move common assertions form testing workflow to composite actions
1 parent 3255529 commit bad87b4

File tree

3 files changed

+99
-104
lines changed

3 files changed

+99
-104
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 'Assert openDAQ Installed'
2+
description: 'Verify that openDAQ package is installed on the system'
3+
4+
inputs:
5+
is-32bit:
6+
description: 'Check for 32-bit installation on Windows'
7+
required: false
8+
default: false
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Verify Installation (Linux)
14+
if: runner.os == 'Linux'
15+
shell: bash
16+
run: |
17+
if ! dpkg -l | grep -q opendaq; then
18+
echo "::error::✗ Package not found"
19+
exit 1
20+
fi
21+
22+
- name: Verify Installation (Windows)
23+
if: runner.os == 'Windows'
24+
shell: pwsh
25+
run: |
26+
if ("${{ inputs.is-32bit }}" -eq "true") {
27+
$installPath = "C:\Program Files (x86)\openDAQ"
28+
$binPath = "C:\Program Files (x86)\openDAQ\bin"
29+
} else {
30+
$installPath = "C:\Program Files\openDAQ"
31+
$binPath = "C:\Program Files\openDAQ\bin"
32+
}
33+
34+
# Assert installation directory exists
35+
if (-not (Test-Path $installPath)) {
36+
Write-Host "::error::✗ Installation directory not found: $installPath"
37+
exit 1
38+
}
39+
40+
# Assert bin directory is in PATH
41+
if ($env:PATH -notlike "*$binPath*") {
42+
Write-Host "::error::✗ PATH does not contain: $binPath"
43+
exit 1
44+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Assert openDAQ Version Equals'
2+
description: 'Verify that installed openDAQ version matches expected version'
3+
4+
inputs:
5+
expected-version:
6+
description: 'Expected version (with v prefix and optional suffix like v3.30.0-rc)'
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Verify Version
13+
shell: bash
14+
run: |
15+
ACTUAL_VERSION=$(dpkg -s opendaq | grep '^Version:' | awk '{print $2}')
16+
EXPECTED_VERSION="${{ inputs.expected-version }}"
17+
EXPECTED_VERSION="${EXPECTED_VERSION#v}"
18+
EXPECTED_VERSION="${EXPECTED_VERSION%%-*}"
19+
20+
# Assert version matches
21+
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION"* ]]; then
22+
echo "::error::✗ Version mismatch: expected <$EXPECTED_VERSION> but was <$ACTUAL_VERSION>"
23+
exit 1
24+
fi

.github/workflows/test-install-sdk.yml

Lines changed: 31 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
- ubuntu-24.04
2626
- ubuntu-24.04-arm
2727
- ubuntu-latest
28-
2928
steps:
3029
- name: Checkout
3130
uses: actions/checkout@v4
@@ -35,16 +34,7 @@ jobs:
3534
uses: ./install-sdk
3635

3736
- name: Verify Installation
38-
env:
39-
INSTALLED_VERSION: ${{ steps.install.outputs.version }}
40-
run: |
41-
# Assert package is installed
42-
if ! dpkg -l | grep -q opendaq; then
43-
echo "::error::✗ Package not found"
44-
exit 1
45-
fi
46-
47-
echo "✓ Installation verification succeeded"
37+
uses: ./.github/actions/assert-opendaq-installed
4838

4939
ubuntu-versions-explicit:
5040
name: Ubuntu Versions Explicit (${{ matrix.version }})
@@ -56,9 +46,8 @@ jobs:
5646
version:
5747
- v3.30.0
5848
- v3.29.0-rc
49+
- v3.30.0
5950
- v3.19.4-rc
60-
- v3.10.0
61-
- v3.0.0
6251
steps:
6352
- name: Checkout
6453
uses: actions/checkout@v4
@@ -69,27 +58,13 @@ jobs:
6958
with:
7059
version: ${{ matrix.version }}
7160

72-
- name: Verify Installation
73-
env:
74-
INSTALLED_VERSION: ${{ matrix.version }}
75-
run: |
76-
# Assert package is installed
77-
if ! dpkg -l | grep -q opendaq; then
78-
echo "::error::✗ Package not found"
79-
exit 1
80-
fi
81-
82-
ACTUAL_VERSION=$(dpkg -s opendaq | grep '^Version:' | awk '{print $2}')
83-
EXPECTED_VERSION="${INSTALLED_VERSION#v}"
84-
EXPECTED_VERSION="${EXPECTED_VERSION%%-*}"
85-
86-
# Assert version matches
87-
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION"* ]]; then
88-
echo "::error::✗ Version mismatch: expected <$EXPECTED_VERSION> but was <$ACTUAL_VERSION>"
89-
exit 1
90-
fi
91-
92-
echo "✓ Installation verification succeeded"
61+
- name: Verify SDK Installed
62+
uses: ./.github/actions/assert-opendaq-installed
63+
64+
- name: Verify SDK Version
65+
uses: ./.github/actions/assert-opendaq-version-equals
66+
with:
67+
expected-version: ${{ matrix.version }}
9368

9469
ubuntu-versions-aliased:
9570
name: Ubuntu Versions Aliased (${{ matrix.version }})
@@ -110,90 +85,42 @@ jobs:
11085
with:
11186
version: ${{ matrix.version }}
11287

113-
- name: Verify Installation
114-
env:
115-
INSTALLED_VERSION: ${{ steps.install.outputs.version }}
116-
run: |
117-
# Assert package is installed
118-
if ! dpkg -l | grep -q opendaq; then
119-
echo "::error::✗ Package not found"
120-
exit 1
121-
fi
122-
123-
ACTUAL_VERSION=$(dpkg -s opendaq | grep '^Version:' | awk '{print $2}')
124-
EXPECTED_VERSION="${INSTALLED_VERSION#v}"
125-
EXPECTED_VERSION="${EXPECTED_VERSION%%-*}"
126-
127-
# Assert version matches
128-
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION"* ]]; then
129-
echo "::error::✗ Version mismatch: expected <$EXPECTED_VERSION> but was <$ACTUAL_VERSION>"
130-
exit 1
131-
fi
132-
133-
echo "✓ Installation verification succeeded"
134-
135-
windows-32bit:
136-
name: Windows 32-bit
88+
- name: Verify SDK Installed
89+
uses: ./.github/actions/assert-opendaq-installed
90+
91+
- name: Verify SDK Version
92+
uses: ./.github/actions/assert-opendaq-version-equals
93+
with:
94+
expected-version: ${{ steps.install.outputs.version }}
95+
96+
windows-autodetect:
97+
name: Windows Autodetect
13798
runs-on: windows-latest
13899
steps:
139100
- name: Checkout
140101
uses: actions/checkout@v4
141102

142-
- name: Install SDK (32-bit)
103+
- name: Install SDK (default version)
143104
id: install
144105
uses: ./install-sdk
145-
with:
146-
enable-32bit: true
147106

148-
- name: Verify Installation
149-
shell: pwsh
150-
env:
151-
INSTALLED_VERSION: ${{ steps.install.outputs.version }}
152-
run: |
153-
# Assert installation directory exists
154-
$installPath = "C:\Program Files (x86)\openDAQ"
155-
if (-not (Test-Path $installPath)) {
156-
Write-Host "::error::✗ Installation directory not found: $installPath"
157-
exit 1
158-
}
159-
160-
# Assert bin directory is in PATH
161-
$binPath = "C:\Program Files (x86)\openDAQ\bin"
162-
if ($env:PATH -notlike "*$binPath*") {
163-
Write-Host "::error::✗ PATH does not contain: $binPath"
164-
exit 1
165-
}
166-
167-
Write-Host "✓ Installation verification succeeded"
107+
- name: Verify SDK Installed
108+
uses: ./.github/actions/assert-opendaq-installed
168109

169-
windows-autodetect:
170-
name: Windows Autodetect
110+
windows-autodetect-version-32bit:
111+
name: Windows Autodetect Version (32-bit)
171112
runs-on: windows-latest
172113
steps:
173114
- name: Checkout
174115
uses: actions/checkout@v4
175116

176-
- name: Install SDK (default version)
117+
- name: Install SDK (32-bit)
177118
id: install
178119
uses: ./install-sdk
120+
with:
121+
enable-32bit: true
179122

180-
- name: Verify Installation
181-
shell: pwsh
182-
env:
183-
INSTALLED_VERSION: ${{ steps.install.outputs.version }}
184-
run: |
185-
# Assert installation directory exists (64-bit)
186-
$installPath = "C:\Program Files\openDAQ"
187-
if (-not (Test-Path $installPath)) {
188-
Write-Host "::error::✗ Installation directory not found: $installPath"
189-
exit 1
190-
}
191-
192-
# Assert bin directory is in PATH
193-
$binPath = "C:\Program Files\openDAQ\bin"
194-
if ($env:PATH -notlike "*$binPath*") {
195-
Write-Host "::error::✗ PATH does not contain: $binPath"
196-
exit 1
197-
}
198-
199-
Write-Host "✓ Installation verification succeeded"
123+
- name: Verify SDK Installed
124+
uses: ./.github/actions/assert-opendaq-installed
125+
with:
126+
is-32bit: true

0 commit comments

Comments
 (0)