-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
3,524 additions
and
1,885 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
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 |
---|---|---|
@@ -1,30 +1,33 @@ | ||
source .tmpenv # 2>/dev/null || true | ||
################################################################################## | ||
# bash bin | ||
export PATH=$PATH:.github/bin | ||
#!/usr/bin/env bash | ||
|
||
# Platform Architecture | ||
#export ARCH=$(uname -m | awk '{ if ($$1 == "x86_64") print "amd64"; else if ($$1 == "aarch64" || $$1 == "arm64") print "arm64"; else print "unknown" }') | ||
# Source environment variables from .env and temporary environment | ||
source_env .env 2>/dev/null || true | ||
source .tmpenv 2>/dev/null || true | ||
|
||
################################################################################## | ||
# Basic Config Variables | ||
# Add local bin directories to PATH | ||
PATH_add .venv/bin | ||
PATH_add .github/bin | ||
|
||
# Platform Architecture Detection | ||
export ARCH=$(uname -m | awk '{ if ($1 == "x86_64") print "amd64"; else if ($1 == "aarch64" || $1 == "arm64") print "arm64"; else print "unknown" }') | ||
|
||
# Basic Configuration | ||
export BROWSER=echo | ||
export KUBECONFIG=$PWD/.kube/config | ||
export TALOSCONFIG=$PWD/.talos/manifest/talosconfig | ||
#export OMNICONFIG=.talos/omniconfig | ||
|
||
################################################################################## | ||
# Pulumi Environment Variables | ||
# - https://www.pulumi.com/docs/cli/environment-variables | ||
# Pulumi Configuration | ||
# See: https://www.pulumi.com/docs/cli/environment-variables | ||
export PULUMI_SKIP_UPDATE_CHECK=true | ||
export PULUMI_SKIP_CONFIRMATIONS=true | ||
export PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK=true | ||
#export PULUMI_K8S_DELETE_UNREACHABLE=true | ||
#export PULUMI_HOME=$PWD/.pulumi | ||
|
||
################################################################################## | ||
# Optional Pulumi Environment Variables | ||
# Useful for CI testing | ||
# Uncomment to use local backend instead of Pulumi Cloud | ||
# Optional Configuration (commented out by default) | ||
#export OMNICONFIG=.talos/omniconfig | ||
|
||
# Optional Pulumi Backend Configuration | ||
# Uncomment for local backend instead of Pulumi Cloud | ||
#export PULUMI_BACKEND_URL=${PULUMI_BACKEND_URL:-file://$PWD/.pulumi} | ||
#export PULUMI_CONFIG_PASSPHRASE=${PULUMI_CONFIG_PASSPHRASE:-foobarbaz} | ||
#export PULUMI_HOME=$PWD/.pulumi | ||
#export PULUMI_K8S_DELETE_UNREACHABLE=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,69 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Script to count non-comment, non-docstring lines of Python code in Pulumi IaC | ||
# Usage: ./cloc | ||
# Description: Analyzes Python code in the ./pulumi directory, excluding: | ||
# - Comments (lines starting with #) | ||
# - Empty lines and whitespace | ||
# - Docstrings (multi-line strings between """ or ''') | ||
# - Inline comments (# after code) | ||
|
||
# Ensure we're in the root directory | ||
cd "$(dirname "$0")/../.." || exit 1 | ||
|
||
# Verify pulumi directory exists | ||
if [[ ! -d "./pulumi" ]]; then | ||
echo "Error: ./pulumi directory not found!" | ||
exit 1 | ||
fi | ||
|
||
echo "Analyzing Python code in Pulumi Infrastructure as Code (IaC) directory..." | ||
echo "Excluding comments, docstrings, and blank lines..." | ||
|
||
# Count lines across all Python files | ||
total_lines=$(find ./pulumi -name "*.py" -type f -exec awk ' | ||
BEGIN { | ||
in_docstring = 0 | ||
count = 0 | ||
} | ||
{ | ||
# Store original line for inline comment handling | ||
original = $0 | ||
# Trim leading/trailing whitespace | ||
line = $0 | ||
gsub(/^[ \t]+|[ \t]+$/, "", line) | ||
# Skip empty lines | ||
if (line == "") { next } | ||
# Skip full comment lines | ||
if (line ~ /^#/) { next } | ||
# Handle triple-quoted docstrings (both single and double quotes) | ||
if (line ~ /^"""/ || line ~ /"""$/ || line ~ /^'\'''\'''\''/ || line ~ /'\'''\'''\''$/) { | ||
in_docstring = !in_docstring | ||
next | ||
} | ||
if (in_docstring) { next } | ||
# Remove inline comments | ||
sub(/#.*$/, "", original) | ||
# Trim whitespace after removing inline comment | ||
gsub(/^[ \t]+|[ \t]+$/, "", original) | ||
# Skip if line becomes empty after removing inline comment | ||
if (original == "") { next } | ||
# Count this line | ||
count++ | ||
} | ||
END { print count } | ||
' {} \; | awk '{total += $1} END {print total}') | ||
|
||
# Verify we got a valid number | ||
if [[ ! "$total_lines" =~ ^[0-9]+$ ]]; then | ||
echo "Error: Failed to count lines properly!" | ||
exit 1 | ||
fi | ||
|
||
echo "Total lines of Python code: ${total_lines}" |
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
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
Oops, something went wrong.