Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cake #2

Merged
merged 18 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ITNOA
# Basic set up for three package managers

version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
33 changes: 33 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ITNOA
# Based on https://github.com/flcdrg/VsShowMissing

name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes

$CHANGES
154 changes: 154 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# ITNOA
# Based on https://github.com/flcdrg/VsShowMissing

name: CI


# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
DOTNET_VERSION: '6.0.412' # The .NET SDK version to use
PRODUCT_VERSION: '0.1.0'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
name: build-and-test-${{matrix.os}}
strategy:
matrix:
include:
- solution: BSN.IpTables.Api.sln
os: [ubuntu-latest]

# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

outputs:
GitAssemblyInformationalVersion: ${{ steps.gitversion.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ steps.gitversion.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ steps.gitversion.outputs.GitBuildVersionSimple }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget

- name: Install dependencies
run: dotnet restore

- name: Build with Cake
uses: cake-build/cake-action@v1
with:
target: JustBuild
script-path: Build/linux-build.cake
verbosity: Diagnostic
arguments: |
projectVersion: ${{ env.PRODUCT_VERSION }}

- name: Build
id: build
run: dotnet build --configuration Release --no-restore

- name: Git Version
id: gitversion
uses: codacy/git-version@2.7.1

# set pr number, if it's a pr build
- name: set pr build number
id: PRNUMBER
if: ${{ github.event_name == 'pull_request' }}
uses: kkak10/pr-number-action@v1.3

# set report file and title
- name: Set Test Title
run: |
if ${{ github.event_name == 'pull_request' }}
then
echo "title=Test Run for PR #${{steps.PRNUMBER.outputs.pr}} (${{github.run_number}})" >> $GITHUB_ENV
echo "file_name=TestReport.${{steps.PRNUMBER.outputs.pr}}.${{github.run_number}}.md" >> $GITHUB_ENV
else
echo "title=Test Run ${{github.run_number}}" >> $GITHUB_ENV
echo "file_name=TestReport.${{github.run_number}}.md" >> $GITHUB_ENV
fi

# run tests with built project
- name: Test with Cake
uses: cake-build/cake-action@v1
with:
target: JustTest
script-path: Build/linux-build.cake
verbosity: Diagnostic
arguments: |
projectVersion: ${{ env.PRODUCT_VERSION }}

- name: Test
run: |
dotnet test --no-restore --verbosity normal --logger trx --results-directory Build/artifacts
dotnet test --no-restore --no-build --configuration Release --logger:"liquid.md;LogFileName=${{github.workspace}}/${{env.file_name}};Title=${{env.title}};"

- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
# Artifact name
name: Test Results
# A file, directory or wildcard pattern that describes what to upload
path: 'Build/artifacts/*.xml'
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

# add report as PR comment (if PR)
- name: comment PR
uses: machine-learning-apps/pr-comment@master
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: ${{env.file_name}}
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"

update_release_draft:
name: Update release draft
runs-on: ubuntu-latest
needs: [build-and-test]
env:
GitAssemblyInformationalVersion: ${{ needs.build-and-test.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ needs.build-and-test.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ needs.build-and-test.outputs.GitBuildVersionSimple }}

if: github.ref == 'refs/heads/main' # Running this job only for master branch
steps:
- uses: actions/checkout@v3

- uses: release-drafter/release-drafter@v5
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ needs.build-and-test.outputs.GitBuildVersionSimple }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ __pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
Build/tools/**
tools/**
!tools/packages.config

# Tabs Studio
*.tss
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "BSN.IpTables.Api.sln"
}
35 changes: 35 additions & 0 deletions BSN.IpTables.Api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,63 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.6.33829.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{AB5DD529-3C2F-42E5-A5FE-0863D4BBD4CF}"
ProjectSection(SolutionItems) = preProject
Build\build.cake = Build\build.cake
Build\build.ps1 = Build\build.ps1
Build\cake.config = Build\cake.config
Build\linux-build.cake = Build\linux-build.cake
Build\README.md = Build\README.md
Build\windows-build.cake = Build\windows-build.cake
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{70AE69C7-7213-4193-A514-5D06526EC544}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Document", "Document", "{AC6D41C1-B22B-476B-9D22-25F45F08E122}"
ProjectSection(SolutionItems) = preProject
Document\README.md = Document\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{12DEA530-7ABA-4B24-B629-E231AA36C365}"
ProjectSection(SolutionItems) = preProject
Test\README.md = Test\README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSN.IpTables.Api", "Source\BSN.IpTables.Api\BSN.IpTables.Api.csproj", "{D40AAB28-6B86-4E6E-B51A-9F1404B5AB09}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99D685D1-4CB1-4BBC-89D6-2C3B28D2D552}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.gitignore = .gitignore
build.sh = build.sh
Directory.Build.props = Directory.Build.props
Dockerfile.test = Dockerfile.test
LICENSE = LICENSE
nuget.config = nuget.config
README.md = README.md
sbuild.bat = sbuild.bat
testEnvironments.json = testEnvironments.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{4264F4C7-0BF7-484F-9AB6-8E9312A50FEB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSN.IpTables.Api.Tests", "Test\UnitTests\BSN.IpTables.Api.Tests\BSN.IpTables.Api.Tests.csproj", "{BCD38560-9570-40CF-8B7B-D22C20DD6EDE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{F49C2402-DF58-402E-847D-E67F6AC66F64}"
ProjectSection(SolutionItems) = preProject
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{387CFE47-D0AC-4191-9FAA-EB9203519A05}"
ProjectSection(SolutionItems) = preProject
.github\dependabot.yml = .github\dependabot.yml
.github\release-drafter.yml = .github\release-drafter.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{DA92F560-B467-4744-9002-7475466C9DCD}"
ProjectSection(SolutionItems) = preProject
.github\workflows\main.yml = .github\workflows\main.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -49,6 +83,7 @@ Global
{D40AAB28-6B86-4E6E-B51A-9F1404B5AB09} = {70AE69C7-7213-4193-A514-5D06526EC544}
{4264F4C7-0BF7-484F-9AB6-8E9312A50FEB} = {12DEA530-7ABA-4B24-B629-E231AA36C365}
{BCD38560-9570-40CF-8B7B-D22C20DD6EDE} = {4264F4C7-0BF7-484F-9AB6-8E9312A50FEB}
{DA92F560-B467-4744-9002-7475466C9DCD} = {387CFE47-D0AC-4191-9FAA-EB9203519A05}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52753D02-BF5A-4DDE-BB5E-4FA5E12E0C8F}
Expand Down
Loading
Loading