From 1b685fee1f35c710214d0cbabd42fd052f2aa45f Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Wed, 17 Dec 2025 17:03:25 +0400 Subject: [PATCH 01/12] Refactor action.yml for template synchronization Updated action.yml to improve clarity and functionality, including changes to input descriptions, branch defaults, and steps for syncing templates. --- action.yml | 212 +++++++++++++---------------------------------------- 1 file changed, 51 insertions(+), 161 deletions(-) diff --git a/action.yml b/action.yml index a9e5b06..b1bbfd2 100644 --- a/action.yml +++ b/action.yml @@ -1,220 +1,110 @@ -name: 'Sync Template' -description: 'Sync template into a project and optionally create a pull request' -author: 'Thomas Schmelzer' +name: Sync Repository Template +description: Synchronize a repository template into the current project and optionally open a pull request +author: Thomas Schmelzer inputs: token: - description: 'GitHub token or PAT for authentication' + description: GitHub token or PAT for authentication required: true + source: - description: 'Path to the YAML configuration file containing template settings' + description: Path to the YAML configuration file containing template settings required: true + branch: - description: 'Target branch in the current repo' - default: 'sync/update' + description: Target branch for the sync + required: false + default: sync/template-update + commit-message: - description: 'Commit message for sync' - default: 'chore: sync template' - test-mode: - description: 'If true, skip push and PR creation' - default: 'false' - automerge: - description: 'If true, enable auto-merge on the PR' - default: 'false' - template-ref: - description: 'Tag or branch to check out from the template repository (overrides template-branch)' + description: Commit message for the sync + required: false + default: "chore: sync template" + + create-pr: + description: Whether to create a pull request if changes are detected required: false + default: "true" outputs: changes-detected: - description: 'Whether changes were detected during the sync (true or false)' - value: ${{ steps.commit-changes.outputs.changes_detected }} + description: Whether changes were detected during the sync (true or false) + value: ${{ steps.sync.outputs.changes_detected }} runs: - using: "composite" + using: composite steps: # ------------------------------------------------------------ - # Checkout target repo + # Checkout target repository # ------------------------------------------------------------ - - name: Checkout the target repo + - name: Checkout repository uses: actions/checkout@v6 with: token: ${{ inputs.token }} fetch-depth: 0 - - name: Ensure inside a git repository - shell: bash - run: git rev-parse --is-inside-work-tree >/dev/null || { echo "❌ Not in a git repository"; exit 1; } - # ------------------------------------------------------------ - # Parse configuration (repository, branch, ref, includes, excludes) + # Tooling # ------------------------------------------------------------ - - name: Parse configuration file - shell: bash - id: config - run: | - CONFIG_FILE="${{ inputs.source }}" - echo "Reading configuration from ${CONFIG_FILE}" - - if [[ ! -f "${CONFIG_FILE}" ]]; then - echo "::error::Configuration file not found: ${CONFIG_FILE}" - exit 1 - fi - - # Install yq if needed - if ! command -v yq &>/dev/null; then - wget -qO /tmp/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 - chmod +x /tmp/yq - YQ="/tmp/yq" - else - YQ="yq" - fi - - TEMPLATE_REPO="$($YQ '.template-repository // ""' "${CONFIG_FILE}")" - if [[ -z "$TEMPLATE_REPO" ]]; then - echo "::error::template-repository missing in ${CONFIG_FILE}" - exit 1 - fi - echo "template_repository=$TEMPLATE_REPO" >> $GITHUB_OUTPUT - - TEMPLATE_BRANCH="$($YQ '.template-branch // "main"' "${CONFIG_FILE}")" - echo "template_branch=$TEMPLATE_BRANCH" >> $GITHUB_OUTPUT - - TEMPLATE_REF="$($YQ '.template-ref // ""' "${CONFIG_FILE}")" - echo "template_ref=$TEMPLATE_REF" >> $GITHUB_OUTPUT - - # New: Tag/Ref override - #TEMPLATE_REF_INPUT="${{ inputs.template-ref }}" - #TEMPLATE_REF_CONFIG="$($YQ '.template-ref // ""' "${CONFIG_FILE}")" - #TEMPLATE_REF="${TEMPLATE_REF_INPUT:-$TEMPLATE_REF_CONFIG}" - #echo "template_ref=$TEMPLATE_REF" >> $GITHUB_OUTPUT - - # Include patterns - support both pipe (|) and list (-) syntax - INCLUDE_TYPE="$($YQ '.include | type' "${CONFIG_FILE}" 2>/dev/null || echo "null")" - if [[ "$INCLUDE_TYPE" == "!!seq" ]]; then - # It's a YAML list with dashes - INCLUDE="$($YQ '.include[]' "${CONFIG_FILE}")" - else - # It's a string (pipe syntax) or doesn't exist - INCLUDE="$($YQ '.include // ""' "${CONFIG_FILE}")" - fi - echo "include<> $GITHUB_OUTPUT - echo "$INCLUDE" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - # Exclude patterns - support both pipe (|) and list (-) syntax - EXCLUDE_TYPE="$($YQ '.exclude | type' "${CONFIG_FILE}" 2>/dev/null || echo "null")" - if [[ "$EXCLUDE_TYPE" == "!!seq" ]]; then - # It's a YAML list with dashes - EXCLUDE="$($YQ '.exclude[]' "${CONFIG_FILE}")" - else - # It's a string (pipe syntax) or doesn't exist - EXCLUDE="$($YQ '.exclude // ""' "${CONFIG_FILE}")" - fi - echo "exclude<> $GITHUB_OUTPUT - echo "$EXCLUDE" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - # ------------------------------------------------------------ - # Sparse checkout template (branch or tag -> ref) - # ------------------------------------------------------------ - - name: Sparse checkout template - uses: actions/checkout@v6 + - name: Install uv + uses: astral-sh/setup-uv@v7 with: - repository: ${{ steps.config.outputs.template_repository }} - ref: ${{ steps.config.outputs.template_ref || steps.config.outputs.template_branch }} - path: .template-temp - token: ${{ inputs.token }} - fetch-depth: 0 - sparse-checkout: ${{ steps.config.outputs.include }} - sparse-checkout-cone-mode: false + version: "0.9.17" # ------------------------------------------------------------ - # Clean template and apply excludes + # Validate configuration # ------------------------------------------------------------ - - name: Clean template and apply excludes + - name: Validate rhiza configuration shell: bash - working-directory: .template-temp run: | - rm -rf .git - EXCLUDES="${{ steps.config.outputs.exclude }}" - - if [[ -n "$EXCLUDES" ]]; then - echo "$EXCLUDES" | while IFS= read -r item; do - [[ -z "$item" ]] && continue - item="$(echo "$item" | xargs)" - rm -rf "$item" 2>/dev/null || true - done - fi - - tree -L 2 || ls -R + uvx rhiza validate "${{ inputs.source }}" # ------------------------------------------------------------ - # Apply template + commit & push + # Materialize + commit changes # ------------------------------------------------------------ - - name: Commit and optionally push changes - id: commit-changes + - name: Sync template + id: sync shell: bash - env: - TEST_MODE: ${{ inputs.test-mode }} run: | - cp -R .template-temp/. . - rm -rf .template-temp + set -euo pipefail + + git checkout -B "${{ inputs.branch }}" + + uvx rhiza materialize "${{ inputs.source }}" git add -A if git diff --cached --quiet; then - echo "changes_detected=false" >> $GITHUB_OUTPUT - echo "No changes." + echo "No changes detected." + echo "changes_detected=false" >> "$GITHUB_OUTPUT" exit 0 fi - echo "changes_detected=true" >> $GITHUB_OUTPUT + echo "changes_detected=true" >> "$GITHUB_OUTPUT" if git diff --cached --name-only | grep -q '^\.github/workflows/'; then - echo "⚠️ Workflow files modified — PAT with workflow scope required." + echo "⚠️ Workflow files modified — PAT with workflow scope may be required." fi - git config user.name 'github-actions[bot]' - git config user.email '41898282+github-actions[bot]@users.noreply.github.com' - git commit -m "${{ inputs.commit-message }}" + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - if [[ "$TEST_MODE" == "true" ]]; then - echo "🧪 Test mode: skipping push" - exit 0 - fi - - target_branch="${{ inputs.branch }}" - git push origin "HEAD:$target_branch" --force-with-lease + git commit -m "${{ inputs.commit-message }}" + git push origin "HEAD:${{ inputs.branch }}" --force-with-lease # ------------------------------------------------------------ # Create Pull Request # ------------------------------------------------------------ - - name: Create Pull Request - id: create-pr - if: ${{ inputs.test-mode != 'true' && steps.commit-changes.outputs.changes_detected == 'true' }} + - name: Create pull request + if: ${{ inputs.create-pr == 'true' && steps.sync.outputs.changes_detected == 'true' }} uses: peter-evans/create-pull-request@v8 with: token: ${{ inputs.token }} branch: ${{ inputs.branch }} - commit-message: ${{ inputs.commit-message }} delete-branch: false - title: "chore: sync template from ${{ steps.config.outputs.template_repository }}@${{ steps.config.outputs.template_ref || steps.config.outputs.template_branch }}" + title: ${{ inputs.commit-message }} body: | - This PR syncs the template from: - **${{ steps.config.outputs.template_repository }} @ ${{ steps.config.outputs.template_ref || steps.config.outputs.template_branch }}** + This pull request synchronizes the repository with its template. - # ------------------------------------------------------------ - # Auto-merge - # ------------------------------------------------------------ - - name: Enable auto-merge - if: ${{ inputs.automerge == 'true' && steps.create-pr.outputs.pull-request-number }} - shell: bash - env: - GH_TOKEN: ${{ inputs.token }} - run: | - gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} \ - --merge \ - --auto \ - --delete-branch \ No newline at end of file + Changes were generated automatically using **rhiza**. From 383b1a9778cf47b1541f88a7d4dc0f687e05bb32 Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Wed, 17 Dec 2025 17:08:11 +0400 Subject: [PATCH 02/12] Refactor test-action.sh for clarity and structure Refactor test-action.sh script for improved clarity and structure, including changes to variable names, comments, and echo statements. --- tests/test-action.sh | 288 ++++++++++++++----------------------------- 1 file changed, 90 insertions(+), 198 deletions(-) diff --git a/tests/test-action.sh b/tests/test-action.sh index d7aeb9a..f81064f 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -1,32 +1,23 @@ #!/bin/bash -set -e +set -euo pipefail -# Colors for output +# ------------------------------------------------------------ +# Colors +# ------------------------------------------------------------ GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[0;33m' -NC='\033[0m' # No Color +NC='\033[0m' -echo -e "${YELLOW}Starting test for Sync Template Action${NC}" +echo -e "${YELLOW}Starting test for Sync Repository Template action${NC}" -# Create test directory -TEST_DIR=$(mktemp -d) -echo -e "Using temporary directory: ${TEST_DIR}" - -# Cleanup function -cleanup() { - echo -e "${YELLOW}Cleaning up test environment${NC}" - rm -rf "${TEST_DIR}" -} - -# Register cleanup function to run on exit -trap cleanup EXIT - -# Function to check if a test passes +# ------------------------------------------------------------ +# Helpers +# ------------------------------------------------------------ assert() { local condition=$1 local message=$2 - + if eval "${condition}"; then echo -e "${GREEN}✅ PASS: ${message}${NC}" else @@ -35,217 +26,118 @@ assert() { fi } -# Setup source repository (template) -echo -e "${YELLOW}Setting up source repository${NC}" -SOURCE_REPO="${TEST_DIR}/source-repo" +# ------------------------------------------------------------ +# Temp workspace +# ------------------------------------------------------------ +TEST_DIR="$(mktemp -d)" +trap 'rm -rf "${TEST_DIR}"' EXIT +echo "Using temp dir: ${TEST_DIR}" + +# ------------------------------------------------------------ +# Source repo (template) +# ------------------------------------------------------------ +echo -e "${YELLOW}Setting up template repository${NC}" +SOURCE_REPO="${TEST_DIR}/template" mkdir -p "${SOURCE_REPO}" cd "${SOURCE_REPO}" -git init +git init -q git config user.name "Test User" git config user.email "test@example.com" -# Create template files -echo "# Template README" > README.md -echo "# Code of Conduct" > CODE_OF_CONDUCT.md -echo "# Contributing Guide" > CONTRIBUTING.md +cat > README.md < CODE_OF_CONDUCT.md < CONTRIBUTING.md < .github/workflows/test.yml -echo "# License" > LICENSE +echo "name: Template Workflow" > .github/workflows/test.yml -git add . -git commit -m "Initial commit" +cat > LICENSE < README.md -echo "# Target License" > LICENSE -git add . -git commit -m "Initial commit" +cat > README.md < LICENSE < template.yml << EOF +# ------------------------------------------------------------ +# Rhiza config +# ------------------------------------------------------------ +cat > template.yml <> .git/info/sparse-checkout -done < <(grep -A 10 "^include: |" ../template.yml | tail -n +2 | grep -v "^exclude:") - -git pull origin main --depth=1 - -# Step 2: Apply excludes -echo "Applying excludes" -# First, remove the .git directory -rm -rf .git - -# Read exclude patterns from template.yml file and remove files -while IFS= read -r pattern; do - pattern="$(echo "$pattern" | xargs)" - [ -z "$pattern" ] || rm -rf "$pattern" 2>/dev/null || true -done < <(grep -A 10 "^exclude: |" ../template.yml | tail -n +2) - -# Make sure we're on the sync/update-configs branch before copying files -cd "${TARGET_REPO}" -git checkout sync/update-configs +# ------------------------------------------------------------ +# Run rhiza (this is what the action does) +# ------------------------------------------------------------ +echo -e "${YELLOW}Running rhiza validate${NC}" +uvx rhiza validate template.yml -# Step 3: Copy template files to target repo -echo "Copying template files" -# Copy all files from template temp directory -cp -R .template-temp/. . -rm -rf .template-temp +echo -e "${YELLOW}Running rhiza materialize${NC}" +git checkout -B sync/template-update +uvx rhiza materialize template.yml -# Step 4: Commit and push changes -git checkout "${BRANCH_NAME}" -git add CODE_OF_CONDUCT.md CONTRIBUTING.md .github -git commit -m "chore: sync template" +git add -A +git commit -qm "chore: sync template" -# Verify results +# ------------------------------------------------------------ +# Assertions +# ------------------------------------------------------------ echo -e "${YELLOW}Verifying results${NC}" -# Check that files were synced correctly +# Included assert "[ -f CODE_OF_CONDUCT.md ]" "CODE_OF_CONDUCT.md exists" assert "[ -f CONTRIBUTING.md ]" "CONTRIBUTING.md exists" -assert "[ -d .github ]" ".github directory exists" assert "[ -f .github/workflows/test.yml ]" "Workflow file exists" -# Check that excluded files were not synced -assert "[ \"$(cat README.md)\" = \"# Target README\" ]" "README.md was not overwritten" -assert "[ \"$(cat LICENSE)\" = \"# Target License\" ]" "LICENSE was not overwritten" - -# Check commit message -assert "[ \"$(git log -1 --pretty=%B)\" = \"chore: sync template\" ]" "Commit message is correct" - -# Simulate auto-merge behavior as implemented in action.yml -# Condition: Enable auto-merge only when automerge input is 'true' AND a PR number is available (non-empty) -echo -e "${YELLOW}Simulating auto-merge behavior${NC}" - -# Positive case: automerge enabled and PR number available triggers auto-merge command -AUTOMERGE="true" -PR_NUMBER="123" -AUTO_MERGE_CMD="" -if [[ "${AUTOMERGE}" == "true" && "${PR_NUMBER}" != "" ]]; then - AUTO_MERGE_CMD="gh pr merge ${PR_NUMBER} --merge --auto --delete-branch" -fi -assert "[ \"${AUTO_MERGE_CMD}\" = \"gh pr merge 123 --merge --auto --delete-branch\" ]" "Auto-merge command generated when automerge is true and PR number is set" - -# Negative case: automerge disabled means skip even if PR number exists -AUTOMERGE="false" -PR_NUMBER="123" -AUTO_MERGE_EXECUTED="false" -if [[ "${AUTOMERGE}" == "true" && "${PR_NUMBER}" != "" ]]; then - AUTO_MERGE_EXECUTED="true" -fi -assert "[ \"${AUTO_MERGE_EXECUTED}\" = \"false\" ]" "Auto-merge is skipped when automerge is false even if PR number is provided" - -# Negative case: automerge enabled but no PR number means skip -AUTOMERGE="true" -PR_NUMBER="" -AUTO_MERGE_EXECUTED="false" -if [[ "${AUTOMERGE}" == "true" && "${PR_NUMBER}" != "" ]]; then - AUTO_MERGE_EXECUTED="true" -fi -assert "[ \"${AUTO_MERGE_EXECUTED}\" = \"false\" ]" "Auto-merge is skipped when PR number is empty" - -# Test list format for include/exclude -echo -e "${YELLOW}Testing YAML list format for include/exclude${NC}" - -# Setup a new test with list format -cd "${TARGET_REPO}" -# Clean up previous test files -git checkout main 2>/dev/null || git checkout -b main -git reset --hard HEAD~1 2>/dev/null || true -git checkout -b sync/test-list-format +# Excluded +assert "[ \"$(cat README.md)\" = \"# Target README\" ]" "README.md preserved" +assert "[ \"$(cat LICENSE)\" = \"Target License\" ]" "LICENSE preserved" -# Create template.yml with list format -cat > template-list.yml << EOF -template-repository: ${SOURCE_REPO} -template-branch: main -include: - - CODE_OF_CONDUCT.md - - CONTRIBUTING.md -exclude: - - README.md -EOF +# Commit message +assert "[ \"$(git log -1 --pretty=%B)\" = \"chore: sync template\" ]" "Commit message correct" + +# Branch +assert "[ \"$(git branch --show-current)\" = \"sync/template-update\" ]" "Correct branch used" -# Install yq if needed -if ! command -v yq &>/dev/null; then - wget -qO /tmp/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 - chmod +x /tmp/yq - YQ="/tmp/yq" -else - YQ="yq" -fi - -# Parse the list format using same logic as action.yml -INCLUDE_TYPE="$($YQ '.include | type' template-list.yml 2>/dev/null || echo "null")" -if [[ "$INCLUDE_TYPE" == "!!seq" ]]; then - INCLUDE="$($YQ '.include[]' template-list.yml)" -else - INCLUDE="$($YQ '.include // ""' template-list.yml)" -fi - -EXCLUDE_TYPE="$($YQ '.exclude | type' template-list.yml 2>/dev/null || echo "null")" -if [[ "$EXCLUDE_TYPE" == "!!seq" ]]; then - EXCLUDE="$($YQ '.exclude[]' template-list.yml)" -else - EXCLUDE="$($YQ '.exclude // ""' template-list.yml)" -fi - -# Verify parsed values -assert "[ \"$INCLUDE_TYPE\" = \"!!seq\" ]" "Include field is recognized as a sequence" -assert "[ \"$EXCLUDE_TYPE\" = \"!!seq\" ]" "Exclude field is recognized as a sequence" - -# Check that parsed values contain expected content -assert "echo \"$INCLUDE\" | grep -q 'CODE_OF_CONDUCT.md'" "Include contains CODE_OF_CONDUCT.md" -assert "echo \"$INCLUDE\" | grep -q 'CONTRIBUTING.md'" "Include contains CONTRIBUTING.md" -assert "echo \"$EXCLUDE\" | grep -q 'README.md'" "Exclude contains README.md" - -echo -e "${GREEN}All tests passed!${NC}" \ No newline at end of file +echo -e "${GREEN}All tests passed!${NC}" From 8005bb4c23b00566f85cfb90d47c73837d14396f Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Wed, 17 Dec 2025 17:10:12 +0400 Subject: [PATCH 03/12] Ensure uv/uvx is available in test-action.sh Add check and installation for uv/uvx in test script --- tests/test-action.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test-action.sh b/tests/test-action.sh index f81064f..28d06f9 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -11,6 +11,17 @@ NC='\033[0m' echo -e "${YELLOW}Starting test for Sync Repository Template action${NC}" +# ------------------------------------------------------------ +# Ensure uv / uvx is available (mirror action) +# ------------------------------------------------------------ +if ! command -v uvx >/dev/null 2>&1; then + echo -e "${YELLOW}Installing uv / uvx${NC}" + + curl -LsSf https://astral.sh/uv/install.sh | sh + + export PATH="$HOME/.local/bin:$PATH" +fi + # ------------------------------------------------------------ # Helpers # ------------------------------------------------------------ From 82f372e74b90155aa95df42250282dd7ff03f41c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:11:40 +0000 Subject: [PATCH 04/12] Initial plan From 866fe90d4612e13a31a21f8009619420b75da519 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:16:57 +0000 Subject: [PATCH 05/12] Fix rhiza command usage to pass directory instead of file path Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --- action.yml | 18 ++++++++++++++++-- tests/test-action.sh | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index b1bbfd2..cada8ca 100644 --- a/action.yml +++ b/action.yml @@ -58,7 +58,14 @@ runs: - name: Validate rhiza configuration shell: bash run: | - uvx rhiza validate "${{ inputs.source }}" + CONFIG_FILE="${{ inputs.source }}" + + # If config file is not in the root as template.yml, copy it there temporarily + if [[ "$CONFIG_FILE" != "template.yml" ]] && [[ "$CONFIG_FILE" != "./template.yml" ]]; then + cp "$CONFIG_FILE" template.yml + fi + + uvx rhiza validate . # ------------------------------------------------------------ # Materialize + commit changes @@ -69,9 +76,16 @@ runs: run: | set -euo pipefail + CONFIG_FILE="${{ inputs.source }}" + + # If config file is not in the root as template.yml, copy it there temporarily + if [[ "$CONFIG_FILE" != "template.yml" ]] && [[ "$CONFIG_FILE" != "./template.yml" ]]; then + cp "$CONFIG_FILE" template.yml + fi + git checkout -B "${{ inputs.branch }}" - uvx rhiza materialize "${{ inputs.source }}" + uvx rhiza materialize . git add -A diff --git a/tests/test-action.sh b/tests/test-action.sh index 28d06f9..9ef904b 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -122,11 +122,11 @@ EOF # Run rhiza (this is what the action does) # ------------------------------------------------------------ echo -e "${YELLOW}Running rhiza validate${NC}" -uvx rhiza validate template.yml +uvx rhiza validate . echo -e "${YELLOW}Running rhiza materialize${NC}" git checkout -B sync/template-update -uvx rhiza materialize template.yml +uvx rhiza materialize . git add -A git commit -qm "chore: sync template" From 1987245d5083c5c0602c4234b890845a266cfcd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:35:12 +0000 Subject: [PATCH 06/12] Remove inputs.source parameter - rhiza uses .github/template.yml by default Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --- action.yml | 21 +-------------------- tests/test-action.sh | 3 ++- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/action.yml b/action.yml index cada8ca..55a92b8 100644 --- a/action.yml +++ b/action.yml @@ -7,10 +7,6 @@ inputs: description: GitHub token or PAT for authentication required: true - source: - description: Path to the YAML configuration file containing template settings - required: true - branch: description: Target branch for the sync required: false @@ -57,15 +53,7 @@ runs: # ------------------------------------------------------------ - name: Validate rhiza configuration shell: bash - run: | - CONFIG_FILE="${{ inputs.source }}" - - # If config file is not in the root as template.yml, copy it there temporarily - if [[ "$CONFIG_FILE" != "template.yml" ]] && [[ "$CONFIG_FILE" != "./template.yml" ]]; then - cp "$CONFIG_FILE" template.yml - fi - - uvx rhiza validate . + run: uvx rhiza validate . # ------------------------------------------------------------ # Materialize + commit changes @@ -76,13 +64,6 @@ runs: run: | set -euo pipefail - CONFIG_FILE="${{ inputs.source }}" - - # If config file is not in the root as template.yml, copy it there temporarily - if [[ "$CONFIG_FILE" != "template.yml" ]] && [[ "$CONFIG_FILE" != "./template.yml" ]]; then - cp "$CONFIG_FILE" template.yml - fi - git checkout -B "${{ inputs.branch }}" uvx rhiza materialize . diff --git a/tests/test-action.sh b/tests/test-action.sh index 9ef904b..0e193a1 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -106,7 +106,8 @@ git branch -M main # ------------------------------------------------------------ # Rhiza config # ------------------------------------------------------------ -cat > template.yml < .github/template.yml < Date: Wed, 17 Dec 2025 13:53:14 +0000 Subject: [PATCH 07/12] Initial plan From 1188ef2635982256338a6664b9a0b03085b99c73 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:55:37 +0000 Subject: [PATCH 08/12] Fix test to use file:// URL for local template repository Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --- tests/test-action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-action.sh b/tests/test-action.sh index 0e193a1..d70e3fd 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -108,7 +108,7 @@ git branch -M main # ------------------------------------------------------------ mkdir -p .github cat > .github/template.yml < Date: Wed, 17 Dec 2025 18:18:17 +0400 Subject: [PATCH 09/12] Simplify test to use actual GitHub repository (#19) * Initial plan * Simplify test to use real GitHub repository (jebel-quant/rhiza) Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --- tests/test-action.sh | 123 +++++-------------------------------------- 1 file changed, 12 insertions(+), 111 deletions(-) diff --git a/tests/test-action.sh b/tests/test-action.sh index d70e3fd..db94894 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -16,111 +16,24 @@ echo -e "${YELLOW}Starting test for Sync Repository Template action${NC}" # ------------------------------------------------------------ if ! command -v uvx >/dev/null 2>&1; then echo -e "${YELLOW}Installing uv / uvx${NC}" - curl -LsSf https://astral.sh/uv/install.sh | sh - export PATH="$HOME/.local/bin:$PATH" fi # ------------------------------------------------------------ -# Helpers -# ------------------------------------------------------------ -assert() { - local condition=$1 - local message=$2 - - if eval "${condition}"; then - echo -e "${GREEN}✅ PASS: ${message}${NC}" - else - echo -e "${RED}❌ FAIL: ${message}${NC}" - exit 1 - fi -} - -# ------------------------------------------------------------ -# Temp workspace +# Clone the jebel-quant/rhiza repository to test with # ------------------------------------------------------------ TEST_DIR="$(mktemp -d)" trap 'rm -rf "${TEST_DIR}"' EXIT echo "Using temp dir: ${TEST_DIR}" -# ------------------------------------------------------------ -# Source repo (template) -# ------------------------------------------------------------ -echo -e "${YELLOW}Setting up template repository${NC}" -SOURCE_REPO="${TEST_DIR}/template" -mkdir -p "${SOURCE_REPO}" -cd "${SOURCE_REPO}" - -git init -q -git config user.name "Test User" -git config user.email "test@example.com" - -cat > README.md < CODE_OF_CONDUCT.md < CONTRIBUTING.md < .github/workflows/test.yml - -cat > LICENSE < README.md < LICENSE < .github/template.yml < Date: Wed, 17 Dec 2025 18:21:58 +0400 Subject: [PATCH 10/12] Update test-action.sh --- tests/test-action.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-action.sh b/tests/test-action.sh index db94894..59a4807 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -27,9 +27,9 @@ TEST_DIR="$(mktemp -d)" trap 'rm -rf "${TEST_DIR}"' EXIT echo "Using temp dir: ${TEST_DIR}" -echo -e "${YELLOW}Cloning jebel-quant/rhiza repository${NC}" +echo -e "${YELLOW}Cloning tschm/monkeys repository${NC}" cd "${TEST_DIR}" -git clone --quiet https://github.com/jebel-quant/rhiza.git +git clone --quiet https://github.com/tschm/monkeys.git cd rhiza # ------------------------------------------------------------ @@ -39,7 +39,7 @@ echo -e "${YELLOW}Running rhiza validate${NC}" uvx rhiza validate . echo -e "${YELLOW}Running rhiza materialize${NC}" -git checkout -B sync/template-update +# git checkout -B sync/template-update uvx rhiza materialize . # ------------------------------------------------------------ From 52dbfa8b938a6c2a3e7c45556c7df89ad7a4059b Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Wed, 17 Dec 2025 18:25:34 +0400 Subject: [PATCH 11/12] Fix formatting of include section in template.yml --- .github/template.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/template.yml b/.github/template.yml index 6bc4323..128f303 100644 --- a/.github/template.yml +++ b/.github/template.yml @@ -1,8 +1,8 @@ template-repository: jebel-quant/sync_template template-branch: main -include: | - CODE_OF_CONDUCT.md - CONTRIBUTING.md +include: + - CODE_OF_CONDUCT.md + - CONTRIBUTING.md exclude: - README.md - LICENSE From b0fbf687784811696a7207e4e391fad4a9ae09e0 Mon Sep 17 00:00:00 2001 From: Thomas Schmelzer Date: Wed, 17 Dec 2025 18:27:26 +0400 Subject: [PATCH 12/12] Disable cloning of jebel-quant/rhiza repository Comment out the cloning of the jebel-quant/rhiza repository and related commands. --- tests/test-action.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test-action.sh b/tests/test-action.sh index 59a4807..09c786a 100755 --- a/tests/test-action.sh +++ b/tests/test-action.sh @@ -20,17 +20,17 @@ if ! command -v uvx >/dev/null 2>&1; then export PATH="$HOME/.local/bin:$PATH" fi -# ------------------------------------------------------------ -# Clone the jebel-quant/rhiza repository to test with -# ------------------------------------------------------------ -TEST_DIR="$(mktemp -d)" -trap 'rm -rf "${TEST_DIR}"' EXIT -echo "Using temp dir: ${TEST_DIR}" - -echo -e "${YELLOW}Cloning tschm/monkeys repository${NC}" -cd "${TEST_DIR}" -git clone --quiet https://github.com/tschm/monkeys.git -cd rhiza +## ------------------------------------------------------------ +## Clone the jebel-quant/rhiza repository to test with +## ------------------------------------------------------------ +#TEST_DIR="$(mktemp -d)" +#trap 'rm -rf "${TEST_DIR}"' EXIT +#echo "Using temp dir: ${TEST_DIR}" + +#echo -e "${YELLOW}Cloning tschm/monkeys repository${NC}" +#cd "${TEST_DIR}" +#git clone --quiet https://github.com/jebel-quant/sync_template.git +#cd sync_template # ------------------------------------------------------------ # Run rhiza commands (mirror what the action does)