OCram85/DroneHelper
OCram85
/
DroneHelper
Archived
1
0
Fork 0
This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
DroneHelper/README.md

195 lines
4.7 KiB
Markdown

# DroneHelper
[![Build Status](https://drone.ocram85.com/api/badges/OCram85/DroneHelper/status.svg)](https://drone.ocram85.com/OCram85/DroneHelper)
## Description
Helper module for Drone.io based build pipelines.
## About
The DroneHelper PowerShell Modules adds several feature to a `Gitea -> Drone.IO` based build pipeline. It's designed
to perform all needed tasks for PowerShell Module development like:
- `FileLinter` -> Runs basic FileLinter tests with console and log file output
- `Linter` -> Runs PSScriptAnalyer with embedded to custom profiles.
- `UnitTest` -> Executes Pester tests with code coverage with console and log file output.
- `BuildReport` -> Takes all generated reports and reports them back as Pull Request Comment for a simplified overview.
- `StateReporter` -> Marks the current pipeline run / build as failed if the previous steps also raised errors.
- `DoksUpdater` -> Automatically updates the markdown based docs generated form your Comment Based Help blocks in your functions
To use these feature, all you have to do, is follow the `.drone.yml` template:
### `.drone.yml` Template
```yaml
---
kind: pipeline
type: docker
name: "Build Pipeline"
trigger:
branch:
exclude:
- droneDocs/*
steps:
- name: "Pwsh FileLinter"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
failure: ignore
environment:
EXCLUDE: "(.exe|.dll|.ico|.gitkeep)"
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module 'DroneHelper';
Invoke-FileLinter
}"
- name: "ScriptAnalyzer"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
failure: ignore
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Invoke-Linter
}"
- name: "Pester"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
failure: ignore
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Invoke-UnitTest -Verbosity 'Detailed' -ExcludeTag 'Integration'
}"
- name: "PRComment"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
failure: ignore
environment:
GITEA_TOKEN:
from_secret: GITEA_TOKEN
CUSTOM_PIPELINE_STATE: true
LOG_FILES: "build/*.log"
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module 'DroneHelper';
Send-PRComment
}"
when:
event:
include:
- pull_request
- name: "buildState"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Invoke-BuildState
}"
---
kind: pipeline
type: docker
name: "Publish Pipeline"
depends_on:
- "Build Pipeline"
trigger:
event:
- tag
steps:
- name: BuildArtifacts
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
#failure: ignore
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Update-ModuleMeta -Verbose
}"
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
New-BuildPackage -Verbose
}"
- name: GiteaRelease
image: plugins/gitea-release
settings:
api_key:
from_secret: GITEA_TOKEN
base_url: https://gitea.ocram85.com
files:
- "bin/${DRONE_REPO_NAME}.zip"
- "bin/PSModule.zip"
title: "${DRONE_TAG}"
note: CHANGELOG.md
- name: "PublishModule"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
#failure: ignore
environment:
NexusToken:
from_secret: NexusToken
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Invoke-Publish -Verbose
}"
---
kind: pipeline
type: docker
name: "Update Docs"
depends_on:
- "Build Pipeline"
trigger:
event:
exclude:
- pull_request
branch:
include:
- master
steps:
- name: "Update Docs"
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
commands:
- |
pwsh -NonInteractive -c "& {
Import-Module -Name 'DroneHelper';
Install-ModuleDependency;
Update-Docs -Verbose
}"
- name: "push commit"
image: appleboy/drone-git-push
settings:
remote_name: origin
branch: "droneDocs/${DRONE_COMMIT:0:8}"
local_ref: droneDocs
commit: true
commit_message: "docs updated by drone [CI SKIP]"
author_name: drone
author_email: noreply@ocram85.com
force: true
```