-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (101 loc) · 3.92 KB
/
release.yml
File metadata and controls
120 lines (101 loc) · 3.92 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
name: Create Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential libcmocka-dev lcov python3
- name: Extract version info
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
TAG=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Find previous tag
PREV_TAG=$(git describe --tags --abbrev=0 ${GITHUB_REF}^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# If no previous tag, get the first commit
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
- name: Build with Coverage
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON
cmake --build build
- name: Run Tests
id: tests
run: |
cd build
# distinct output file for parsing
ctest --output-on-failure | tee test_output.log
# Simple parsing for summary stats
PASSED=$(grep -oE '[0-9]+% tests passed' test_output.log | grep -oE '[0-9]+' || echo "0")
TOTAL=$(grep -oE '[0-9]+ tests failed out of [0-9]+' test_output.log | awk '{print $6}' || echo "0")
if [ "$TOTAL" = "0" ]; then
# If 100% passed, grep matches "X tests passed, 0 tests failed out of Y"
TOTAL=$(grep -oE 'out of [0-9]+' test_output.log | awk '{print $3}' | head -n1 || echo "0")
fi
# Calculate Passed count
COUNT_PASSED=$(echo "$TOTAL * $PASSED / 100" | bc)
echo "{\"total\": $TOTAL, \"passed\": $COUNT_PASSED}" > ../test_stats.json
- name: Generate Coverage Report
run: |
cd build
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/tests/*' '*/examples/*' --output-file coverage.filtered.info --ignore-errors unused
lcov --list coverage.filtered.info > ../coverage_summary.txt || echo "Coverage: N/A" > ../coverage_summary.txt
# Extract percentage for summary file (e.g. "lines......: 85.5%")
grep "lines......:" ../coverage_summary.txt | awk '{print $2}' > ../coverage_percent.txt || echo "N/A" > ../coverage_percent.txt
- name: Generate Release Notes
id: notes
run: |
# Use our helper script
python3 tools/generate_release_notes.py \
"${{ steps.version.outputs.version }}" \
"${{ steps.version.outputs.prev_tag }}" \
"test_stats.json" \
"coverage_percent.txt" > release_notes.md
# Cat to console for debugging
cat release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: iolinki ${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: false
files: |
build/examples/simple_device/simple_device
build/tests/test_init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
back-merge-develop:
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge Main to Develop
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout develop
git merge origin/main
git push origin develop