-
-
Notifications
You must be signed in to change notification settings - Fork 305
171 lines (149 loc) · 5.44 KB
/
Copy pathmain.yml
File metadata and controls
171 lines (149 loc) · 5.44 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
---
# Continuous Integration Workflow: Test case suite run + validation build check
name: CI
# Controls when the action will run.
# Triggers the workflow on push or pull request events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# Job: Ruby unit tests across all supported Ruby versions and OSes.
# These are fast (no C compilation) and verify the generator logic is Ruby-version-portable.
ruby-tests:
name: "Ruby Tests (${{ matrix.os }}, Ruby ${{ matrix.ruby }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
ruby: ['3.0', '3.1', '3.2', '3.3']
exclude:
# create sparse matrix to avoid pointless duplication
- os: macos-latest
ruby: '3.0'
- os: macos-latest
ruby: '3.1'
- os: macos-latest
ruby: '3.2'
- os: windows-latest
ruby: '3.0'
- os: windows-latest
ruby: '3.1'
- os: windows-latest
ruby: '3.2'
steps:
- name: Checkout Latest Repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install Ruby Dependencies
run: |
gem install bundler
bundle install
- name: Run Ruby Unit Tests
env:
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
run: |
cd test && rake test:unit
- name: Run Style Check
env:
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
run: |
cd test && rake style:check
# Job: C compilation and system tests — only needs to run on one Ruby version per OS,
# since the generated C code and runtime behavior don't vary with the Ruby version.
c-tests:
name: "C Tests (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
# Install Multilib (Linux only)
- name: Install Multilib
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -qq
sudo apt-get install --assume-yes --quiet gcc-multilib
# Add MinGW GCC to PATH (Windows only — MSYS2 is pre-installed on the runner)
- name: Add GCC to PATH
if: matrix.os == 'windows-latest'
run: echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Checkout Latest Repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install Ruby Dependencies
run: |
gem install bundler
bundle install
- name: Run C Unit Tests
env:
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
run: cd test && rake test:c
- name: Run System Tests
env:
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
run: cd test && rake test:system
- name: Run Examples
env:
NO_COLOR: ${{ matrix.os == 'windows-latest' && '1' || '' }}
run: cd test && rake test:examples
# Job: Valgrind memory-leak check (Linux/gcc_64 only, latest Ruby)
valgrind:
name: "Valgrind Memory Check"
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
sudo apt-get update -qq
sudo apt-get install --assume-yes --quiet gcc-multilib valgrind
- name: Checkout Latest Repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install Ruby Dependencies
run: |
gem install bundler
bundle install
# Build and run C unit tests, then re-run the executable under valgrind.
# test:system clobbers the build directory, so check TestCMockC before that happens.
- name: Build and Run C Unit Tests
run: cd test && rake config[gcc_64_valgrind] test:c
- name: Valgrind Check - C Unit Tests
run: |
valgrind --leak-check=full --track-origins=yes --error-exitcode=1 \
test/system/build/TestCMockC.exe
# Build and run system tests, then re-run each executable under valgrind.
- name: Build and Run System Tests
run: cd test && rake config[gcc_64_valgrind] test:system
- name: Valgrind Check - System Tests
run: |
failed=0
for exe in test/system/build/test_*.exe; do
echo "Checking: $exe"
# Use exit code 42 to distinguish valgrind errors from Unity test failures.
# Some executables intentionally contain tests expected to fail (testing CMock's
# error-handling), so Unity exits non-zero. The `|| exit_code=$?` prevents bash's
# set -e from aborting the script on Unity's non-zero exit, while still capturing
# valgrind's own error exit code (42) separately.
exit_code=0
valgrind --leak-check=full --track-origins=yes --error-exitcode=42 "$exe" || exit_code=$?
[ $exit_code -eq 42 ] && failed=1
done
exit $failed