Optimized git
Some checks failed
Some checks failed
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
name: CI Pipeline
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
shasums:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run shasums script
|
||||
run: |
|
||||
cp -rv ./hyperterm/ "$HOME/.hyperterm/"
|
||||
@@ -79,6 +84,11 @@ jobs:
|
||||
shellcheck hyperterm/tools/sysinfo.sh
|
||||
shellcheck hyperterm/tools/virtualenv.sh
|
||||
|
||||
- name: Run shellcheck on test scripts
|
||||
run: |
|
||||
shellcheck tests/test_prompt.sh
|
||||
shellcheck tests/quick_test.sh
|
||||
|
||||
- name: Run shellcheck on install script
|
||||
run: shellcheck install.sh
|
||||
|
||||
@@ -90,3 +100,138 @@ jobs:
|
||||
|
||||
- name: Run uninstall script
|
||||
run: bash -x uninstall.sh -s
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
CI: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up git configuration for tests
|
||||
run: |
|
||||
git config --global user.name "CI Test User"
|
||||
git config --global user.email "ci-test@example.com"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y git bash
|
||||
|
||||
- name: Run quick prompt test
|
||||
run: |
|
||||
echo "INFO: Running quick prompt test"
|
||||
bash tests/quick_test.sh
|
||||
|
||||
- name: Run comprehensive prompt test
|
||||
run: |
|
||||
echo "INFO: Running comprehensive prompt test"
|
||||
# Run in non-interactive mode for CI
|
||||
bash tests/test_prompt.sh --non-interactive
|
||||
|
||||
- name: Test prompt performance
|
||||
run: |
|
||||
echo "INFO: Testing prompt performance in git repository"
|
||||
# Create test changes to verify git status detection
|
||||
echo "test change" >> README.md
|
||||
echo "untracked file" > test_file.txt
|
||||
|
||||
# Source the hyperterm functions
|
||||
source hyperterm/core/colors.sh
|
||||
source hyperterm/core/git.sh
|
||||
|
||||
# Test prompt generation
|
||||
echo "Testing prompt generation..."
|
||||
__prompt_git
|
||||
echo ""
|
||||
echo "SUCCESS: Prompt generation completed"
|
||||
|
||||
- name: Validate optimizations
|
||||
run: |
|
||||
echo "INFO: Validating optimizations"
|
||||
|
||||
# Check that git_optimized.sh doesn't exist (should be integrated into git.sh)
|
||||
if [[ -f "hyperterm/core/git_optimized.sh" ]]; then
|
||||
echo "ERROR: git_optimized.sh should not exist (should be integrated)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check that git.sh exists and is optimized
|
||||
if [[ ! -f "hyperterm/core/git.sh" ]]; then
|
||||
echo "ERROR: git.sh not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify the optimized functions exist
|
||||
source hyperterm/core/git.sh
|
||||
if ! command -v _get_git_status_fast >/dev/null 2>&1; then
|
||||
echo "ERROR: Optimized function _get_git_status_fast not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "SUCCESS: Optimizations validated"
|
||||
|
||||
performance:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up git configuration
|
||||
run: |
|
||||
git config --global user.name "Performance Test"
|
||||
git config --global user.email "perf-test@example.com"
|
||||
|
||||
- name: Performance benchmark
|
||||
run: |
|
||||
echo "INFO: Running performance benchmark"
|
||||
|
||||
# Create a test repository with various states
|
||||
mkdir -p /tmp/perf_test
|
||||
cd /tmp/perf_test
|
||||
git init
|
||||
git config user.name "Test User"
|
||||
git config user.email "test@example.com"
|
||||
|
||||
# Create initial commit
|
||||
echo "# Performance Test" > README.md
|
||||
git add README.md
|
||||
git commit -m "Initial commit"
|
||||
|
||||
# Create various git states
|
||||
echo "modified content" >> README.md
|
||||
echo "untracked file" > untracked.txt
|
||||
echo "staged file" > staged.txt
|
||||
git add staged.txt
|
||||
|
||||
# Source hyperterm functions
|
||||
cd "$GITEA_WORKSPACE"
|
||||
source hyperterm/core/colors.sh
|
||||
source hyperterm/core/git.sh
|
||||
|
||||
# Run performance test
|
||||
cd /tmp/perf_test
|
||||
|
||||
echo "Running 50 iterations of prompt generation..."
|
||||
start_time=$(date +%s%N)
|
||||
for i in {1..50}; do
|
||||
__prompt_git >/dev/null 2>&1
|
||||
done
|
||||
end_time=$(date +%s%N)
|
||||
|
||||
duration=$(( (end_time - start_time) / 1000000 ))
|
||||
avg_duration=$(( duration / 50 ))
|
||||
|
||||
echo "Performance Results:"
|
||||
echo " Total time: ${duration}ms"
|
||||
echo " Average per call: ${avg_duration}ms"
|
||||
echo " Iterations: 50"
|
||||
|
||||
# Performance validation
|
||||
if [[ $avg_duration -lt 100 ]]; then
|
||||
echo "SUCCESS: Performance is good (${avg_duration}ms < 100ms)"
|
||||
else
|
||||
echo "WARNING: Performance may need optimization (${avg_duration}ms >= 100ms)"
|
||||
# Don't fail the build, just warn
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user