diff --git a/.pymarkdown.json b/.pymarkdown.json index fe4d4cd..8efdfa2 100644 --- a/.pymarkdown.json +++ b/.pymarkdown.json @@ -6,9 +6,6 @@ "enabled": true, "style": "atx" }, - "commands-show-output": { - "enabled": true - }, "no-missing-space-atx": { "enabled": true }, @@ -37,6 +34,12 @@ }, "no-alt-text": { "enabled": true + }, + "line-length": { + "enabled": true, + "line_length": 120, + "heading_line_length": 120, + "code_block_line_length": 120 } }, "extensions": { @@ -44,4 +47,4 @@ "enabled" : true } } -} \ No newline at end of file +} diff --git a/Makefile b/Makefile index 1c93dec..ac76358 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,18 @@ VENVDIR := .venv CONFIG := .pymarkdown.json SOURCEDIR ?= . +FILE ?= # Phony targets -.PHONY: help lint-md clean venv pymarkdownlnt-install +.PHONY: help lint-md clean venv pymarkdownlnt-install preview # Default target help: @echo "Available targets:" @echo " venv - Create virtual environment using uv" @echo " pymarkdownlnt-install - Install pymarkdownlnt" - @echo " lint-md - Run markdown linter" + @echo " lint-md - Run markdown linter (FILE=path/to/file.md to check a single file)" + @echo " preview - Preview files that would be installed for a collection (COLLECTION=name)" @echo " clean - Remove virtual environment" # Create virtual environment using uv @@ -32,12 +34,31 @@ pymarkdownlnt-install: venv @uv pip install --python $(VENVDIR) pymarkdownlnt --quiet 2>&1 | grep -v "Audited" || true # Run markdown linter +# Usage: make lint-md [FILE=path/to/file.md] [SOURCEDIR=path/to/dir] lint-md: pymarkdownlnt-install @echo "Running markdown linter..." - @uv run --python $(VENVDIR) pymarkdownlnt --config $(CONFIG) scan --recurse $(SOURCEDIR) + @if [ -n "$(FILE)" ]; then \ + uv run --python $(VENVDIR) pymarkdownlnt --config $(CONFIG) scan $(FILE); \ + else \ + uv run --python $(VENVDIR) pymarkdownlnt --config $(CONFIG) scan --recurse $(SOURCEDIR); \ + fi # Clean virtual environment clean: @echo "Removing virtual environment..." @rm -rf $(VENVDIR) @echo "Virtual environment removed" + +# Preview what would be installed for a given collection (dry-run) +# Usage: make preview COLLECTION= +COLLECTION ?= +preview: + @if [ -z "$(COLLECTION)" ]; then \ + echo "❌ Usage: make preview COLLECTION="; \ + exit 1; \ + fi + @TMPFILE=$$(mktemp ./copilot-preview-XXXXXX.yaml) && \ + printf 'copilot:\n collections:\n - %s\n' "$(COLLECTION)" > $$TMPFILE && \ + echo "🔍 Previewing collection: $(COLLECTION)" && \ + bash scripts/install_collections.sh $$TMPFILE . --dry-run; \ + rm -f $$TMPFILE diff --git a/groups/platform-engineering/collections.yaml b/groups/platform-engineering/collections.yaml index 02a7f12..a4ac14d 100644 --- a/groups/platform-engineering/collections.yaml +++ b/groups/platform-engineering/collections.yaml @@ -36,3 +36,5 @@ pfe-charms: dest: .github/instructions/charms-lib-updates.instructions.md - src: /assets/instructions/common/core-directive.instructions.md dest: .github/instructions/core-directive.instructions.md + - src: skills/create-pr + dest: .github/skills/create-pr diff --git a/groups/platform-engineering/skills/create-pr/SKILL.md b/groups/platform-engineering/skills/create-pr/SKILL.md new file mode 100644 index 0000000..b0ecea6 --- /dev/null +++ b/groups/platform-engineering/skills/create-pr/SKILL.md @@ -0,0 +1,66 @@ +--- +name: create-pr +description: Create a pull request for the current session. Use when the user wants to open a PR with the session's changes. +# reference documentation: https://github.com/canonical/platform-engineering-docs/edit/main/docs/delivery-workflows/github/pull-requests/index.rst +--- + +# Create Pull Request + +Use the GitHub MCP server to create a pull request — do NOT use the `gh` CLI. + +1. Run the compile and hygiene tasks (fixing any errors) +2. If there are any uncommitted changes, use the `/commit` skill to commit them +3. Review all changes in the current session +4. Write a clear, concise PR title with a short area prefix (e.g. "sessions: …", "editor: …") +5. Write a description covering what changed, why, and anything reviewers should know +6. Create the pull request following the guidelines from the next sections. + +## PR description + +Unless the PR is trivial or self-explanatory (for example, fixing typos in the +documentation, a well known task that needs to be done across many repositories +such as enabling a new bot), the PR description should include: + +- A high level overview of the change +- The reason the change is needed +- Any additional information requested in the pull request template. + +Use the template available in `.github/pull_request_template.md>` if available. + +## PR branch name + +PR branches should be named in a way that indicates the purpose of the branch. + +Format: **type/scope-short-description[-optional-identifier]** (all lowercase, words separated by hyphens) + +Where the type can be one of the following: + +- `feat`: a new feature +- `fix`: a bug fix +- `docs`: documentation changes +- `chore`: a change that doesn't add a feature or fix a bug + (typically a maintenance change, such as updating dependencies or aligning with standards) +- `test`: adding or updating tests (if not related to a specific feature or bug fix, + in which case it should be tagged with the relevant type) +- `ci`: changes to our CI configuration or scripts (if not related to a specific feature or bug fix, + in which case it should be tagged with the relevant type) + +Examples: + +- `feat/tcp-wildcard-sni-support-isd-1234` +- `fix/non-working-tls-relation` +- `chore/terraform-align-module` + +## PR title + +The PR title follows the same philosophy as the branch name. + +Format: **type(scope):short description [optional-identifier]** (all lowercase, words separated by spaces) + +Where the type is the same as described in the branch name section. + +Examples: + +- `feat(tcp): add wildcard SNI support (ISD-1234)` +- `fix(tls): non-working TLS relation` +- `chore(terraform): align module with standards` diff --git a/scripts/install_collections.sh b/scripts/install_collections.sh index a0838d3..85d497a 100755 --- a/scripts/install_collections.sh +++ b/scripts/install_collections.sh @@ -5,13 +5,20 @@ set -e -# Usage: ./install_collections.sh +# Usage: ./install_collections.sh [--dry-run] CONFIG_FILE="$1" TOOLKIT_DIR="$2" +DRY_RUN=false + +for arg in "$@"; do + if [ "$arg" = "--dry-run" ]; then + DRY_RUN=true + fi +done # 1. Validation if [ -z "$CONFIG_FILE" ] || [ -z "$TOOLKIT_DIR" ]; then - echo "❌ Usage: $0 " + echo "❌ Usage: $0 [--dry-run]" exit 1 fi @@ -103,6 +110,10 @@ process_collection() { echo " - Installing $src -> $dest" + if [ "$DRY_RUN" = true ]; then + continue + fi + if [ -d "$full_src" ]; then # Folder Copy mkdir -p "$dest" @@ -125,4 +136,8 @@ for col in $COLLECTIONS_LIST; do done rm "$MERGED_MANIFEST" -echo "✅ Sync complete." +if [ "$DRY_RUN" = true ]; then + echo "🔍 Dry-run complete. No files were copied." +else + echo "✅ Sync complete." +fi