-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'EarthlyBuild' into main
- Loading branch information
Showing
18 changed files
with
452 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# ignore output (because we put stuff there) | ||
/output/* | ||
assemblies/ | ||
# ignore binary output files and folders | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
FORCE_COLOR: 1 | ||
steps: | ||
- uses: earthly/actions-setup@v1 | ||
with: | ||
# version: v0.7.21 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: earthly +all | ||
run: earthly --strict +all | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Pansies | ||
path: Modules/Pansies | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: TestResults | ||
path: Modules/Pansies-TestResults | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Packages | ||
path: Modules/Pansies-Packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach" | ||
}, | ||
{ | ||
"type": "PowerShell", | ||
"request": "launch", | ||
"name": "PowerShell Launch (current file)", | ||
"script": "${file}", | ||
}, | ||
{ | ||
"type": "PowerShell", | ||
"request": "launch", | ||
"name": "PowerShell Launch (current test file)", | ||
"script": "Invoke-Pester", | ||
"args": [ | ||
"-Path", "${file}", | ||
"-PesterOption", "@{ IncludeVSCodeMarker = $True }" | ||
], | ||
"createTemporaryIntegratedConsole": true | ||
}, | ||
{ | ||
"type": "PowerShell", | ||
"request": "attach", | ||
"name": "PowerShell Attach to Host Process", | ||
"processId": "${command:PickPSHostProcess}", | ||
"runspaceId": 1 | ||
}, | ||
{ | ||
"type": "PowerShell", | ||
"request": "launch", | ||
"name": "PowerShell Interactive Session", | ||
"cwd": "${workspaceRoot}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"files.encoding": "utf8", | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
"editor.tabSize": 4, | ||
"editor.insertSpaces": true, | ||
"powershell.codeFormatting.preset": "OTBS", | ||
"powershell.codeFormatting.ignoreOneLineBlock": false, | ||
"powershell.codeFormatting.useCorrectCasing": true, | ||
"powershell.codeFormatting.alignPropertyValuePairs": true, | ||
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline", | ||
"powershell.scriptAnalysis.settingsPath": "ScriptAnalyzerSettings.psd1", | ||
"files.associations": { | ||
"*.ps1xml": "xml", | ||
".earthlyignore": "ignore" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"type": "shell", | ||
"command": "Invoke-Build", | ||
"presentation": { | ||
"echo": true, | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "shared", | ||
"showReuseMessage": true, | ||
"clear": false | ||
} | ||
}, | ||
{ | ||
"label": "test", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
}, | ||
"type": "shell", | ||
"options": { | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"PSModulePath": "${workspaceFolder}\\Output;${env:PSModulePath}" | ||
} | ||
}, | ||
"command": "Invoke-Build", | ||
"args": [ | ||
"Test" | ||
], | ||
"presentation": { | ||
"echo": true, | ||
"reveal": "always", | ||
"focus": true, | ||
"panel": "shared", | ||
"showReuseMessage": true, | ||
"clear": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<# | ||
.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 = @( | ||
"Pansies" | ||
), | ||
|
||
# Which projects are test projects | ||
[Alias("TestProjects")] | ||
$dotnetTestProjects = @(), | ||
|
||
# Further options to pass to dotnet | ||
[Alias("Options")] | ||
$dotnetOptions = @{ | ||
"-verbosity" = "minimal" | ||
# "-runtime" = "linux-x64" | ||
} | ||
) | ||
$InformationPreference = "Continue" | ||
$ErrorView = 'DetailedView' | ||
|
||
# The name of the module to publish | ||
$script:PSModuleName = "TerminalBlocks" | ||
# Use Env because Earthly can override it | ||
$Env:OUTPUT_ROOT ??= Join-Path $BuildRoot Modules | ||
|
||
$Tasks = "Tasks", "../Tasks", "../../Tasks" | Convert-Path -ErrorAction Ignore | Select-Object -First 1 | ||
Write-Information "$($PSStyle.Foreground.BrightCyan)Found shared tasks in $Tasks" -Tag "InvokeBuild" | ||
## 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. Put the right values for your project type here... | ||
if ($dotnetProjects -and $Clean) { | ||
Add-BuildTask CleanBuild Clean, ($Task ?? "Test") | ||
} elseif ($Clean) { | ||
Add-BuildTask CleanBuild Clean, ($Task ?? "Test") | ||
} | ||
|
||
## Initialize the build variables, and import shared tasks, including DotNet tasks | ||
. "$Tasks/_Initialize.ps1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
VERSION 0.7 | ||
IMPORT github.com/poshcode/tasks | ||
FROM mcr.microsoft.com/dotnet/sdk:7.0 | ||
WORKDIR /work | ||
|
||
ARG --global EARTHLY_BUILD_SHA | ||
ARG --global EARTHLY_GIT_BRANCH | ||
# These are my common paths, used in my shared /Tasks repo | ||
ARG --global OUTPUT_ROOT=/Modules | ||
ARG --global TEST_ROOT=/tests | ||
ARG --global TEMP_ROOT=/temp | ||
# These are my common build args, used in my shared /Tasks repo | ||
ARG --global MODULE_NAME=Pansies | ||
ARG --global CONFIGURATION=Release | ||
ARG --global PSMODULE_PUBLISH_KEY | ||
ARG --global NUGET_API_KEY | ||
|
||
worker: | ||
# Dotnet tools and scripts installed by PSGet | ||
ENV PATH=$HOME/.dotnet/tools:$HOME/.local/share/powershell/Scripts:$PATH | ||
RUN mkdir /Tasks \ | ||
&& git config --global user.email "[email protected]" \ | ||
&& git config --global user.name "Earthly Build" | ||
# I'm using Invoke-Build tasks from this other repo which rarely changes | ||
COPY tasks+tasks/* /Tasks | ||
# Dealing with dependencies first allows docker to cache packages for us | ||
# So the dependency cach only re-builds when you add a new dependency | ||
COPY RequiredModules.psd1 . | ||
COPY *.csproj . | ||
RUN ["pwsh", "--file", "/Tasks/_Bootstrap.ps1", "-RequiredModulesPath", "RequiredModules.psd1"] | ||
|
||
build: | ||
FROM +worker | ||
RUN mkdir $OUTPUT_ROOT $TEST_ROOT $TEMP_ROOT | ||
COPY . . | ||
# make sure you have bin and obj in .earthlyignore, as their content from context might cause problems | ||
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Build", "-File", "Build.build.ps1"] | ||
|
||
# SAVE ARTIFACT [--keep-ts] [--keep-own] [--if-exists] [--force] <src> [<artifact-dest-path>] [AS LOCAL <local-path>] | ||
SAVE ARTIFACT $OUTPUT_ROOT/$MODULE_NAME AS LOCAL ./Modules/$MODULE_NAME | ||
|
||
test: | ||
# If we run a target as a reference in FROM or COPY, it's outputs will not be produced | ||
FROM +build | ||
# make sure you have bin and obj in .earthlyignore, as their content from context might cause problems | ||
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Test", "-File", "Build.build.ps1"] | ||
|
||
# SAVE ARTIFACT [--keep-ts] [--keep-own] [--if-exists] [--force] <src> [<artifact-dest-path>] [AS LOCAL <local-path>] | ||
SAVE ARTIFACT $TEST_ROOT AS LOCAL ./Modules/$MODULE_NAME-TestResults | ||
|
||
pack: | ||
BUILD +build # So that we get the build artifact too | ||
FROM +build | ||
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Pack", "-File", "Build.build.ps1", "-Verbose"] | ||
SAVE ARTIFACT $OUTPUT_ROOT/publish/*.nupkg AS LOCAL ./Modules/$MODULE_NAME-Packages/ | ||
|
||
publish: | ||
FROM +build | ||
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Publish", "-File", "Build.build.ps1", "-Verbose"] | ||
|
||
all: | ||
# BUILD +build | ||
BUILD +test | ||
BUILD +pack |
Oops, something went wrong.