Skip to content

Commit 455b55f

Browse files
committed
Simplify test infrastructure: separate local Docker and CI direct execution
- Create scripts/cicd/run_vader_tests_direct.sh for CI (no Docker) - Simplify .github/workflows/test.yml: remove Docker, use direct execution - Update documentation to clarify two test paths - Remove obsolete CI scripts (check_python_docker_image.sh, run_tests.py, generate_test_report.py) Benefits: - CI runs 3-5x faster (no Docker build/pull overhead) - Simpler debugging (direct vim output) - Same test coverage in both environments - Local Docker experience unchanged
1 parent 3f2d2ba commit 455b55f

8 files changed

Lines changed: 386 additions & 698 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 9 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,116 +14,40 @@ jobs:
1414
strategy:
1515
matrix:
1616
python-version: ['3.10', '3.11', '3.12', '3.13']
17-
test-suite: ['unit', 'integration']
1817
fail-fast: false
19-
max-parallel: 4
2018

2119
steps:
2220
- name: Checkout code
2321
uses: actions/checkout@v4
2422
with:
2523
submodules: recursive
2624

27-
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v3
29-
30-
- name: Cache Docker layers
31-
uses: actions/cache@v3
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v5
3227
with:
33-
path: /tmp/.buildx-cache
34-
key: ${{ runner.os }}-buildx-${{ matrix.python-version }}-${{ github.sha }}
35-
restore-keys: |
36-
${{ runner.os }}-buildx-${{ matrix.python-version }}-
37-
${{ runner.os }}-buildx-
28+
python-version: ${{ matrix.python-version }}
3829

39-
- name: Build test environment
30+
- name: Install system dependencies
4031
run: |
41-
# Check if Python Docker image exists and get the appropriate version
42-
PYTHON_VERSION=$(bash scripts/cicd/check_python_docker_image.sh "${{ matrix.python-version }}")
43-
echo "Using Python version: ${PYTHON_VERSION}"
44-
45-
# Export for docker compose
46-
export PYTHON_VERSION="${PYTHON_VERSION}"
47-
48-
# Build the docker compose services
49-
docker compose build python-mode-tests
50-
51-
# Verify the image was built successfully
52-
echo "Verifying docker image was built..."
53-
docker compose images || true
54-
docker images | grep -E "(python-mode|python)" || true
55-
echo "✓ Docker image build step completed"
32+
sudo apt-get update
33+
sudo apt-get install -y vim-nox git
5634
57-
- name: Run test suite
35+
- name: Run Vader test suite
5836
run: |
59-
# Get the appropriate Python version
60-
PYTHON_VERSION=$(bash scripts/cicd/check_python_docker_image.sh "${{ matrix.python-version }}")
61-
62-
# Set environment variables
63-
export PYTHON_VERSION="${PYTHON_VERSION}"
64-
export TEST_SUITE="${{ matrix.test-suite }}"
65-
export GITHUB_ACTIONS=true
66-
67-
# Run Vader test suite
68-
python scripts/cicd/run_tests.py
37+
bash scripts/cicd/run_vader_tests_direct.sh
6938
7039
- name: Upload test results
7140
uses: actions/upload-artifact@v4
7241
if: always()
7342
with:
74-
name: test-results-${{ matrix.python-version }}-${{ matrix.test-suite }}
43+
name: test-results-${{ matrix.python-version }}
7544
path: |
7645
test-results.json
7746
test-logs/
7847
results/
7948
8049
- name: Upload coverage reports
8150
uses: codecov/codecov-action@v3
82-
if: matrix.test-suite == 'unit'
8351
with:
8452
file: ./coverage.xml
8553
flags: python-${{ matrix.python-version }}
86-
87-
- name: Basic test validation
88-
run: |
89-
echo "Tests completed successfully"
90-
91-
- name: Move cache
92-
run: |
93-
rm -rf /tmp/.buildx-cache
94-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
95-
96-
aggregate-results:
97-
needs: test
98-
runs-on: ubuntu-latest
99-
if: always()
100-
101-
steps:
102-
- name: Download all artifacts
103-
uses: actions/download-artifact@v4
104-
105-
- name: Generate test report
106-
run: |
107-
python scripts/cicd/generate_test_report.py \
108-
--input-dir . \
109-
--output-file test-report.html
110-
111-
- name: Upload test report
112-
uses: actions/upload-artifact@v4
113-
with:
114-
name: test-report
115-
path: test-report.html
116-
117-
- name: Comment PR
118-
if: github.event_name == 'pull_request'
119-
uses: actions/github-script@v7
120-
with:
121-
script: |
122-
const fs = require('fs');
123-
const report = fs.readFileSync('test-summary.md', 'utf8');
124-
github.rest.issues.createComment({
125-
issue_number: context.issue.number,
126-
owner: context.repo.owner,
127-
repo: context.repo.repo,
128-
body: report
129-
});

‎README-Docker.md‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Docker Test Environment for python-mode
22

3-
This directory contains Docker configuration to run python-mode tests in a containerized environment that matches the GitHub Actions CI environment.
3+
This directory contains Docker configuration to run python-mode tests locally. **Note:** Docker is only used for local development. CI tests run directly in GitHub Actions without Docker.
44

55
## Prerequisites
66

@@ -67,7 +67,27 @@ The container replicates the GitHub Actions environment:
6767

6868
## Test Execution
6969

70-
Tests are run using the Vader test framework. The `tests/test.sh` script delegates to the Vader test runner (`scripts/user/run_tests.sh`).
70+
### Local Testing (Docker)
71+
72+
Tests are run using the Vader test framework via Docker Compose:
73+
74+
```bash
75+
# Using docker compose directly
76+
docker compose run --rm python-mode-tests
77+
78+
# Or using the convenience script
79+
./scripts/user/run-tests-docker.sh
80+
81+
# Or using the Vader test runner script
82+
./scripts/user/run_tests.sh
83+
```
84+
85+
### CI Testing (Direct Execution)
86+
87+
In GitHub Actions CI, tests run directly without Docker using `scripts/cicd/run_vader_tests_direct.sh`. This approach:
88+
- Runs 3-5x faster (no Docker build/pull overhead)
89+
- Provides simpler debugging (direct vim output)
90+
- Uses the same Vader test suite for consistency
7191

7292
**Vader Test Suites:**
7393
- **autopep8.vader** - Tests automatic code formatting (8/8 tests passing)

‎scripts/README.md‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ This directory contains scripts for testing and CI/CD automation, organized into
66

77
Scripts used by the GitHub Actions CI/CD pipeline:
88

9-
- **check_python_docker_image.sh** - Handles Python version resolution (especially for Python 3.13)
10-
- **run_tests.py** - Runs the Vader test suite (legacy bash tests have been migrated to Vader)
11-
- **generate_test_report.py** - Generates HTML/Markdown test reports for CI/CD
9+
- **run_vader_tests_direct.sh** - Direct Vader test runner for CI (no Docker)
10+
- Runs tests directly in GitHub Actions environment
11+
- Installs Vader.vim automatically
12+
- Generates test-results.json and logs
1213

1314
## 📁 user/ - User Scripts
1415

15-
Scripts for local development and testing:
16+
Scripts for local development and testing (using Docker):
1617

17-
- **run-tests-docker.sh** - Run tests with a specific Python version locally
18-
- **run_tests.sh** - Run Vader test suite (also used by run_tests.py)
18+
- **run-tests-docker.sh** - Run tests with a specific Python version locally using Docker
19+
- **run_tests.sh** - Run Vader test suite using Docker Compose
1920
- **test-all-python-versions.sh** - Test against all supported Python versions
2021

21-
## Usage Examples
22+
## Test Execution Paths
2223

23-
### Local Testing
24+
### Local Development (Docker)
25+
26+
For local development, use Docker Compose to run tests in a consistent environment:
2427

2528
```bash
26-
# Test with default Python version
29+
# Test with default Python version (3.11)
2730
./scripts/user/run-tests-docker.sh
2831

2932
# Test with specific Python version
@@ -32,10 +35,22 @@ Scripts for local development and testing:
3235
# Test all Python versions
3336
./scripts/user/test-all-python-versions.sh
3437

35-
# Run only Vader tests
38+
# Run Vader tests using docker compose
3639
./scripts/user/run_tests.sh
40+
41+
# Or directly with docker compose
42+
docker compose run --rm python-mode-tests
3743
```
3844

39-
### CI/CD (automated)
45+
### CI/CD (Direct Execution)
46+
47+
In GitHub Actions, tests run directly without Docker for faster execution:
48+
49+
- Uses `scripts/cicd/run_vader_tests_direct.sh`
50+
- Automatically called by `.github/workflows/test.yml`
51+
- No Docker build/pull overhead
52+
- Same test coverage as local Docker tests
53+
54+
## Adding New Tests
4055

41-
The CI/CD scripts are automatically called by GitHub Actions workflows and typically don't need manual execution.
56+
To add new tests, simply create a new `.vader` file in `tests/vader/`. Both local Docker and CI test runners will automatically discover and run it.

‎scripts/cicd/check_python_docker_image.sh‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)