Skip to content

Commit 5744587

Browse files
[#88885] .github: Add github CI
1 parent a94b0e0 commit 5744587

5 files changed

Lines changed: 230 additions & 1 deletion

File tree

.github/workflows/.editorconfig

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# This is a modified copy of Renode .editorconfig.
2+
# It allows for running format checks in the renode-infrastructure repo without the Renode context.
3+
# Missing Renode means that some libraries are not available, this necessitates
4+
# removal of 'unused parameter', 'make readonly' and 'unused using' checks as otherwise
5+
# they would result in false-positives.
6+
7+
# Allow including user specific analyzers from global .editorconfig
8+
root = false
9+
10+
[*.cs]
11+
# By default disable all analyzers
12+
dotnet_analyzer_diagnostic.severity = none
13+
14+
# Whitespaces
15+
trim_trailing_whitespace = true
16+
csharp_space_after_keywords_in_control_flow_statements = false
17+
# Allow arbitrary number of spaces in decalrations
18+
csharp_space_around_declaration_statements = ignore
19+
20+
# Indentation options
21+
indent_size = 4
22+
indent_style = space
23+
csharp_indent_case_contents = true
24+
csharp_indent_case_contents_when_block = false
25+
csharp_indent_switch_labels = false
26+
csharp_indent_block_contents = true
27+
csharp_indent_braces = false
28+
29+
# New line preferences
30+
csharp_new_line_before_open_brace = all
31+
csharp_new_line_before_else = true
32+
csharp_new_line_before_catch = true
33+
csharp_new_line_before_finally = true
34+
csharp_new_line_before_members_in_object_initializers = true
35+
csharp_new_line_before_members_in_anonymous_types = true
36+
csharp_new_line_between_query_expression_clauses = true
37+
end_of_line = lf
38+
39+
# "var" instead of type
40+
dotnet_diagnostic.IDE0007.severity = suggestion
41+
# type instead of "var"
42+
dotnet_diagnostic.IDE0008.severity = none
43+
# Prefer "var" everywhere
44+
csharp_style_var_for_built_in_types = true
45+
csharp_style_var_when_type_is_apparent = true
46+
csharp_style_var_elsewhere = true
47+
48+
# Sort using directives alphabetically
49+
dotnet_sort_system_directives_first = true
50+
51+
# Separate using directives groups with new lines
52+
dotnet_separate_import_directive_groups = true
53+
54+
# Check for unassigned fields
55+
dotnet_diagnostic.CS0649.severity = warning
56+
57+
# Modifiers order
58+
dotnet_diagnostic.IDE0036.severity = warning
59+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
60+
61+
# Class members must have explicit accessibility modifiers
62+
dotnet_style_require_accessibility_modifiers = always:warning
63+
64+
# Enable checking naming rules
65+
dotnet_diagnostic.IDE1006.severity = warning
66+
67+
# camel_case_style - Define the camelCase style
68+
dotnet_naming_style.camel_case_style.capitalization = camel_case
69+
# pascal_case_style - Define the PascalCase style
70+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
71+
# prefix_interface_with_i_style - Define interfaces style
72+
dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case
73+
dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
74+
75+
# Interfaces use PascalCase and are prefixed with uppercase 'I'
76+
dotnet_naming_symbols.interface_group.applicable_kinds = interface
77+
dotnet_naming_rule.interface_rule.symbols = interface_group
78+
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
79+
dotnet_naming_rule.interface_rule.severity = warning
80+
81+
# All of the following must be PascalCase:
82+
# - Namespaces
83+
# - Classes and Enumerations
84+
# - Delegates
85+
# - Constructors, Properties, Events, Methods
86+
dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property
87+
dotnet_naming_rule.element_rule.symbols = element_group
88+
dotnet_naming_rule.element_rule.style = pascal_case_style
89+
dotnet_naming_rule.element_rule.severity = warning
90+
91+
# All constant fields must be PascalCase
92+
dotnet_naming_symbols.constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
93+
dotnet_naming_symbols.constant_fields_group.required_modifiers = const
94+
dotnet_naming_symbols.constant_fields_group.applicable_kinds = field
95+
dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.symbols = constant_fields_group
96+
dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.style = pascal_case_style
97+
dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.severity = warning
98+
99+
# All non-public fields must be camelCase
100+
dotnet_naming_symbols.fields_group.applicable_accessibilities = internal, protected_internal, protected, private_protected, private
101+
dotnet_naming_symbols.fields_group.applicable_kinds = field
102+
dotnet_naming_rule.fields_must_be_camel_case_rule.symbols = fields_group
103+
dotnet_naming_rule.fields_must_be_camel_case_rule.style = camel_case_style
104+
dotnet_naming_rule.fields_must_be_camel_case_rule.severity = warning
105+
106+
# All public fields must be PascalCase
107+
dotnet_naming_symbols.public_fields_group.applicable_accessibilities = public
108+
dotnet_naming_symbols.public_fields_group.applicable_kinds = field
109+
dotnet_naming_rule.fields_must_be_camel_case_rule.symbols = public_fields_group
110+
dotnet_naming_rule.fields_must_be_camel_case_rule.style = pascal_case_style
111+
dotnet_naming_rule.fields_must_be_camel_case_rule.severity = warning
112+
113+
# Local variables must be camelCase
114+
dotnet_naming_symbols.local_variables_group.applicable_accessibilities = local
115+
dotnet_naming_symbols.local_variables_group.applicable_kinds = local
116+
dotnet_naming_rule.local_variables_must_be_camel_case_rule.symbols = local_variables_group
117+
dotnet_naming_rule.local_variables_must_be_camel_case_rule.style = camel_case_style
118+
dotnet_naming_rule.local_variables_must_be_camel_case_rule.severity = warning
119+
120+
# Function parameters use camelCase
121+
dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
122+
dotnet_naming_rule.parameters_rule.symbols = parameters_group
123+
dotnet_naming_rule.parameters_rule.style = camel_case_style
124+
dotnet_naming_rule.parameters_rule.severity = warning
125+
126+
# Renode specific rules
127+
dotnet_diagnostic.renode_copyright.severity = suggestion
128+
dotnet_diagnostic.renode_class_members_order.severity = warning
129+
130+
# Setup StyleCop analyzers
131+
# List of all analyzers: https://dotnetanalyzers.github.io/StyleCopAnalyzers/
132+
# Opening braces should not be followed by blank line
133+
dotnet_diagnostic.SA1505.severity = warning
134+
# Code should not contain multiple blank lines in a row
135+
dotnet_diagnostic.SA1507.severity = warning
136+
# Closing braces should not be preceded by blank line
137+
dotnet_diagnostic.SA1508.severity = warning
138+
# Opening braces should not be preceded by blank line
139+
dotnet_diagnostic.SA1509.severity = warning
140+
# Seperate class members with blank line
141+
dotnet_diagnostic.SA1516.severity = warning
142+
# File must not start with blank line
143+
dotnet_diagnostic.SA1517.severity = warning
144+
145+
# Exclude files from formatting
146+
[src/Emulator/Extensions/Config/SimpleJson.cs]
147+
generated_code = true
148+
149+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_CMU_3.Generated.cs]
150+
generated_code = true
151+
152+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_DPLL_1.Generated.cs]
153+
generated_code = true
154+
155+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_EMU_3.Generated.cs]
156+
generated_code = true
157+
158+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_HFRCO_2.Generated.cs]
159+
generated_code = true
160+
161+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_HFXO_3.Generated.cs]
162+
generated_code = true
163+
164+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_LFRCO_2.Generated.cs]
165+
generated_code = true
166+
167+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_LFXO_1.Generated.cs]
168+
generated_code = true
169+
170+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_PRS_3.Generated.cs]
171+
generated_code = true
172+
173+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_SYSCFG_3.Generated.cs]
174+
generated_code = true
175+
176+
[src/Emulator/Peripherals/Peripherals/Miscellaneous/SiLabs/EFR32xG2_DCDC_2.Generated.cs]
177+
generated_code = true
178+
179+
[src/Emulator/Peripherals/Peripherals/Timers/EFR32xG2_TIMER_1.Generated.cs]
180+
generated_code = true
181+
182+
[src/Emulator/Peripherals/Peripherals/I3C/Caliptra_I3C_generated.cs]
183+
generated_code = true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetFrameworks>net8.0</TargetFrameworks>
4+
</PropertyGroup>
5+
</Project>

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Renode CI
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
formatting-check:
9+
name: Formatting Check
10+
runs-on: ubuntu-24.04
11+
12+
steps:
13+
- name: Clone repository
14+
uses: actions/checkout@v6
15+
16+
- name: Install Dotnet
17+
uses: actions/setup-dotnet@v5
18+
with:
19+
global-json-file: .github/workflows/global.json
20+
21+
- name: Setup Dotnet artifacts
22+
run: |
23+
ln -s .github/workflows/global.json global.json
24+
ln -s .github/workflows/Directory.Build.targets Directory.Build.targets
25+
ln -s .github/workflows/.editorconfig .editorconfig
26+
mkdir -p ../../output
27+
# Dotnet fails to find properties.csproj if it is a symbolic link
28+
cp src/Emulator/Cores/linux-properties.csproj ../../output/properties.csproj
29+
30+
- name: Register dotnet-format problem matcher
31+
uses: xt0rted/dotnet-format-problem-matcher@v1
32+
33+
- name: Run format check
34+
run: |
35+
dotnet format ./src/Infrastructure_NET.csproj --exclude lib --verify-no-changes --severity warn

.github/workflows/global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.100",
4+
"rollForward": "latestFeature"
5+
}
6+
}

0 commit comments

Comments
 (0)