Skip to content

refactor(zsh): reorder env completions and loaders #75

refactor(zsh): reorder env completions and loaders

refactor(zsh): reorder env completions and loaders #75

name: Scripts Functionality Check
on:
push:
branches: [main, develop]
paths:
- "scripts/**"
- ".github/workflows/scripts-functionality.yml"
pull_request:
branches: [main, develop]
paths:
- "scripts/**"
jobs:
scripts-execution-check:
runs-on: ubuntu-latest
name: Scripts Execution Test
permissions:
issues: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test script execution
id: exec-test
run: |
echo "Testing script structure and dependencies..."
failed_scripts=""
# Test lib scripts (source them for syntax checking - skip installation scripts)
echo "Testing lib scripts (syntax check)..."
# Skip scripts that have side effects (installations)
skip_patterns="go_tools|python_tools|packages|plugins|wallpapers"
for script in $(find scripts/lib -type f -name "*.sh"); do
basename=$(basename "$script")
# Skip installation scripts
if echo "$basename" | grep -qE "$skip_patterns"; then
echo " Skipping (installation): $script"
continue
fi
echo " Testing: $script"
if ! bash -c "source $script" 2>&1; then
failed_scripts="$failed_scripts$script (sourcing failed)\n"
fi
done
# Test main scripts for syntax (don't execute)
echo "Testing main scripts (syntax check)..."
for script in $(find scripts -maxdepth 1 -type f -name "*.sh"); do
echo " Testing: $script"
if ! bash -n "$script" 2>&1; then
failed_scripts="$failed_scripts$script (syntax error)\n"
fi
done
# Test utils scripts (source them for syntax)
echo "Testing utils scripts (syntax check)..."
for script in $(find scripts/utils -type f -name "*.sh" 2>/dev/null); do
echo " Testing: $script"
if ! bash -c "source $script" 2>&1; then
failed_scripts="$failed_scripts$script (sourcing failed)\n"
fi
done
if [ -n "$failed_scripts" ]; then
echo "FAILED_SCRIPTS<<EOF" >> $GITHUB_OUTPUT
echo -e "$failed_scripts" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
echo "All scripts passed structure and syntax checks!"
- name: Create issue on execution failure
if: failure() && github.event_name == 'push'
uses: actions/github-script@v7
with:
script: |
const failedScripts = `${{ steps.exec-test.outputs.FAILED_SCRIPTS }}`;
const title = `[Scripts] Execution Failure`;
const body = `## Scripts Execution Test Failure\n\n**Failed Scripts:**\n${failedScripts}\n\nPlease fix the scripts listed above.\n\n**Workflow Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: ['scripts-execution-error']
});
if (issues.data.length === 0) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['scripts-execution-error', 'scripts-check']
});
} else {
// Update existing issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issues.data[0].number,
body: body
});
}
close-issues:
runs-on: ubuntu-latest
name: Close Issues on Success
needs: [scripts-execution-check]
if: success() && github.event_name == 'push'
permissions:
issues: write
contents: read
steps:
- name: Close scripts-check issues
uses: actions/github-script@v7
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: ['scripts-check']
});
for (const issue of issues.data) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: '✅ All scripts passed execution test! Closing this issue.\n\n**Workflow Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
});
}