Skip to content

Commit 086c325

Browse files
JosephJoseph
authored andcommitted
Update docs
1 parent a993908 commit 086c325

File tree

101 files changed

+14784
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+14784
-0
lines changed

.github/workflows/ci.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * 0' # Weekly on Sunday
10+
11+
jobs:
12+
lint-python:
13+
name: Lint Python Scripts
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ['3.8', '3.9', '3.10', '3.11']
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Cache pip dependencies
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
32+
restore-keys: |
33+
${{ runner.os }}-pip-
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install flake8 black isort mypy
39+
40+
- name: Lint with flake8
41+
run: |
42+
# Stop the build if there are Python syntax errors or undefined names
43+
flake8 scripts/ --count --select=E9,F63,F7,F82 --show-source --statistics
44+
# Exit-zero treats all errors as warnings
45+
flake8 scripts/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
46+
47+
- name: Check formatting with black
48+
run: black --check scripts/
49+
50+
- name: Check import order with isort
51+
run: isort --check-only scripts/
52+
53+
- name: Type check with mypy
54+
run: mypy scripts/ || true
55+
56+
test-scripts:
57+
name: Test DORA Scripts
58+
runs-on: ubuntu-latest
59+
needs: lint-python
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: '3.9'
68+
69+
- name: Install test dependencies
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install pytest pytest-cov pytest-mock
73+
74+
- name: Install script dependencies
75+
run: |
76+
for req in scripts/*/requirements.txt; do
77+
pip install -r "$req"
78+
done
79+
80+
- name: Run tests
81+
run: |
82+
pytest tests/ -v --cov=scripts --cov-report=xml
83+
84+
- name: Upload coverage to Codecov
85+
uses: codecov/codecov-action@v3
86+
with:
87+
file: ./coverage.xml
88+
flags: unittests
89+
name: codecov-umbrella
90+
91+
validate-terraform:
92+
name: Validate Terraform
93+
runs-on: ubuntu-latest
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Setup Terraform
99+
uses: hashicorp/setup-terraform@v3
100+
with:
101+
terraform_version: 1.5.0
102+
103+
- name: Terraform Format Check
104+
run: |
105+
cd templates/terraform
106+
terraform fmt -check -recursive
107+
108+
- name: Terraform Init
109+
run: |
110+
cd templates/terraform/monitoring-stack
111+
terraform init -backend=false
112+
113+
- name: Terraform Validate
114+
run: |
115+
cd templates/terraform/monitoring-stack
116+
terraform validate
117+
118+
lint-ansible:
119+
name: Lint Ansible
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
125+
- name: Set up Python
126+
uses: actions/setup-python@v4
127+
with:
128+
python-version: '3.9'
129+
130+
- name: Install Ansible
131+
run: |
132+
python -m pip install --upgrade pip
133+
pip install ansible ansible-lint
134+
135+
- name: Lint Ansible Playbooks
136+
run: |
137+
ansible-lint templates/ansible/
138+
139+
validate-markdown:
140+
name: Validate Documentation
141+
runs-on: ubuntu-latest
142+
143+
steps:
144+
- uses: actions/checkout@v4
145+
146+
- name: Lint Markdown files
147+
uses: DavidAnson/markdownlint-cli2-action@v14
148+
with:
149+
globs: '**/*.md'
150+
151+
- name: Check for broken links
152+
uses: lycheeverse/lychee-action@v1
153+
with:
154+
args: --verbose --no-progress './**/*.md'
155+
fail: false # Don't fail on broken links, just report
156+
157+
security-scan:
158+
name: Security Scan
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- uses: actions/checkout@v4
163+
164+
- name: Run Trivy vulnerability scanner
165+
uses: aquasecurity/trivy-action@master
166+
with:
167+
scan-type: 'fs'
168+
scan-ref: '.'
169+
format: 'sarif'
170+
output: 'trivy-results.sarif'
171+
172+
- name: Upload Trivy scan results
173+
uses: github/codeql-action/upload-sarif@v2
174+
with:
175+
sarif_file: 'trivy-results.sarif'
176+
177+
- name: Run Bandit security linter
178+
run: |
179+
pip install bandit
180+
bandit -r scripts/ -f json -o bandit-report.json || true
181+
182+
build-status:
183+
name: Build Status
184+
runs-on: ubuntu-latest
185+
needs: [lint-python, test-scripts, validate-terraform, lint-ansible, validate-markdown]
186+
if: always()
187+
188+
steps:
189+
- name: Check build status
190+
run: |
191+
if [ "${{ needs.lint-python.result }}" == "failure" ] || \
192+
[ "${{ needs.test-scripts.result }}" == "failure" ] || \
193+
[ "${{ needs.validate-terraform.result }}" == "failure" ] || \
194+
[ "${{ needs.lint-ansible.result }}" == "failure" ] || \
195+
[ "${{ needs.validate-markdown.result }}" == "failure" ]; then
196+
echo "One or more jobs failed"
197+
exit 1
198+
else
199+
echo "All jobs passed successfully"
200+
fi

.github/workflows/release.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
create-release:
14+
name: Create Release
15+
runs-on: ubuntu-latest
16+
outputs:
17+
upload_url: ${{ steps.create_release.outputs.upload_url }}
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Generate Changelog
25+
id: changelog
26+
run: |
27+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
28+
if [ -z "$PREVIOUS_TAG" ]; then
29+
CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges)
30+
else
31+
CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges ${PREVIOUS_TAG}..HEAD)
32+
fi
33+
34+
# Save to file for release body
35+
cat > CHANGELOG.md << EOF
36+
## What's Changed
37+
38+
${CHANGES}
39+
40+
## DORA Metrics Scripts
41+
- Deployment Frequency Calculator
42+
- Lead Time for Changes Analyzer
43+
- MTTR (Mean Time to Recovery) Tracker
44+
- Change Failure Rate Monitor
45+
46+
## Quick Start
47+
\`\`\`bash
48+
pip install -r scripts/requirements.txt
49+
python scripts/DeploymentFrequency/deployment_frequency.py --help
50+
\`\`\`
51+
52+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ github.ref_name }}
53+
EOF
54+
55+
- name: Create Release
56+
id: create_release
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
tag_name: ${{ github.ref_name }}
62+
release_name: Release ${{ github.ref_name }}
63+
body_path: CHANGELOG.md
64+
draft: false
65+
prerelease: false
66+
67+
package-scripts:
68+
name: Package Scripts
69+
runs-on: ubuntu-latest
70+
needs: create-release
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v4
77+
with:
78+
python-version: '3.9'
79+
80+
- name: Create script packages
81+
run: |
82+
# Create a packaged version of scripts
83+
mkdir -p dist
84+
85+
# Package each DORA metric script
86+
for metric in DeploymentFrequency LeadTime MTTR ChangeFailureRate; do
87+
tar -czf dist/dora-metrics-${metric,,}-${{ github.ref_name }}.tar.gz \
88+
-C scripts ${metric}/ \
89+
--transform "s|^|dora-metrics-${metric,,}-${{ github.ref_name }}/|"
90+
done
91+
92+
# Create all-in-one package
93+
tar -czf dist/dora-metrics-complete-${{ github.ref_name }}.tar.gz \
94+
scripts/ templates/ \
95+
--transform "s|^|dora-metrics-${{ github.ref_name }}/|"
96+
97+
- name: Upload Release Assets
98+
uses: actions/upload-release-asset@v1
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
with:
102+
upload_url: ${{ needs.create-release.outputs.upload_url }}
103+
asset_path: dist/dora-metrics-complete-${{ github.ref_name }}.tar.gz
104+
asset_name: dora-metrics-complete-${{ github.ref_name }}.tar.gz
105+
asset_content_type: application/gzip
106+
107+
build-docker-images:
108+
name: Build Docker Images
109+
runs-on: ubuntu-latest
110+
needs: create-release
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Set up Docker Buildx
116+
uses: docker/setup-buildx-action@v3
117+
118+
- name: Log in to GitHub Container Registry
119+
uses: docker/login-action@v3
120+
with:
121+
registry: ghcr.io
122+
username: ${{ github.actor }}
123+
password: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Build and push DORA metrics collector image
126+
uses: docker/build-push-action@v5
127+
with:
128+
context: .
129+
file: docker/Dockerfile.metrics-collector
130+
push: true
131+
tags: |
132+
ghcr.io/${{ github.repository_owner }}/dora-metrics-collector:${{ github.ref_name }}
133+
ghcr.io/${{ github.repository_owner }}/dora-metrics-collector:latest
134+
cache-from: type=gha
135+
cache-to: type=gha,mode=max
136+
137+
update-documentation:
138+
name: Update Documentation
139+
runs-on: ubuntu-latest
140+
needs: create-release
141+
142+
steps:
143+
- uses: actions/checkout@v4
144+
with:
145+
ref: main
146+
147+
- name: Update version references
148+
run: |
149+
# Update version in documentation
150+
sed -i "s/version: .*/version: ${{ github.ref_name }}/g" README.md
151+
152+
# Update installation instructions
153+
sed -i "s|devops-playbook@.*|devops-playbook@${{ github.ref_name }}|g" README.md
154+
155+
- name: Create Pull Request
156+
uses: peter-evans/create-pull-request@v5
157+
with:
158+
token: ${{ secrets.GITHUB_TOKEN }}
159+
commit-message: "docs: update version to ${{ github.ref_name }}"
160+
title: "Update documentation for release ${{ github.ref_name }}"
161+
body: |
162+
This PR updates the documentation to reference the latest release version.
163+
164+
- Updates version numbers in README
165+
- Updates installation instructions
166+
167+
Auto-generated by release workflow.
168+
branch: update-docs-${{ github.ref_name }}
169+
delete-branch: true

0 commit comments

Comments
 (0)