Skip to content

Commit

Permalink
Add initial sln and build related files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Jan 23, 2023
0 parents commit d6ff179
Show file tree
Hide file tree
Showing 28 changed files with 1,072 additions and 0 deletions.
147 changes: 147 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
root=true

[*.cs]
trim_trailing_whitespace=true
insert_final_newline=true
end_of_line = lf

[*]
charset = utf-8
indent_style = tab
indent_size = 4

[*.cshtml]
indent_style = tab
indent_size = 4
end_of_line = lf

[*.{fs,fsx,yml}]
indent_style = space
indent_size = 4
end_of_line = lf

[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
indent_style = space
indent_size = 2
end_of_line = lf

# Dotnet code style settings:
[*.{cs,vb}]

# ---
# naming conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
# currently not supported in Rider/Resharper so not using these for now
# ---

# ---
# langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions

# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Prefer this.X except for _fields
# TODO can we force _ for private fields?
# TODO elevate severity after code cleanup to warning minimum
# TODO use language latest
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error

# Suggest more modern language features when available
dotnet_style_object_initializer = true:error
dotnet_style_collection_initializer = true:error
dotnet_style_explicit_tuple_names = true:error
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
dotnet_style_prefer_inferred_tuple_names = true:error
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:error

dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
dotnet_style_readonly_field = true:error

# CSharp code style settings:
[*.cs]
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error

csharp_style_expression_bodied_methods = true:error
csharp_style_expression_bodied_constructors = true:error
csharp_style_expression_bodied_operators = true:error
csharp_style_expression_bodied_properties = true:error
csharp_style_expression_bodied_indexers = true:error
csharp_style_expression_bodied_accessors = true:error

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_inlined_variable_declaration = true:error
csharp_style_deconstructed_variable_declaration = true:error
csharp_style_pattern_local_over_anonymous_function = true:error
csharp_style_throw_expression = true:error
csharp_style_conditional_delegate_call = true:error

csharp_prefer_braces = false:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error

# ---
# formatting conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions

# Newline settings (Allman yo!)
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true:error
csharp_new_line_before_catch = true:error
csharp_new_line_before_finally = true:error
csharp_new_line_before_members_in_object_initializers = true
# just a suggestion do to our JSON tests that use anonymous types to
# represent json quite a bit (makes copy paste easier).
csharp_new_line_before_members_in_anonymous_types = true:suggestion
csharp_new_line_between_query_expression_clauses = true:error

# Indent
csharp_indent_case_contents = true:error
csharp_indent_switch_labels = true:error
csharp_space_after_cast = false:error
csharp_space_after_keywords_in_control_flow_statements = true:error
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
csharp_space_between_method_call_parameter_list_parentheses = false:error

#Wrap
csharp_preserve_single_line_statements = false:error
csharp_preserve_single_line_blocks = true:error

csharp_style_namespace_declarations = file_scoped

# Resharper
resharper_csharp_braces_for_lock=required_for_complex
resharper_csharp_braces_for_using=required_for_complex
resharper_csharp_braces_for_while=required_for_complex
resharper_csharp_braces_for_foreach=required_for_complex
resharper_csharp_braces_for_for=required_for_complex
resharper_csharp_braces_for_fixed=required_for_complex
resharper_csharp_braces_for_ifelse=required_for_complex

resharper_csharp_accessor_owner_body=expression_body

resharper_redundant_case_label_highlighting=do_not_show
resharper_redundant_argument_default_value_highlighting=do_not_show
# Do not penalize code that explicitly lists generic arguments
resharper_redundant_type_arguments_of_method_highlighting=do_not_show

[Jenkinsfile]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{sh,bat,ps1}]
trim_trailing_whitespace=true
insert_final_newline=true
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf

# Set default behavior for command prompt diff.
# This gives output on command line taking C# language constructs into consideration (e.g showing class name)
*.cs text diff=csharp

# Set windows specific files explicitly to crlf line ending
*.cmd eol=crlf
*.bat eol=crlf
*.ps1 eol=crlf

# Mark files specifically as binary to avoid line ending conversion
*.snk binary
*.png binary
14 changes: 14 additions & 0 deletions .github/add-license-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
script_path=$(dirname $(realpath -s $0))/../

function add_license () {
(find "$script_path" -name $1 | grep -v "/bin/" | grep -v "/obj/" )|while read fname; do
line=$(sed -n '2p;3q' "$fname")
if ! [[ "$line" == " * Licensed to Elasticsearch B.V. under one or more contributor" ]] ; then
cat "${script_path}.github/license-header.txt" "$fname" > "${fname}.new"
mv "${fname}.new" "$fname"
fi
done
}

add_license "*.cs"
45 changes: 45 additions & 0 deletions .github/check-license-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Check that source code files in this repo have the appropriate license
# header.

if [ "$TRACE" != "" ]; then
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace
fi
set -o errexit
set -o pipefail

TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd)
NLINES=$(wc -l .github/license-header.txt | awk '{print $1}')

function check_license_header {
local f
f=$1
if ! diff .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'"
return 1
else
return 0
fi
}

cd "$TOP"
nErrors=0
for f in $(git ls-files | grep '\.cs$'); do
if ! check_license_header $f; then
nErrors=$((nErrors+1))
fi
done

for f in $(git ls-files | grep '\.fs$'); do
if ! check_license_header $f; then
nErrors=$((nErrors+1))
fi
done

if [[ $nErrors -eq 0 ]]; then
exit 0
else
exit 1
fi
3 changes: 3 additions & 0 deletions .github/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Always be deploying

on:
pull_request:
paths-ignore:
- 'README.md'
- '.editorconfig'
push:
paths-ignore:
- 'README.md'
- '.editorconfig'
branches:
- main
tags:
- "*.*.*"

jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- run: |
git fetch --prune --unshallow --tags
echo exit code $?
git tag --list
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
5.0.x
6.0.x
source-url: https://nuget.pkg.github.com/elastic/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- run: ./build.sh build -s true
name: Build
- run: ./build.sh test -s true
name: Test
- run: ./build.sh generatepackages -s true
name: Generate local nuget packages
- run: ./build.sh validatepackages -s true
name: "validate *.npkg files that were created"
- run: ./build.sh generateapichanges -s true
name: "Inspect public API changes"

- name: publish canary packages github package repository
if: github.event_name == 'push' && startswith(github.ref, 'refs/heads')
shell: bash
run: |
until dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate --no-symbols; do echo "Retrying"; sleep 1; done;
# Github packages requires authentication, this is likely going away in the future so for now we publish to feedz.io
- run: dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.FEEDZ_IO_API_KEY}} -s https://f.feedz.io/elastic/all/nuget/index.json --skip-duplicate --no-symbols
name: publish canary packages to feedz.io
if: github.event_name == 'push' && startswith(github.ref, 'refs/heads')

- run: ./build.sh generatereleasenotes -s true
name: Generate release notes for tag
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')
- run: ./build.sh createreleaseongithub -s true --token ${{secrets.GITHUB_TOKEN}}
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')
name: Create or update release for tag on github

- run: dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
name: release to nuget.org
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')
15 changes: 15 additions & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: License headers

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check license headers
run: |
./.github/check-license-headers.sh
Loading

0 comments on commit d6ff179

Please sign in to comment.