Skip to content

Commit

Permalink
Merge pull request #1 from elastic/initial
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
flobernd authored Oct 31, 2024
2 parents a07d59f + b2305f0 commit b293d81
Show file tree
Hide file tree
Showing 44 changed files with 6,080 additions and 0 deletions.
1,572 changes: 1,572 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
### Header #########################################################################################

# Author: Florian Bernd
# Source: https://github.com/zysharp/templates

### Git Line Endings ###############################################################################

# Set default behavior to automatically normalize line endings
* text=auto

# Documents
*.md text diff=markdown
*.mdx text diff=markdown

# Serialization
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text

# Graphics
*.eps binary
*.gif binary
*.ico binary
*.jpg binary
*.jpeg binary
*.png binary
*.tif binary
*.tiff binary

# Force batch scripts to always use CRLF line endings
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# Force bash scripts to always use LF line endings
*.bash text eol=lf
*.fish text eol=lf
*.sh text eol=lf
*.zsh text eol=lf

# Text files where line endings should be preserved
*.patch -text

### .NET ###########################################################################################

*.sln text

### C# #############################################################################################

*.cs text diff=csharp
*.csx text diff=csharp
*.cshtml text diff=html
*.csproj text

### F# #############################################################################################

*.fs text diff=fsharp
*.fsx text diff=fsharp
*.fsproj text

### Exclude files from exporting ###################################################################

.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore

### License ########################################################################################

# The MIT License (MIT)
#
# Copyright (c) 2023 Florian Bernd
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

####################################################################################################
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
main:
name: CI
uses: ./.github/workflows/ci_template.yaml
134 changes: 134 additions & 0 deletions .github/workflows/ci_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: CI

on:
workflow_call:
inputs:
path:
description: The path to look for a Visual Studio Solution file (without a trailing slash).
type: string
required: false
default: ''

env:
BUILD_CONFIG: Debug
DOTNET_GLOBAL_JSON: ${{ inputs.path != '' && format('{0}/global.json', inputs.path) || 'global.json' }}
RESTORE_PATTERN: ${{ inputs.path != '' && format('{0}/**/packages.lock.json', inputs.path) || '**/packages.lock.json' }}
TESTS_PATTERN: ${{ inputs.path != '' && format('{0}/**/*.Test*.csproj', inputs.path) || '**/*.Test*.csproj' }}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Retrieve the preceding commit to enable 'changed-files' to create a diff.
fetch-depth: 2

- name: .NET Setup
uses: zyactions/dotnet-setup@v1
with:
global-json-file: ${{ env.DOTNET_GLOBAL_JSON }}
problem-matcher: false

- name: Install latest .NET Format tool
shell: bash
run: |
dotnet tool install -g dotnet-format --version "8.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@729c70475c2976c3d4ca8897d34d9df975a4d05c
with:
files: ${{ inputs.path != '' && format('{0}/**', inputs.path) || '' }}

- name: .NET Cache Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }}
restore-keys: ${{ runner.os }}-nuget-

- name: .NET Restore
uses: zyactions/dotnet-restore@v1
with:
working-directory: ${{ inputs.path }}

# TODO: Add additional generic '.editorconfig' linting, e.g. for `*.csproj` files
# TODO: Always lint all files, if '.editorconfig' has changed

- name: .NET Lint
uses: zyactions/dotnet-lint@v1
with:
working-directory: ${{ inputs.path }}
# This list is empty for the initial commit. NET Lint will lint all files in this case.
include: ${{ steps.changed-files.outputs.all_changed_files }}
use-standalone-tool: true

test:
name: Run Tests
runs-on: ubuntu-latest
env:
FILTERED_SOLUTION: ${{ inputs.path != '' && format('{0}/Tests.slnf', inputs.path) || 'Tests.slnf' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Find Solution
id: find
uses: flobernd/actions/dotnet/find-solution@master
with:
directory: ${{ inputs.path }}

- name: Filter Solution
uses: flobernd/actions/dotnet/filter-solution@master
with:
solution: ${{ steps.find.outputs.solution }}
# This pattern is relative to the solution file and does not need to be prefixed with
# the 'directory' input value
pattern: '**/*.Test*.csproj'
output: ${{ env.FILTERED_SOLUTION }}

- name: .NET Setup
uses: zyactions/dotnet-setup@v1
with:
global-json-file: ${{ env.DOTNET_GLOBAL_JSON }}
problem-matcher: false

- name: .NET Cache Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }}
restore-keys: ${{ runner.os }}-nuget-

- name: .NET Restore
uses: zyactions/dotnet-restore@v1
with:
workspace: ${{ env.FILTERED_SOLUTION }}

- name: .NET Build
uses: flobernd/actions/dotnet/build@master
with:
workspace: ${{ env.FILTERED_SOLUTION }}
configuration: ${{ env.BUILD_CONFIG }}

# - name: .NET Test
# uses: flobernd/actions/dotnet/test@master
# with:
# projects: ${{ env.TESTS_PATTERN }}
# fail-on-error: false
# log-results: true
# collect-coverage: false
# maxdop: 4

# - name: Generate Test Report
# uses: zyactions/test-reporter@main
# with:
# name: Test Results
# path: ${{ inputs.path != '' && format('{0}/**/TestResults/*.trx', inputs.path) || '**/TestResults/*.trx' }}
# reporter: dotnet-trx
# fail-on-error: true
# only-summary: false
# max-annotations: 30
Loading

0 comments on commit b293d81

Please sign in to comment.