-
Notifications
You must be signed in to change notification settings - Fork 124
134 lines (127 loc) · 4.59 KB
/
reusable-vm-build.yml
File metadata and controls
134 lines (127 loc) · 4.59 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
name: Reusable VM Build
on:
workflow_call:
inputs:
vm-type:
required: true
type: string
description: 'VM type (freebsd, netbsd, openbsd)'
vm-version:
required: true
type: string
description: 'VM version'
build-type:
required: true
type: string
description: 'CMake build type'
dependencies:
required: true
type: string
description: 'Commands to install dependencies'
cmake-flags:
required: false
type: string
default: ''
description: 'Additional CMake flags'
host-os:
required: false
type: string
default: 'ubuntu-22.04'
description: 'Host runner OS'
timeout-minutes:
required: false
type: number
default: 25
description: 'Job timeout in minutes'
coverage:
required: false
type: boolean
default: false
description: "When true, forces SNMALLOC_COVERAGE=ON and builds the 'coverage' target instead of running ctest, then uploads coverage.json. The VM 'dependencies' input must install llvm-profdata/llvm-cov."
coverage-artifact-name:
required: false
type: string
default: ''
description: "Suffix for the uploaded artifact, used as 'coverage-<suffix>'. Required when coverage is true. Validated against ^[A-Za-z0-9._-]+$."
jobs:
build:
runs-on: ${{ inputs.host-os }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Validate coverage inputs
if: inputs.coverage
shell: bash
run: |
if ! [[ "${{ inputs.coverage-artifact-name }}" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "::error::coverage-artifact-name must match ^[A-Za-z0-9._-]+\$ when coverage is true (got '${{ inputs.coverage-artifact-name }}')"
exit 1
fi
- name: Build on FreeBSD
if: inputs.vm-type == 'freebsd'
uses: vmactions/freebsd-vm@v1
with:
release: ${{ inputs.vm-version }}
usesh: true
mem: 8192
copyback: ${{ inputs.coverage }}
prepare: |
${{ inputs.dependencies }}
run: |
set -e
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -G Ninja ${{ inputs.cmake-flags }} ${{ inputs.coverage && '-DSNMALLOC_COVERAGE=ON' || '' }}
cd ${{ github.workspace }}/build
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
if [ "${{ inputs.coverage }}" = "true" ]; then
cmake --build . --target coverage
else
ctest -j 4 --output-on-failure -E '(perf-.*)|(.*-malloc$)' --timeout 400
fi
- name: Build on NetBSD
if: inputs.vm-type == 'netbsd'
uses: vmactions/netbsd-vm@v1
with:
release: ${{ inputs.vm-version }}
usesh: true
mem: 8192
copyback: ${{ inputs.coverage }}
prepare: |
${{ inputs.dependencies }}
run: |
set -e
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -G Ninja ${{ inputs.cmake-flags }} ${{ inputs.coverage && '-DSNMALLOC_COVERAGE=ON' || '' }}
cd ${{ github.workspace }}/build
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
if [ "${{ inputs.coverage }}" = "true" ]; then
cmake --build . --target coverage
else
ctest -j 4 --output-on-failure -E '(perf-.*)|(.*-malloc$)' --timeout 400
fi
- name: Build on OpenBSD
if: inputs.vm-type == 'openbsd'
uses: vmactions/openbsd-vm@v0
with:
release: ${{ inputs.vm-version }}
usesh: true
mem: 8192
copyback: ${{ inputs.coverage }}
prepare: |
${{ inputs.dependencies }}
run: |
set -e
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -G Ninja ${{ inputs.cmake-flags }} ${{ inputs.coverage && '-DSNMALLOC_COVERAGE=ON' || '' }}
cd ${{ github.workspace }}/build
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
if [ "${{ inputs.coverage }}" = "true" ]; then
cmake --build . --target coverage
else
ctest -j 4 --output-on-failure -E '(perf-.*)|(.*-malloc$)' --timeout 400
fi
- name: Upload coverage artifact
if: inputs.coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ inputs.coverage-artifact-name }}
path: ${{ github.workspace }}/build/coverage.json
if-no-files-found: error
retention-days: 7