Skip to content

Commit 21b36bf

Browse files
committed
cicd: add release workflow
execute tests and store artifacts
1 parent d002a79 commit 21b36bf

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

.github/workflows/release.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
name: Release Verification
14+
15+
# on:
16+
# release:
17+
# types: [created]
18+
on:
19+
pull_request:
20+
types: [opened, reopened, synchronize]
21+
22+
jobs:
23+
archive-report:
24+
runs-on: ubuntu-22.04
25+
permissions:
26+
contents: write # required to upload release assets
27+
28+
steps:
29+
- name: Checkout Repository
30+
uses: actions/checkout@v4.2.2
31+
32+
- name: Install lcov and libtinfo5
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y lcov libtinfo5
36+
37+
- name: Setup Bazel with shared caching
38+
uses: bazel-contrib/setup-bazel@0.15.0
39+
with:
40+
disk-cache: true
41+
repository-cache: true
42+
bazelisk-cache: true
43+
44+
- name: Bazel info (discover paths)
45+
id: bazel-info
46+
run: |
47+
echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV
48+
echo "BAZEL_USER_ROOT=$(bazel info output_user_root)" >> $GITHUB_ENV
49+
echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV
50+
bazel info
51+
52+
- name: Cache Bazel output base
53+
uses: actions/cache@v4
54+
with:
55+
path: |
56+
${{ env.BAZEL_OUTPUT_BASE }}/action_cache
57+
${{ env.BAZEL_OUTPUT_BASE }}/bazel-out
58+
${{ env.BAZEL_OUTPUT_BASE }}/external
59+
${{ env.BAZEL_OUTPUT_BASE }}/execroot
60+
key: bazel-ob-v2-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl', 'Cargo.lock') }}
61+
restore-keys: |
62+
bazel-ob-v2-${{ runner.os }}-
63+
64+
- name: Disk usage before build
65+
run: |
66+
df -h
67+
68+
# - name: Build via Bazel
69+
# run: |
70+
# echo "Running: bazel build //src/..."
71+
# bazel build //...
72+
73+
# - name: Run Unit Tests via Bazel
74+
# run: |
75+
# echo "Running: bazel test //:unit_tests"
76+
# bazel test //... --build_tests_only
77+
78+
- name: Restore some space
79+
run: |
80+
bazel clean --expunge
81+
82+
- name: Disk usage after clean
83+
run: |
84+
df -h
85+
86+
- name: Aggressive cleanup
87+
run: |
88+
# Remove .NET SDKs
89+
sudo rm -rf /usr/share/dotnet
90+
91+
# Remove Swift toolchain
92+
sudo rm -rf /usr/share/swift
93+
94+
# Remove Haskell (GHC)
95+
sudo rm -rf /usr/local/.ghcup
96+
97+
# Remove Julia
98+
sudo rm -rf /usr/local/julia*
99+
100+
# Remove Android SDKs
101+
sudo rm -rf /usr/local/lib/android
102+
103+
# Remove Chromium (optional if not using for browser tests)
104+
sudo rm -rf /usr/local/share/chromium
105+
106+
df -h
107+
108+
- name: Run Unit Test with Coverage for C++
109+
run: |
110+
# Run tests
111+
bazel coverage //... \
112+
--build_tests_only \
113+
--collect_code_coverage \
114+
--combined_report=lcov \
115+
--experimental_generate_llvm_lcov \
116+
--nocache_test_results \
117+
--nostamp
118+
# Generate HTML report
119+
genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \
120+
-o=cpp_coverage \
121+
--show-details \
122+
--legend \
123+
--function-coverage \
124+
--branch-coverage
125+
126+
- name: Create archive of test report
127+
run: |
128+
mkdir -p artifacts
129+
find bazel-testlogs/src/ -name 'test.xml' -print0 | xargs -0 -I{} cp --parents {} artifacts/
130+
cp -r cpp_coverage artifacts/
131+
zip -r ${{ github.event.repository.name }}_coverage_report.zip artifacts/
132+
shell: bash
133+
134+
- name: Upload artifacts
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: ${{ github.event.repository.name }}_coverage_report.zip
138+
path: ${{ github.event.repository.name }}_coverage_report.zip
139+
140+
- name: Upload release asset (attach ZIP to GitHub Release)
141+
uses: softprops/action-gh-release@v2.5.0
142+
with:
143+
files: ${{ github.event.repository.name }}_coverage_report.zip
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)