-
Notifications
You must be signed in to change notification settings - Fork 9
215 lines (211 loc) · 7.75 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
---
name: Build
on:
push:
pull_request:
branches: [main, development]
merge_group:
permissions: read-all
jobs:
build-linux:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v4.2.2
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Downgrade libstdc++6 on ubuntu-22.04
# yamllint disable rule:line-length
if: ${{matrix.os == 'ubuntu-22.04'}}
run: |
#! /bin/bash
dpkg -l libstdc++6
sudo apt install libstdc++6=12.3.0-1ubuntu1~22.04 -y --allow-downgrades
- name: Build UmatiDashboardOpcUaClient with dependencies
run: |
#! /bin/bash
LIBCPP_VERSION="$(dpkg -s libstdc++6 | grep Version | awk '{match($0,"[0-9]+.[0-9].[0-9]",a)}END{print a[0]}')" # yamllint disable-line rule:line-length
echo "libstdc++6 version=$LIBCPP_VERSION"
mkdir -p build
cd build || exit
#shellcheck disable=SC2296
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" \
-DCMAKE_BUILD_TYPE="${{matrix.build_type}}" -DPAHO_WITH_SSL=1 -DBUILD_DEB_PACKAGE:BOOL=1 -DDEB_PACKAGE_LIBCPP_VERSION="$LIBCPP_VERSION"
cmake --build . -j
cd Dashboard-Client-build
make package
# yamllint enable rule:line-length
- name: Run Tests
run: |
#! /bin/bash
cd build/Dashboard-Client-build || exit
ctest -V -C "${{matrix.build_type}}"
- name: Run integration test cacert_test
# yamllint disable rule:line-length
run: |
#! /bin/bash
cd UmatiDashboardOpcUaClient/Tests/integration/cacert_test || exit
./genCerts.sh
cp "${{ github.workspace }}/build/Dashboard-Client-build/Tests/unit/TestCaCertificate" .
docker compose up -d
./evaluateTest.sh
# yamllint enable rule:line-length
- name: Upload Artefacts
uses: actions/upload-artifact@v4
with:
# yamllint disable rule:line-length
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
- name: Upload Debian package
uses: actions/upload-artifact@v4
with:
name: dashboardopcuaclient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}.deb
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/*.deb
# yamllint enable rule:line-length
build-windows:
strategy:
matrix:
os: [windows-2019, windows-2022]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v4.2.2
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
shell: pwsh
# yamllint disable rule:line-length
run: |
#shellcheck disable=SC1073,SC1050,SC1141,SC1083,SC1072,SC2296
$matrixarch = "${{matrix.arch}}"
if($matrixarch -eq "386"){$arch="Win32"}
if($matrixarch -eq "amd64"){$arch="x64"}
mkdir -p build
cd build || exit
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }} -A "$arch" -DPAHO_WITH_SSL=1
cmake --build . -j --config ${{matrix.build_type}}
# yamllint enable rule:line-length
- name: Run Tests
shell: pwsh
run: |
cd build/Dashboard-Client-build || exit
ctest -V -C ${{matrix.build_type}}
- name: Download CA Certs
shell: pwsh
run: |
cd ${{ env.CMAKE_INSTALL_PREFIX }}
mkdir -p bin/certs
curl https://curl.se/ca/cacert.pem -o bin/certs/cacert.pem -s
- name: Upload Artefacts
uses: actions/upload-artifact@v4
with:
# yamllint disable rule:line-length
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
# yamllint enable rule:line-length
docker:
permissions:
packages: write
runs-on: ubuntu-24.04
env:
# Check if this is not a pull request and GITHUB_TOKEN is set
# As all env variables are strings, you need to compare
# against "== 'true'" (not "== true")
IS_NOT_PR: ${{ !github.head_ref && true }}
steps:
- name: Checkout Code
uses: actions/checkout@v4.2.2
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
#! /bin/bash
#shellcheck disable=SC2296
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
if: env.IS_NOT_PR == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: docker/build-push-action@v6.9.0
with:
file: "./UmatiDashboardOpcUaClient/Dockerfile"
context: ./UmatiDashboardOpcUaClient
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
- name: Run integration test mqtt
if: ${{env.IS_NOT_PR == 'true'}}
run: |
#! /bin/bash
python -m pip install --upgrade pip
cd ./UmatiDashboardOpcUaClient/Tests/integration/mqtt_test || exit
pip install -r requirements.txt
docker compose up -d
./waitForContainer.sh
python -m unittest discover test_mqtt_sampleserver
release:
permissions:
contents: write
runs-on: ubuntu-24.04
needs: [build-linux, build-windows]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v3.1.4
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
workflow_conclusion: success
repo: ${{ github.repository }}
commit: ${{github.event.pull_request.head.sha}}
if_no_artifact_found: fail
skip_unpack: true
- name: Checksum
run: |
#! /bin/bash
sha256sum ./*.zip > SHA256-checksums
- name: Display structure of downloaded files
run: ls -R
- name: Release
uses: softprops/action-gh-release@v2.0.9
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./*.zip
SHA256-checksums