Skip to content
Draft
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci-summary:
name: CI Summary
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: CI Status
run: |
echo "βœ… Running CI checks for azuredevops-lib"
echo "πŸ“¦ Repository: ${{ github.repository }}"
echo "πŸ”€ Branch: ${{ github.ref_name }}"
echo "πŸ‘€ Actor: ${{ github.actor }}"

if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "πŸ” PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
fi
41 changes: 41 additions & 0 deletions .github/workflows/documentation-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation Check

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- '**.md'
- '.github/workflows/documentation-check.yml'

jobs:
markdown-lint:
name: Lint Markdown Files
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run markdown linter
uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: '**/*.md'
config: '.markdownlint.json'

link-checker:
name: Check Links
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check links in markdown files
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
config-file: '.markdown-link-check.json'
40 changes: 40 additions & 0 deletions .github/workflows/validate-templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Validate Templates

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- '**.yaml'
- '**.yml'
- '.github/workflows/validate-templates.yml'

jobs:
validate-yaml-syntax:
name: Validate YAML Syntax
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install PyYAML
run: |
pip install pyyaml

- name: Validate YAML files
run: |
echo "Validating YAML syntax for all templates..."
find . -type f \( -name "*.yaml" -o -name "*.yml" \) ! -path "./.git/*" | while read file; do
echo "Checking: $file"
python -c "import yaml, sys; yaml.safe_load(open('$file'))" || exit 1
done
echo "βœ… All YAML files are valid!"
35 changes: 35 additions & 0 deletions .github/workflows/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: YAML Lint

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- '**.yaml'
- '**.yml'
- '.github/workflows/yaml-lint.yml'

jobs:
yaml-lint:
name: Lint YAML Files
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install yamllint
run: |
pip install yamllint

- name: Run yamllint
run: |
yamllint -f parsable -c .yamllint.yml .
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# Logs
*.log

# Temporary files
tmp/
temp/
*.tmp
12 changes: 12 additions & 0 deletions .markdown-link-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ignorePatterns": [
{
"pattern": "^https://github.com/bancey/azuredevops-lib/(wiki|discussions)"
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 3,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206]
}
10 changes: 10 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": true,
"MD013": {
"line_length": 200,
"code_blocks": false,
"tables": false
},
"MD033": false,
"MD041": false
}
50 changes: 50 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
extends: default

rules:
# Azure DevOps templates often have long lines
line-length:
max: 200
level: warning

# Allow inline mappings for Azure DevOps template syntax
braces:
max-spaces-inside: 1
level: warning

# Azure DevOps uses templates with specific indentation
indentation:
spaces: 2
indent-sequences: true

# Allow empty values for Azure DevOps parameters with defaults
empty-values:
forbid-in-block-mappings: false
forbid-in-flow-mappings: false

# Azure DevOps templates use anchors and aliases
anchors:
forbid-undeclared-aliases: true
forbid-duplicated-anchors: true

# Allow duplicate keys for Azure DevOps template overrides
key-duplicates: disable

# Comments are important in templates
comments:
min-spaces-from-content: 1

# Allow truthy values common in Azure DevOps
truthy:
allowed-values: ['true', 'false', 'yes', 'no', 'on', 'off']
check-keys: false

# Allow document start for some files
document-start: disable

# Allow new lines for compatibility
new-lines:
type: unix

# Allow trailing spaces to be fixed automatically
trailing-spaces: enable
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# azuredevops-lib

[![YAML Lint](https://github.com/bancey/azuredevops-lib/actions/workflows/yaml-lint.yml/badge.svg)](https://github.com/bancey/azuredevops-lib/actions/workflows/yaml-lint.yml)
[![Validate Templates](https://github.com/bancey/azuredevops-lib/actions/workflows/validate-templates.yml/badge.svg)](https://github.com/bancey/azuredevops-lib/actions/workflows/validate-templates.yml)
[![Documentation Check](https://github.com/bancey/azuredevops-lib/actions/workflows/documentation-check.yml/badge.svg)](https://github.com/bancey/azuredevops-lib/actions/workflows/documentation-check.yml)
[![CI](https://github.com/bancey/azuredevops-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/bancey/azuredevops-lib/actions/workflows/ci.yml)

A comprehensive collection of reusable Azure DevOps pipeline templates and components for infrastructure automation, configuration management, and CI/CD workflows.

## 🎯 Project Scope
Expand Down Expand Up @@ -131,15 +136,15 @@

## πŸ“ Component Reference

### Stages

Check failure on line 139 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Headings should be surrounded by blank lines

README.md:139 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Stages"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
- `stages/terraform.yaml` - Complete Terraform workflow (plan/apply/destroy)

Check failure on line 140 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Lists should be surrounded by blank lines

README.md:140 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `stages/terraform.yaml` - Co..."] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md
- `stages/check-hosts-online.yaml` - Multi-host connectivity verification

### Jobs

Check failure on line 143 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Headings should be surrounded by blank lines

README.md:143 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Jobs"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
- `jobs/hosts-online-precheck.yaml` - Pre-deployment host availability check

Check failure on line 144 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Lists should be surrounded by blank lines

README.md:144 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `jobs/hosts-online-precheck...."] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md

### Steps

Check failure on line 146 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Headings should be surrounded by blank lines

README.md:146 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Steps"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
- `steps/terraform.yaml` - Terraform operations with Azure backend

Check failure on line 147 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Lists should be surrounded by blank lines

README.md:147 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `steps/terraform.yaml` - Ter..."] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md
- `steps/ansible.yaml` - Ansible playbook execution with secret management
- `steps/gh-auth.yaml` - GitHub App authentication
- `steps/packer.yaml` - Packer image building
Expand All @@ -147,21 +152,32 @@
- `steps/check-host-online.yaml` - Single host connectivity check
- `steps/check-hosts-online.yaml` - Multiple host connectivity check

### Resources

Check failure on line 155 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Headings should be surrounded by blank lines

README.md:155 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Resources"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
- `resources/tfcmt.yaml` - Terraform comment automation configuration

Check failure on line 156 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Lists should be surrounded by blank lines

README.md:156 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `resources/tfcmt.yaml` - Ter..."] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md

## 🀝 Contributing

We welcome contributions to improve and extend this library! Here's how you can help:

### Continuous Integration

This repository uses GitHub Actions for automated testing and validation:

- **YAML Linting**: Validates YAML syntax and style across all templates
- **Template Validation**: Checks YAML structure and parsing
- **Documentation Checks**: Lints markdown files and validates links
- **CI Summary**: Provides comprehensive status on all checks

All workflows run automatically on pull requests and pushes to the main branch. You can see the status of these checks in the Actions tab or on your pull request.

### Getting Started

1. **Fork the repository** on GitHub
2. **Clone your fork** locally:
```bash

Check failure on line 177 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Fenced code blocks should be surrounded by blank lines

README.md:177 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md031.md
git clone https://github.com/your-username/azuredevops-lib.git
cd azuredevops-lib
```

Check failure on line 180 in README.md

View workflow job for this annotation

GitHub Actions / Lint Markdown Files

Fenced code blocks should be surrounded by blank lines

README.md:180 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md031.md
3. **Create a feature branch**:
```bash
git checkout -b feature/your-feature-name
Expand Down Expand Up @@ -200,13 +216,28 @@

1. **Validate YAML syntax**:
```bash
# Use your preferred YAML validator
python -c "import yaml; yaml.safe_load(open('path/to/your/template.yaml'))"
# Install yamllint
pip install yamllint

# Run yamllint on all files
yamllint -f parsable -c .yamllint.yml .
```

2. **Validate YAML structure**:
```bash
# Install PyYAML
pip install pyyaml

# Check all YAML files
find . -type f \( -name "*.yaml" -o -name "*.yml" \) ! -path "./.git/*" | while read file; do
echo "Checking: $file"
python -c "import yaml; yaml.safe_load(open('$file'))"
done
```

2. **Test in a pipeline**: Create a test pipeline in your Azure DevOps organization to validate functionality
3. **Test in a pipeline**: Create a test pipeline in your Azure DevOps organization to validate functionality

3. **Document your changes**: Update this README if you're adding new components or changing existing behavior
4. **Document your changes**: Update this README if you're adding new components or changing existing behavior

### Submitting Changes

Expand Down
2 changes: 1 addition & 1 deletion resources/tfcmt.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
plan_patch: true
plan_patch: true
4 changes: 2 additions & 2 deletions steps/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ steps:
cd ${{ parameters.workingDirectory }}
tfswitch -b $(Pipeline.Workspace)/.tools/bin/terraform
- ${{ if eq(parameters.publishPlan, true) }}:
- name: tfcmt
downloadUrl: https://github.com/suzuki-shunsuke/tfcmt/releases/download/v4.14.12/tfcmt_linux_amd64.tar.gz
- name: tfcmt
downloadUrl: https://github.com/suzuki-shunsuke/tfcmt/releases/download/v4.14.12/tfcmt_linux_amd64.tar.gz
- task: TerraformCLI@2
displayName: Terraform initialize
inputs:
Expand Down
Loading