Repository navigation
550 lines (486 loc) · 19.5 KB
/
Copy pathrelease.yml
File metadata and controls
550 lines (486 loc) · 19.5 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
release_type:
description: 'Type of release'
required: true
default: 'stable'
type: choice
options:
- stable
- beta
- alpha
# Read-only by default (the repository's default token is read-only too); only the job that
# publishes the release gets write access.
permissions:
contents: read
env:
CMAKE_VERSION: '4.0.3'
jobs:
# ============================================================================
# Create Windows Release Packages
# ============================================================================
create-windows-packages:
name: Release Windows (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Windows releases
- os: windows-2022
platform: windows
arch: x64
cmake-generator: "Visual Studio 17 2022"
cmake-arch: x64
package-ext: zip
- os: windows-2022
platform: windows
arch: x86
cmake-generator: "Visual Studio 17 2022"
cmake-arch: Win32
package-ext: zip
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Windows MSVC
if: matrix.platform == 'windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.arch }}
- name: Setup Linux GCC
if: matrix.platform == 'linux'
run: |
apt-get update
apt-get install -y ninja-build git wget curl pkg-config
- name: Install CMake 4.0+
uses: lukka/get-cmake@fffaaafeea488556c2c12dad60690008bc1caacb # v4.4.2
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)(\.[0-9]+)?)?$ ]]; then
echo "Invalid release tag: $VERSION" >&2
exit 1
fi
PROJECT_VERSION=${VERSION#v}
PROJECT_VERSION=${PROJECT_VERSION%%-*}
else
VERSION=nightly-$(date +%Y%m%d)
PROJECT_VERSION=0.3.0
fi
PACKAGE_NAME="SpecLab-$VERSION-${{ matrix.platform }}-${{ matrix.arch }}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> "$GITHUB_ENV"
echo "PACKAGE_NAME=$PACKAGE_NAME" >> "$GITHUB_ENV"
echo "PACKAGE_DIR=$GITHUB_WORKSPACE/$PACKAGE_NAME" >> "$GITHUB_ENV"
if [ "${{ matrix.platform }}" = "windows" ]; then
echo "ARCHIVE_NAME=$PACKAGE_NAME.zip" >> "$GITHUB_ENV"
else
echo "ARCHIVE_NAME=$PACKAGE_NAME.tar.gz" >> "$GITHUB_ENV"
fi
shell: bash
- name: Configure Release Build (Windows)
if: matrix.platform == 'windows'
run: |
cmake -B release-build `
-G "${{ matrix.cmake-generator }}" `
-A ${{ matrix.cmake-arch }} `
-DCMAKE_BUILD_TYPE=Release `
-DSPECLAB_BUILD_EXAMPLES=ON `
-DSPECLAB_BUILD_TESTS=OFF `
-DSPECLAB_INSTALL_EXAMPLES=ON `
-DSPECLAB_PROJECT_VERSION="$env:PROJECT_VERSION" `
-DCMAKE_INSTALL_PREFIX="$env:PACKAGE_DIR" `
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD="d0edc3af-4c50-42ea-a356-e2862fe7a444"
- name: Configure Release Build (Linux)
if: matrix.platform == 'linux'
run: |
cmake -B release-build \
-G ${{ matrix.cmake-generator }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_C_COMPILER=gcc \
-DSPECLAB_BUILD_EXAMPLES=ON \
-DSPECLAB_BUILD_TESTS=OFF \
-DSPECLAB_INSTALL_EXAMPLES=ON \
-DSPECLAB_PROJECT_VERSION="$PROJECT_VERSION" \
-DCMAKE_INSTALL_PREFIX="$PACKAGE_DIR" \
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD="d0edc3af-4c50-42ea-a356-e2862fe7a444"
- name: Build Release
run: cmake --build release-build --config Release --parallel
- name: Test Release Build
run: |
cd release-build/examples
if [ "${{ matrix.platform }}" = "windows" ]; then
cd Release
./basic_example.exe
./pulse_oximeter_example.exe
else
./basic_example
./pulse_oximeter_example
fi
shell: bash
- name: Install Release
run: cmake --install release-build --config Release
- name: Create Release Documentation
run: |
cd "$PACKAGE_NAME"
cat > README.md << 'EOF'
# SpecLab Medical Device Testing Framework
**Version:** ${{ steps.get_version.outputs.version }}
**Platform:** ${{ matrix.platform }} ${{ matrix.arch }}
**Build Date:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')
## Medical Device Compliance
- ✅ IEC 62304:2015 - Software Lifecycle Processes
- ✅ ISO 14971:2019 - Risk Management
- ✅ FDA 21 CFR Part 820 - Quality System Regulation
- ✅ ISO 13485:2016 - Quality Management Systems
## Requirements
- **Windows**: Windows 10+ with MSVC 17.10+ (Visual Studio 2022 v17.10+)
- **Linux**: Ubuntu 20.04+ with GCC 16.1+ or Clang 20+
- **CMake**: 4.0+ (required for C++23 `import std` support)
## Quick Start
```cpp
import speclab;
using namespace speclab;
// Create a medical device test
auto test = Test("DEVICE_001")
.Given("device is powered on", []() { /* setup */ })
.When("SpO2 is measured", []() { /* action */ })
.Then("reading should be accurate", []() { /* verify */ });
auto result = test.Execute();
```
## Medical Device Examples
- **Pulse Oximeter**: Complete Class B medical device implementation
- **Requirements Traceability**: 6 SRS requirements with full traceability
- **BDD Testing**: Given-When-Then syntax for readable tests
- **Compliance Reporting**: Automated regulatory reports
## Files Included
- `lib/` - SpecLab library files
- `include/` - Header files and modules
- `examples/` - Medical device examples
- `docs/` - Documentation and compliance guides
## Support
For medical device development support and validation assistance:
- GitHub: https://github.com/your-org/SpecLab
- Documentation: https://speclab-docs.example.com
- Issues: https://github.com/your-org/SpecLab/issues
---
*This software has been validated for medical device development according to international standards.*
EOF
shell: bash
- name: Create Medical Device Compliance Guide
run: |
cd "$PACKAGE_NAME"
mkdir -p docs/compliance
cat > docs/compliance/IEC62304-Guide.md << 'EOF'
# IEC 62304 Compliance Guide for SpecLab
## Software Safety Classification
SpecLab supports all IEC 62304 safety classes:
- **Class A**: Non-safety software
- **Class B**: Non-life-threatening safety software
- **Class C**: Life-threatening safety software
## Lifecycle Processes
1. **Planning (5.1)**: CMake build system with medical device flags
2. **Requirements Analysis (5.2)**: Requirements API with traceability
3. **Architectural Design (5.3)**: C++23 modules architecture
4. **Detailed Design (5.4)**: Medical device specific modules
5. **Implementation (5.5)**: Type-safe C++23 implementation
6. **Integration Testing (5.6)**: Multi-threaded test runner
7. **System Testing (5.7)**: Medical device validation examples
## Using SpecLab for IEC 62304 Compliance
```cpp
// Define requirements with IEC 62304 metadata
RegisterRequirement({
.id = "REQ-SAFETY-001",
.description = "Critical SpO2 detection",
.riskLevel = "CRITICAL",
.safetyClass = "CLASS_C",
.requiresAudit = true,
.requiresValidation = true
});
// Create IEC 62304 compliant test case
class SafetyTest : public IEC62304TestCase {
public:
SafetyTest() : IEC62304TestCase("SAFETY_001", context,
LifecycleProcess::SystemTesting) {}
protected:
void run() override {
// Safety-critical test implementation
}
};
```
EOF
shell: bash
- name: Package Release (Windows)
if: matrix.platform == 'windows'
run: |
Compress-Archive -Path $env:PACKAGE_NAME -DestinationPath $env:ARCHIVE_NAME
- name: Package Release (Linux)
if: matrix.platform == 'linux'
run: |
tar -czf "$ARCHIVE_NAME" "$PACKAGE_NAME"
- name: Generate Package Checksums
run: |
sha256sum "$ARCHIVE_NAME" > "$ARCHIVE_NAME.sha256"
shell: bash
- name: Upload Release Package
uses: actions/upload-artifact@v4
with:
name: SpecLab-${{ steps.get_version.outputs.version }}-${{ matrix.platform }}-${{ matrix.arch }}
path: |
SpecLab-${{ steps.get_version.outputs.version }}-${{ matrix.platform }}-${{ matrix.arch }}.*
# ============================================================================
# Create Linux Release Packages
# ============================================================================
create-linux-packages:
name: Release Linux (x64)
runs-on: ubuntu-24.04
container:
image: gcc:16.1.0
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Linux GCC
run: |
apt-get update
apt-get install -y ninja-build git wget curl pkg-config
- name: Install CMake 4.0+
uses: lukka/get-cmake@fffaaafeea488556c2c12dad60690008bc1caacb # v4.4.2
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)(\.[0-9]+)?)?$ ]]; then
echo "Invalid release tag: $VERSION" >&2
exit 1
fi
PROJECT_VERSION=${VERSION#v}
PROJECT_VERSION=${PROJECT_VERSION%%-*}
else
VERSION=nightly-$(date +%Y%m%d)
PROJECT_VERSION=0.3.0
fi
PACKAGE_NAME="SpecLab-$VERSION-linux-x64"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> "$GITHUB_ENV"
echo "PACKAGE_NAME=$PACKAGE_NAME" >> "$GITHUB_ENV"
echo "PACKAGE_DIR=$GITHUB_WORKSPACE/$PACKAGE_NAME" >> "$GITHUB_ENV"
echo "ARCHIVE_NAME=$PACKAGE_NAME.tar.gz" >> "$GITHUB_ENV"
shell: bash
- name: Configure Release Build (Linux)
run: |
cmake -B release-build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_C_COMPILER=gcc \
-DSPECLAB_BUILD_EXAMPLES=ON \
-DSPECLAB_BUILD_TESTS=OFF \
-DSPECLAB_INSTALL_EXAMPLES=ON \
-DSPECLAB_PROJECT_VERSION="$PROJECT_VERSION" \
-DCMAKE_INSTALL_PREFIX="$PACKAGE_DIR" \
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD="d0edc3af-4c50-42ea-a356-e2862fe7a444"
- name: Build Release
run: cmake --build release-build --parallel
- name: Test Release Build
run: |
cd release-build/examples
./basic_example
./pulse_oximeter_example
- name: Install Release
run: cmake --install release-build
- name: Package Release (Linux)
run: |
tar -czf "$ARCHIVE_NAME" "$PACKAGE_NAME"
- name: Generate Package Checksums
run: |
sha256sum "$ARCHIVE_NAME" > "$ARCHIVE_NAME.sha256"
- name: Upload Release Package
uses: actions/upload-artifact@v4
with:
name: SpecLab-${{ steps.get_version.outputs.version }}-linux-x64
path: |
SpecLab-${{ steps.get_version.outputs.version }}-linux-x64.*
# ============================================================================
# Create GitHub Release
# ============================================================================
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [create-windows-packages, create-linux-packages]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# Creating a release and uploading its assets needs contents: write. Without it this job failed
# with "GitHub release failed with status: 403" for both v0.1.0 and v0.1.1, and each release had
# to be created by hand from the packages the other jobs built.
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all release packages
uses: actions/download-artifact@v4
with:
path: release-packages
- name: Get version and release notes
id: get_info
run: |
VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)(\.[0-9]+)?)?$ ]]; then
echo "Invalid release tag: $VERSION" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Release notes come from this version's CHANGELOG.md section, not from a fixed template.
# The template this replaces claimed IEC 62304 / ISO 14971 / FDA "validation", linked to
# documentation that does not exist, and said nothing about the release. Failing when the
# section is missing enforces the rule in AGENTS.md: the CHANGELOG entry lands before the tag.
PKG_VERSION=${VERSION#v}
awk -v heading="## [${PKG_VERSION}]" '
index($0, heading) == 1 { found = 1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md > changelog-section.md
if ! awk -v heading="## [${PKG_VERSION}]" 'index($0, heading) == 1 { found = 1 } END { exit !found }' CHANGELOG.md; then
echo "::error::CHANGELOG.md has no '## [${PKG_VERSION}]' section. Add it (in a PR) before tagging."
exit 1
fi
if ! grep -q '[^[:space:]]' changelog-section.md; then
echo "::error::CHANGELOG.md's '## [${PKG_VERSION}]' section is empty. Describe the release (in a PR) before tagging."
exit 1
fi
{
echo "# SpecLab ${VERSION}"
cat changelog-section.md
echo
echo "## Important"
echo
echo "SpecLab is an **experimental** project. Its compliance features are conceptual and educational: using it does not make software compliant with IEC 62304, ISO 13485 or ISO 14971, and it is not recommended for production use."
echo
echo "**Release tags are immutable.** \`${VERSION}\` points at \`${GITHUB_SHA::7}\` and will not be moved. Each package has a matching SHA-256 checksum file. The packages were built by [this workflow run](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})."
} > release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_info.outputs.version }}
name: "SpecLab ${{ steps.get_info.outputs.version }}"
body_path: release-notes.md
files: |
release-packages/**/*
draft: false
prerelease: ${{ contains(steps.get_info.outputs.version, 'alpha') || contains(steps.get_info.outputs.version, 'beta') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================================================
# Publish to Package Registries
# ============================================================================
publish-packages:
name: Publish Packages
runs-on: ubuntu-latest
needs: create-github-release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta)(\.[0-9]+)?)?$ ]]; then
echo "Invalid release tag: $VERSION" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "PACKAGE_VERSION=${VERSION#v}" >> "$GITHUB_ENV"
- name: Create vcpkg package manifest
run: |
mkdir -p vcpkg-package
cat > vcpkg-package/vcpkg.json << EOF
{
"name": "speclab",
"version": "$PACKAGE_VERSION",
"description": "Medical Device Testing Framework with IEC 62304, ISO 14971, and FDA 21 CFR Part 820 compliance",
"homepage": "https://github.com/your-org/SpecLab",
"documentation": "https://speclab-docs.example.com",
"license": "MIT",
"dependencies": [],
"features": {
"medical-compliance": {
"description": "Enable medical device compliance features",
"dependencies": []
},
"examples": {
"description": "Build medical device examples",
"dependencies": []
}
}
}
EOF
- name: Create Conan package
run: |
mkdir -p conan-package
cat > conan-package/conanfile.py << EOF
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import copy
class SpecLabConan(ConanFile):
name = "speclab"
version = "$PACKAGE_VERSION"
description = "Medical Device Testing Framework"
license = "MIT"
url = "https://github.com/your-org/SpecLab"
settings = "os", "compiler", "build_type", "arch"
options = {
"medical_compliance": [True, False],
"build_examples": [True, False]
}
default_options = {
"medical_compliance": True,
"build_examples": False
}
def requirements(self):
pass # No external dependencies
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["SPECLAB_BUILD_EXAMPLES"] = self.options.build_examples
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
EOF
- name: Upload package manifests
uses: actions/upload-artifact@v4
with:
name: package-manifests-${{ steps.get_version.outputs.version }}
path: |
vcpkg-package/
conan-package/