|
1 | 1 | name: CI
|
2 |
| - |
3 | 2 | on:
|
4 | 3 | push:
|
5 |
| - branches: [ main ] |
| 4 | + branches: [main] |
6 | 5 | pull_request:
|
7 |
| - branches: [ main ] |
| 6 | + branches: [main] |
8 | 7 |
|
9 | 8 | jobs:
|
10 | 9 | test:
|
11 | 10 | runs-on: ubuntu-latest
|
12 |
| - strategy: |
13 |
| - matrix: |
14 |
| - python-version: [3.8, 3.9, '3.10', '3.11'] |
15 |
| - neovim-version: ['stable', 'nightly'] |
16 |
| - |
17 | 11 | steps:
|
18 |
| - - uses: actions/checkout@v3 |
19 |
| - |
20 |
| - - name: Set up Python ${{ matrix.python-version }} |
21 |
| - uses: actions/setup-python@v4 |
22 |
| - with: |
23 |
| - python-version: ${{ matrix.python-version }} |
24 |
| - |
25 |
| - - name: Install Python dependencies |
26 |
| - run: | |
27 |
| - python -m pip install --upgrade pip |
28 |
| - pip install sqlparse |
29 |
| - pip install vim-vint |
30 |
| - pip install pynvim |
| 12 | + # Check out the repository code |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
31 | 15 |
|
32 |
| - - name: Install Neovim |
33 |
| - run: | |
34 |
| - if [ "${{ matrix.neovim-version }}" = "stable" ]; then |
35 |
| - sudo add-apt-repository -y ppa:neovim-ppa/stable |
36 |
| - else |
37 |
| - sudo add-apt-repository -y ppa:neovim-ppa/unstable |
38 |
| - fi |
39 |
| - sudo apt-get update |
40 |
| - sudo apt-get install -y neovim |
| 16 | + # Set up Python environment |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: '3.x' |
41 | 21 |
|
42 |
| - - name: Check VimScript syntax |
43 |
| - run: | |
44 |
| - vint plugin/ |
45 |
| - vint autoload/ |
| 22 | + # Install sqlparse |
| 23 | + - name: Install sqlparse |
| 24 | + run: pip install sqlparse |
46 | 25 |
|
47 |
| - - name: Run Python tests |
48 |
| - run: | |
49 |
| - python -m unittest discover -s tests |
| 26 | + # Install Neovim with Python3 support |
| 27 | + - name: Install Neovim |
| 28 | + run: | |
| 29 | + sudo apt-get update |
| 30 | + sudo apt-get install -y software-properties-common |
| 31 | + sudo add-apt-repository ppa:neovim-ppa/stable |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install -y neovim |
50 | 34 |
|
51 |
| - - name: Check for Python syntax errors |
52 |
| - run: | |
53 |
| - python -m py_compile python/*.py |
54 |
| -
|
55 |
| - - name: Check for Python type hints |
56 |
| - run: | |
57 |
| - pip install mypy |
58 |
| - mypy python/*.py |
59 |
| -
|
60 |
| - lint: |
61 |
| - runs-on: ubuntu-latest |
62 |
| - steps: |
63 |
| - - uses: actions/checkout@v3 |
| 35 | + # Verify Python3 support in Neovim |
| 36 | + - name: Check Neovim Python3 support |
| 37 | + run: nvim --headless -c "echo has('python3')" -c "q" |
| 38 | + continue-on-error: false |
64 | 39 |
|
65 |
| - - name: Set up Python |
66 |
| - uses: actions/setup-python@v4 |
67 |
| - with: |
68 |
| - python-version: '3.11' |
| 40 | + # Create a test SQL file |
| 41 | + - name: Create test SQL file |
| 42 | + run: | |
| 43 | + mkdir -p test |
| 44 | + echo "select id,name from users where age>18 order by name" > test/test.sql |
69 | 45 |
|
70 |
| - - name: Install dependencies |
71 |
| - run: | |
72 |
| - python -m pip install --upgrade pip |
73 |
| - pip install flake8 |
74 |
| - pip install black |
| 46 | + # Test plugin loading |
| 47 | + - name: Test plugin loading |
| 48 | + run: nvim --headless -c "source plugin/sqlformat.vim" -c "q" |
| 49 | + env: |
| 50 | + PYTHONPATH: ${{ github.workspace }}/python |
75 | 51 |
|
76 |
| - - name: Run flake8 |
77 |
| - run: | |
78 |
| - flake8 python/ --count --select=E9,F63,F7,F82 --show-source --statistics |
| 52 | + # Test SQL formatting |
| 53 | + - name: Test SQL formatting |
| 54 | + run: | |
| 55 | + export PYTHONPATH=${{ github.workspace }}/python |
| 56 | + nvim --headless -c "edit test/test.sql" -c "SQLFormat" -c "w! test/output.sql" -c "q" |
| 57 | + cat test/output.sql |
| 58 | + env: |
| 59 | + PYTHONPATH: ${{ github.workspace }}/python |
79 | 60 |
|
80 |
| - - name: Run black |
81 |
| - run: | |
82 |
| - black --check python/ |
| 61 | + # Verify formatted output |
| 62 | + - name: Verify formatted output |
| 63 | + run: | |
| 64 | + cat test/output.sql |
| 65 | + grep -q "SELECT id, name" test/output.sql |
| 66 | + grep -q "FROM users" test/output.sql |
| 67 | + grep -q "WHERE age > 18" test/output.sql |
| 68 | + grep -q "ORDER BY name" test/output.sql |
0 commit comments