liveBook · Manning

YAML

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

YAML is a human-readable data-serialization language that represents structured data using indentation-based syntax.

YAML is a human-readable data-serialization language for structured configuration. It uses indentation to express nesting, making workflow definitions readable while requiring consistent spacing. section 14.2

In CI/CD automation, YAML defines when a workflow runs, which jobs execute, the operating system they use, and the steps that invoke shell commands. GitHub workflows and Azure DevOps Pipelines use it. section 14.2 section 14.2.1

A practical GitHub workflow organizes YAML around these elements:

  • The name identifies the workflow. section 14.2.1
  • The on key defines automatic triggers, such as opened or reopened pull requests. section 14.2.1
  • Jobs define execution environments and can run concurrently or sequentially. section 14.2.1
  • Steps check out repository code and run PowerShell commands, including Pester tests. section 14.2.1

Automated pull-request testing

Save a file such as Get-SystemInfo.yaml under .github/workflows/. Configure it to run on pull requests, use windows-latest, check out the repository, and invoke the Pester test file with pwsh. section 14.2.1

Listing 14.4 Get-SystemInfo.yaml
name: PoshAutomator Pester Tests
on:
  pull_request:                                 #1
    types: [opened, reopened]
 
jobs:
  pester-test:
    name: Pester test
    runs-on: windows-latest                     #2
    steps:
      - name: Check out repository code         #3
        uses: actions/checkout@v3
      - name: Run the Get-SystemInfo.Unit.Test.ps1 Test File
        shell: pwsh
        run: |                                  #4
          Invoke-Pester .\Test\Get-SystemInfo.Test.ps1 -Passthru

Inspect the complete workflow listing to see indentation connect the trigger, job, runner, checkout action, shell, and test command. section 14.2.1

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Defines indentation-based nesting and workflow structure, stopping short of broader YAML semantics or specification detail.
Examples
Uses Get-SystemInfo.yaml to trigger Pester tests on pull requests with a Windows runner and repository checkout.
What you can do after
Apply it via GitHub workflows to automate PowerShell and Pester tests for pull requests.
How it connects
Connects YAML with GitHub Actions workflows, Azure DevOps Pipelines, PowerShell, Pester, JSON, XML, and CI/CD.

Also explained in

Compare how 16 books explain YAML →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.