Skip to content

Commit 92ad034

Browse files
committed
Setting up github actions file
Including code format fixes. And removing travis configuration.
1 parent 94f24c5 commit 92ad034

File tree

67 files changed

+591
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+591
-362
lines changed

.editorconfig

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# SPDX-FileCopyrightText: 2024 Lukas Prediger <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
root = true
5+
6+
[*.cs]
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
#### .NET Coding Conventions ####
13+
14+
# Organize usings
15+
dotnet_separate_import_directive_groups = false
16+
dotnet_sort_system_directives_first = true
17+
file_header_template = unset
18+
19+
# this. and Me. preferences
20+
dotnet_style_qualification_for_event = false
21+
dotnet_style_qualification_for_field = false
22+
dotnet_style_qualification_for_method = false
23+
dotnet_style_qualification_for_property = false
24+
dotnet_diagnostic.IDE0003.severity = none
25+
26+
# Language keywords vs BCL types preferences
27+
dotnet_style_predefined_type_for_locals_parameters_members = true
28+
dotnet_style_predefined_type_for_member_access = true
29+
30+
# Parentheses preferences
31+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
32+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
33+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
34+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
35+
dotnet_diagnostic.IDE0047.severity = suggestion
36+
37+
# Modifier preferences
38+
dotnet_style_require_accessibility_modifiers = for_non_interface_members
39+
40+
# Expression-level preferences
41+
dotnet_style_coalesce_expression = true
42+
dotnet_style_collection_initializer = true
43+
dotnet_style_explicit_tuple_names = true
44+
dotnet_style_namespace_match_folder = false
45+
dotnet_style_null_propagation = true
46+
dotnet_style_object_initializer = true
47+
# dotnet_style_operator_placement_when_wrapping = beginning_of_line
48+
dotnet_style_prefer_auto_properties = true
49+
dotnet_style_prefer_collection_expression = when_types_exactly_match
50+
dotnet_style_prefer_compound_assignment = true
51+
dotnet_diagnostic.IDE0054.severity = none
52+
dotnet_diagnostic.IDE0074.severity = none
53+
dotnet_style_prefer_conditional_expression_over_assignment = true
54+
dotnet_style_prefer_conditional_expression_over_return = true
55+
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
56+
dotnet_style_prefer_inferred_anonymous_type_member_names = false
57+
dotnet_style_prefer_inferred_tuple_names = true
58+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
59+
dotnet_style_prefer_simplified_boolean_expressions = true
60+
dotnet_style_prefer_simplified_interpolation = true
61+
62+
# Field preferences
63+
dotnet_style_readonly_field = true
64+
65+
#### C# Coding Conventions ####
66+
67+
# var preferences
68+
csharp_style_var_elsewhere = false
69+
csharp_style_var_for_built_in_types = false
70+
csharp_style_var_when_type_is_apparent = false
71+
72+
# Expression-bodied members
73+
csharp_style_expression_bodied_accessors = true
74+
csharp_style_expression_bodied_constructors = false
75+
csharp_style_expression_bodied_indexers = true
76+
csharp_style_expression_bodied_lambdas = true
77+
csharp_style_expression_bodied_local_functions = false
78+
csharp_style_expression_bodied_methods = false
79+
csharp_style_expression_bodied_operators = false
80+
csharp_style_expression_bodied_properties = true
81+
82+
# Pattern matching preferences
83+
csharp_style_pattern_matching_over_as_with_null_check = true
84+
csharp_style_pattern_matching_over_is_with_cast_check = true
85+
csharp_style_prefer_extended_property_pattern = true
86+
csharp_style_prefer_not_pattern = true
87+
csharp_style_prefer_pattern_matching = true
88+
csharp_style_prefer_switch_expression = false
89+
90+
# Null-checking preferences
91+
csharp_style_conditional_delegate_call = true
92+
93+
# Modifier preferences
94+
csharp_prefer_static_local_function = true
95+
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
96+
csharp_style_prefer_readonly_struct = true
97+
csharp_style_prefer_readonly_struct_member = true
98+
99+
# Code-block preferences
100+
csharp_prefer_braces = when_multiline
101+
csharp_prefer_simple_using_statement = true
102+
csharp_style_namespace_declarations = block_scoped
103+
csharp_style_prefer_method_group_conversion = true
104+
csharp_style_prefer_primary_constructors = false
105+
csharp_style_prefer_top_level_statements = false
106+
107+
# Expression-level preferences
108+
csharp_prefer_simple_default_expression = true
109+
csharp_style_deconstructed_variable_declaration = true
110+
csharp_style_implicit_object_creation_when_type_is_apparent = false
111+
csharp_style_inlined_variable_declaration = true
112+
csharp_style_prefer_index_operator = true
113+
csharp_style_prefer_local_over_anonymous_function = true
114+
csharp_style_prefer_null_check_over_type_check = true
115+
csharp_style_prefer_range_operator = true
116+
csharp_style_prefer_tuple_swap = true
117+
# csharp_style_prefer_utf8_string_literals = false
118+
csharp_style_throw_expression = true
119+
# csharp_style_unused_value_assignment_preference = discard_variable
120+
# csharp_style_unused_value_expression_statement_preference = discard_variable
121+
122+
# 'using' directive preferences
123+
csharp_using_directive_placement = outside_namespace
124+
125+
# # New line preferences
126+
# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
127+
# csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
128+
# csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
129+
# csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
130+
# csharp_style_allow_embedded_statements_on_same_line_experimental = true
131+
132+
#### C# Formatting Rules ####
133+
134+
# New line preferences
135+
csharp_new_line_before_catch = true
136+
csharp_new_line_before_else = true
137+
csharp_new_line_before_finally = true
138+
csharp_new_line_before_members_in_anonymous_types = true
139+
csharp_new_line_before_members_in_object_initializers = true
140+
csharp_new_line_before_open_brace = all
141+
csharp_new_line_between_query_expression_clauses = true
142+
143+
# Indentation preferences
144+
csharp_indent_block_contents = true
145+
csharp_indent_braces = false
146+
csharp_indent_case_contents = true
147+
csharp_indent_case_contents_when_block = true
148+
csharp_indent_labels = one_less_than_current
149+
csharp_indent_switch_labels = true
150+
151+
# Space preferences
152+
csharp_space_after_cast = false
153+
csharp_space_after_colon_in_inheritance_clause = true
154+
csharp_space_after_comma = true
155+
csharp_space_after_dot = false
156+
csharp_space_after_keywords_in_control_flow_statements = true
157+
csharp_space_after_semicolon_in_for_statement = true
158+
csharp_space_around_binary_operators = before_and_after
159+
csharp_space_around_declaration_statements = ignore
160+
csharp_space_before_colon_in_inheritance_clause = true
161+
csharp_space_before_comma = false
162+
csharp_space_before_dot = false
163+
csharp_space_before_open_square_brackets = false
164+
csharp_space_before_semicolon_in_for_statement = false
165+
csharp_space_between_empty_square_brackets = false
166+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
167+
csharp_space_between_method_call_name_and_opening_parenthesis = false
168+
csharp_space_between_method_call_parameter_list_parentheses = false
169+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
170+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
171+
csharp_space_between_method_declaration_parameter_list_parentheses = false
172+
csharp_space_between_parentheses = false
173+
csharp_space_between_square_brackets = false
174+
175+
# Wrapping preferences
176+
csharp_preserve_single_line_blocks = true
177+
csharp_preserve_single_line_statements = true
178+
179+
# dotnet_analyzer_diagnostic.category-Style.severity = warning

.github/workflows/main.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: 2024 Lukas Prediger <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
name: Tests
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
branches:
11+
- master
12+
13+
jobs:
14+
style_check:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: '8.x'
23+
- name: Check style
24+
run: dotnet format --verify-no-changes
25+
- name: Install reuse linter
26+
run: sudo apt-get install -y reuse
27+
- name: Check reuse compliance
28+
run: reuse lint
29+
30+
build_and_test:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Setup .NET Core
36+
uses: actions/setup-dotnet@v4
37+
with:
38+
dotnet-version: '8.x'
39+
- name: Test and generate coverage report
40+
run: |
41+
dotnet test CompactCryptoGroupAlgebra.Tests/ --collect:"XPlat Code Coverage" --settings CompactCryptoGroupAlgebra.Tests/coverlet.runsettings
42+
dotnet test CompactCryptoGroupAlgebra.LibCrypto.Tests/ --collect:"XPlat Code Coverage" --settings CompactCryptoGroupAlgebra.LibCrypto.Tests/coverlet.runsettings
43+
- name: Copy coveralls report
44+
run: |
45+
mkdir ./CoverageResults
46+
cp -v ./CompactCryptoGroupAlgebra.Tests/TestResults/*/coverage.info ./CoverageResults/base_coverage.info
47+
cp -v ./CompactCryptoGroupAlgebra.LibCrypto.Tests/TestResults/*/coverage.info ./CoverageResults/libcrypto_coverage.info
48+
- name: Publish coverage report to coveralls.io
49+
uses: coverallsapp/github-action@v2
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
files:
53+
./CoverageResults/base_coverage.info
54+
./CoverageResults/libcrypto_coverage.info
55+
format: lcov

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ CoverageReport/
1313
__Instrumented/
1414
*Coverage*/
1515
small_*curve_check.py
16-
.reuse*
16+
.reuse*
17+
*TestResults*

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

CompactCryptoGroupAlgebra.LibCrypto.Tests/BigNumberTests.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
2525
// grant you additional permission to convey the resulting work.
2626

27-
using NUnit.Framework;
28-
2927
using System;
3028
using System.Numerics;
31-
3229
using CompactCryptoGroupAlgebra.LibCrypto.Internal.Native;
30+
using NUnit.Framework;
3331

3432
namespace CompactCryptoGroupAlgebra.LibCrypto
3533
{
@@ -158,7 +156,7 @@ public void TestZero()
158156
public void TestLength()
159157
{
160158
var number = new BigNumber(0x548f07);
161-
var expected = NumberLength.FromBitLength(23);;
159+
var expected = NumberLength.FromBitLength(23); ;
162160

163161
Assert.That(number.Length.Equals(expected));
164162
}
@@ -188,7 +186,7 @@ public void TestToString()
188186
int rawValue = 0x96235;
189187
var expected = (new BigInteger(rawValue)).ToString();
190188
var number = new BigNumber(rawValue);
191-
189+
192190
Assert.That(number.ToString().Equals(expected));
193191
}
194192

CompactCryptoGroupAlgebra.LibCrypto.Tests/CompactCryptoGroupAlgebra.LibCrypto.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ SPDX-FileType: SOURCE
3535
<PackageReference Include="NUnit" Version="3.12.0" />
3636
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
3737
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
38-
<PackageReference Include="Microsoft.CodeCoverage" Version="16.8.3" />
39-
<PackageReference Include="NunitXml.TestLogger" Version="3.0.91" />
38+
<PackageReference Include="coverlet.collector" Version="6.*" />
4039
<PackageReference Include="coverlet.msbuild" Version="3.0.2">
4140
<PrivateAssets>all</PrivateAssets>
4241
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

CompactCryptoGroupAlgebra.LibCrypto.Tests/DiffieHellmanIntegrationTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
// terms of the OpenSSL License and the SSLeay License, the licensors of CompactCryptoGroupAlgebra.LibCrypto
2525
// grant you additional permission to convey the resulting work.
2626

27-
using NUnit.Framework;
28-
27+
using System.Globalization;
2928
using System.Numerics;
3029
using System.Text.RegularExpressions;
31-
using System.Globalization;
32-
3330
using CompactCryptoGroupAlgebra.LibCrypto.EllipticCurves;
3431
using CompactCryptoGroupAlgebra.LibCrypto.Multiplicative;
32+
using NUnit.Framework;
3533

3634
namespace CompactCryptoGroupAlgebra.LibCrypto
3735
{
@@ -54,7 +52,7 @@ FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
5452
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
5553
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
5654
E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF";
57-
55+
5856
BigPrime prime = BigPrime.CreateWithoutChecks(
5957
BigInteger.Parse(Regex.Replace(primeHex, @"\s+", ""), NumberStyles.AllowHexSpecifier)
6058
);
@@ -63,9 +61,9 @@ EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
6361

6462
var algebra = new MultiplicativeGroupAlgebra(prime, order, generator);
6563
var group = new CryptoGroup<SecureBigNumber, BigNumber>(algebra);
66-
64+
6765
CompactCryptoGroupAlgebra.DiffieHellmanIntegrationTests.DoDiffieHellman(group);
6866
}
6967

7068
}
71-
}
69+
}

0 commit comments

Comments
 (0)