Skip to content

Commit

Permalink
Update to .NET 8 microsoft#150
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite committed Jan 17, 2024
1 parent 6177b4c commit c57ab07
Show file tree
Hide file tree
Showing 28 changed files with 1,165 additions and 915 deletions.
13 changes: 12 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ indent_size = 2
[*.cs]

# Code style defaults
csharp_using_directive_placement = outside_namespace:suggestion
csharp_using_directive_placement = outside_namespace:error
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
dotnet_sort_system_directives_first = true
dotnet_style_readonly_field = true:suggestion
csharp_style_namespace_declarations = file_scoped:error

# License header
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
dotnet_diagnostic.IDE0073.severity = error

# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
Expand All @@ -42,9 +45,17 @@ dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_switch_expression = false:none
csharp_style_prefer_pattern_matching = false:none

# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# Define the 'private_fields' symbol group:
Expand Down
89 changes: 65 additions & 24 deletions .github/workflows/analyze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,52 @@
name: Analyze
on:
push:
branches: [ main, 'release/*' ]
branches: [main, 'release/*']
pull_request:
branches: [ main, 'release/*' ]
branches: [main, 'release/*']
schedule:
- cron: '51 20 * * 0' # At 08:51 PM, on Sunday each week
- cron: '24 22 * * 0' # At 10:24 PM, on Sunday each week
workflow_dispatch:

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

permissions: {}

jobs:
oss:
name: Analyze with PSRule
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout
uses: actions/checkout@v3
- name: Run PSRule analysis
uses: microsoft/[email protected]
with:
modules: PSRule.Rules.MSFT.OSS
prerelease: true
outputFormat: Sarif
outputPath: reports/ps-rule-results.sarif

- name: Run PSRule analysis
uses: microsoft/[email protected]
with:
modules: PSRule.Rules.MSFT.OSS
prerelease: true
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: reports/ps-rule-results.sarif

- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: PSRule-Sarif
path: reports/ps-rule-results.sarif
retention-days: 1
if-no-files-found: error

devskim:
name: Analyze with DevSkim
Expand All @@ -44,20 +67,29 @@ jobs:
contents: read
security-events: write
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
with:
directory-to-scan: src/
directory-to-scan: .

- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: devskim-results.sarif

- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: DevSkim-Sarif
path: devskim-results.sarif
retention-days: 1
if-no-files-found: error

codeql:
name: Analyze with CodeQL
runs-on: ubuntu-latest
Expand All @@ -66,17 +98,26 @@ jobs:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: 'csharp'

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'csharp'
- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
id: codeql-analyze

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: CodeQL-Sarif
path: ${{ steps.codeql-analyze.outputs.sarif-output }}
retention-days: 1
if-no-files-found: error
143 changes: 143 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#
# CI Pipeline
#

# NOTES:
# This workflow builds and tests module updates.

name: Build
on:
push:
branches: [main, 'release/*']
pull_request:
branches: [main, 'release/*']
workflow_dispatch:

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

permissions: {}

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Install dependencies
shell: pwsh
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1

- name: Build module
shell: pwsh
timeout-minutes: 5
run: Invoke-Build -Configuration Release -AssertStyle GitHubActions

- name: Upload module
uses: actions/upload-artifact@v4
with:
name: Module
path: ./out/modules/PSRule/*
retention-days: 3
if-no-files-found: error

# - name: Upload Test Results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: Module.DotNet.TestResults
# path: ./reports/*.trx
# retention-days: 3
# if-no-files-found: error

- name: Upload PSRule Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Results-PSRule
path: ./reports/ps-rule*.xml
retention-days: 3
if-no-files-found: error

test:
name: Test (${{ matrix.rid }}-${{ matrix.shell }})
runs-on: ${{ matrix.os }}
needs: build
permissions:
contents: read

strategy:
# Get full test results from all platforms.
fail-fast: false

matrix:
os: ['ubuntu-latest']
rid: ['linux-x64']
shell: ['pwsh']
include:
- os: windows-latest
rid: win-x64
shell: pwsh
- os: windows-latest
rid: win-x64
shell: powershell
- os: ubuntu-latest
rid: linux-x64
shell: pwsh
- os: ubuntu-latest
rid: linux-musl-x64
shell: pwsh
- os: macos-latest
rid: osx-x64
shell: pwsh

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- if: ${{ matrix.shell == 'pwsh' }}
name: Install dependencies (PowerShell)
shell: pwsh
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1

- if: ${{ matrix.shell == 'powershell' }}
name: Install dependencies (Windows PowerShell)
shell: powershell
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1

- name: Download module
uses: actions/download-artifact@v4
with:
name: Module
path: ./out/modules/PSRule

- if: ${{ matrix.shell == 'pwsh' }}
name: Test module (PowerShell)
shell: pwsh
timeout-minutes: 15
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions

- if: ${{ matrix.shell == 'powershell' }}
name: Test module (Windows PowerShell)
shell: powershell
timeout-minutes: 30
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions
7 changes: 4 additions & 3 deletions .github/workflows/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
name: Dependencies
on:
schedule:
- cron: '45 1 * * 1' # At 01:45 AM, on Monday each week
- cron: '30 1 * * 1' # At 01:30 AM, on Monday each week
workflow_dispatch:

env:
WORKING_BRANCH: dependencies/powershell-bump

permissions: {}

jobs:
dependencies:
name: Bump dependencies
Expand All @@ -23,9 +25,8 @@ jobs:
contents: write
pull-requests: write
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/first-interaction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Stale item management
#

# NOTES:
# This workflow greets a person for their a first issue or PR.

name: First interaction

on: [pull_request_target, issues]

permissions: {}

jobs:
greeting:
name: Greeting
runs-on: ubuntu-latest
if: github.repository == 'microsoft/PSRule.Monitor'
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Thanks for raising your first issue, the team appreciates the time you have taken 😉'
pr-message: 'Thank you for your contribution, one of the team will evaluate shortly.'
Loading

0 comments on commit c57ab07

Please sign in to comment.