Skip to content

Commit

Permalink
Copy from jaykul/DevOps2023-Building
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed May 1, 2023
1 parent 7742cc2 commit f3fab42
Show file tree
Hide file tree
Showing 135 changed files with 43,288 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Joel-Bennett-Invoke-Build/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Test
on: push

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

# - uses: actions/cache@v3
# with:
# path: ~/.nuget/packages
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# restore-keys: |
# ${{ runner.os }}-nuget

- name: dotnet restore
shell: pwsh
run: Invoke-Build -Task DotNetRestore

- name: dotnet build
shell: pwsh
run: Invoke-Build -Task DotNetBuild

- name: dotnet test
shell: pwsh
run: Invoke-Build -Task DotNetTest

- name: dotnet publish
shell: pwsh
run: Invoke-Build -Task DotNetPublish

- name: Upload Build Output
uses: actions/upload-artifact@v3
with:
name: Output
path: ${{github.workspace}}/output/publish

- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: PesterTests
path: ${{github.workspace}}/output/tests
3 changes: 3 additions & 0 deletions Joel-Bennett-Invoke-Build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
obj/
output/
13 changes: 13 additions & 0 deletions Joel-Bennett-Invoke-Build/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

default: true
MD003:
style: "atx"
MD022:
lines_above: 1
lines_below: 1
MD025: false
MD013: false
MD033: false
MD007:
indent: 4
no-hard-tabs: false
69 changes: 69 additions & 0 deletions Joel-Bennett-Invoke-Build/Build.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<#
.SYNOPSIS
./project.build.ps1
.EXAMPLE
Invoke-Build
.NOTES
0.5.0 - Parameterize
Add parameters to this script to control the build
#>
[CmdletBinding()]
param(
# dotnet build configuration parameter (Debug or Release)
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',

# Add the clean task before the default build
[switch]$Clean,

# Collect code coverage when tests are run
[switch]$CollectCoverage,

# Which projects to build
[Alias("Projects")]
$dotnetProjects = @(
"ContainerApp.TodoApi"
"ContainerApp.WeatherApi"
"ContainerApp.WebApp"
"ContainerApp.Test"
),

# Which projects are test projects
[Alias("TestProjects")]
$dotnetTestProjects = @(
"ContainerApp.Test"
),

# Further options to pass to dotnet
[Alias("Options")]
$dotnetOptions = @{
"-verbosity" = "minimal"
# "-runtime" = "linux-x64"
}
)
$InformationPreference = "Continue"

$Tasks = "Tasks", "../Tasks", "../../Tasks" | Convert-Path -ErrorAction Ignore | Select-Object -First 1

## Self-contained build script - can be invoked directly or via Invoke-Build
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
& "$Tasks/_Bootstrap.ps1"

Invoke-Build -File $MyInvocation.MyCommand.Path @PSBoundParameters -Result Result

if ($Result.Error) {
$Error[-1].ScriptStackTrace | Out-String
exit 1
}
exit 0
}

## The first task defined is the default task
if ($Clean) {
Add-BuildTask . Clean, DotNetRestore, DotNetBuild, DotNetTest, DotNetPublish
} else {
Add-BuildTask . DotNetRestore, DotNetBuild, DotNetTest, DotNetPublish
}

## Initialize the build variables, and import shared tasks, including DotNet tasks
. "$Tasks/_Initialize.ps1" -DotNet
7 changes: 7 additions & 0 deletions Joel-Bennett-Invoke-Build/Building/00. abstract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Invoke-Build: PowerShell in CI/CD

This is a talk about building, testing, and deploying with PowerShell scripts, and ways to design your workflow such that you can run the same build locally that you run on your CI/CD environment. Everyone will go home with their hands full of tips and tricks for using PowerShell in CI/CD pipelines, GitHub Actions, workflows, and more.

Our primary goal is to do most of the coordination of build/test/deploy in PowerShell, regardless of whether you're building PowerShell modules, or any other sort of software, whether it's ASP.NET or Node web apps, Windows Forms, or Java console apps.

Essentially, we will exploring the functionality of PowerShell as a cross-platform scripting engine while looking at cross-platform modules for builds like Invoke-Build and PSake. We'll cover the benefits (and pitfalls) of doing _everything_ in PowerShell. We'll talk about what steps you can easily make work everywhere, and which will only work on your CI/CD environment or your local laptop. We'll discuss the missing "workflow" functionality of being able to suspend and resume, without re-running, and we'll discuss logging and errors and how you can make them verbose when you won't be able to interactively debug.
10 changes: 10 additions & 0 deletions Joel-Bennett-Invoke-Build/Building/99. Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
If you take a look at what went in to a single feature release of BuildKit, you might have a better understanding of the featureset of this tool that you think is just for compiling Dockerfiles...

https://github.com/moby/buildkit/releases/tag/v0.11.0

### Now take a look at some spin-off tools:

- [Depot](https://depot.dev/) is all about building Docker images faster. Aggressive cloud caching of layers. Build agents with native 16-CPU servers for every platform, including AWS Graviton and Apple Silicon. Billed per minute.
- [Sanic](https://github.com/webappio/sanic) is an Open Source parallel builder. It builds all the Dockerfiles in your repo simultaneously, with support for templating and more.
- [Earthly](https://github.com/earthly/earthly#faq) is a CI/CD Framework, based on BuildKit, it's like Dockerfile + Makefile
- [Tekton](https://tekton.dev/docs/pipelines/pipelines/#specifying-workspaces) is a CI/CD Server that's all Kubernetes native. It's very powerful for organizations that are fully Kubernetes native, with k8s-yaml aware dev teams.
Loading

0 comments on commit f3fab42

Please sign in to comment.