Skip to content

Commit c626dd3

Browse files
committed
ci: test setup
1 parent 504f675 commit c626dd3

File tree

1 file changed

+18
-84
lines changed

1 file changed

+18
-84
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,36 @@
1-
name: SQL Formatter CI
1+
name: CI
22

33
on:
44
push:
5-
branches: [main, develop]
5+
branches: [main]
66
pull_request:
77
branches: [main]
88

99
jobs:
10-
test:
10+
build:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
nvim-version: ["0.8.0", "0.9.0"]
15-
sql-dialect: ["postgresql", "mysql", "sqlite"]
1612

1713
steps:
18-
- uses: actions/checkout@v3
19-
20-
- name: Setup Neovim
21-
run: |
22-
curl -LO https://github.com/neovim/neovim/releases/download/v${{ matrix.nvim-version }}/nvim-linux64.tar.gz
23-
tar xzf nvim-linux64.tar.gz
24-
sudo mv nvim-linux64/bin/nvim /usr/local/bin/
25-
sudo mv nvim-linux64/lib/nvim /usr/local/lib/
26-
sudo mv nvim-linux64/share/nvim /usr/local/share/
27-
nvim --version
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
2816

29-
- name: Setup Python
30-
uses: actions/setup-python@v4
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
3119
with:
32-
python-version: "3.x"
20+
node-version: "18"
3321

3422
- name: Install dependencies
35-
run: |
36-
# Install sqlparse
37-
pip install sqlparse
38-
39-
# Install LuaJIT and LuaRocks
40-
sudo apt-get update
41-
sudo apt-get install -y luajit luarocks
42-
sudo luarocks install luacheck
43-
44-
# Install stylua for formatting
45-
cargo install stylua
46-
47-
- name: Lint Lua code
48-
run: |
49-
luacheck lua/ --globals vim --no-color
50-
stylua --check lua/
51-
52-
- name: Test plugin loading
53-
run: |
54-
nvim --headless -c "lua require('sql-formatter').setup({dialect = '${{ matrix.sql-dialect }}'})" -c "qa!"
55-
56-
- name: Test SQL formatting
57-
run: |
58-
# Test basic SQL formatting
59-
echo "SELECT * FROM users WHERE active=1;" | sqlformat --reindent --keywords upper --identifiers lower -
60-
61-
# Test complex SQL formatting
62-
echo "WITH RECURSIVE cte AS (SELECT id, name, parent_id FROM categories WHERE parent_id IS NULL UNION ALL SELECT c.id, c.name, c.parent_id FROM categories c INNER JOIN cte ON c.parent_id = cte.id) SELECT * FROM cte;" | sqlformat --reindent --keywords upper --identifiers lower -
23+
run: npm ci
6324

64-
- name: Test file type detection
65-
run: |
66-
# Create test SQL files
67-
echo "SELECT * FROM test;" > test.sql
68-
echo "SELECT * FROM test;" > test.mysql
69-
echo "SELECT * FROM test;" > test.pgsql
70-
71-
# Test formatting for each file type
72-
for file in test.*; do
73-
nvim --headless -c "e $file" -c "lua require('sql-formatter').setup({dialect = '${{ matrix.sql-dialect }}'})" -c "wq"
74-
done
75-
76-
release:
77-
needs: test
78-
runs-on: ubuntu-latest
79-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
80-
81-
steps:
82-
- uses: actions/checkout@v3
83-
with:
84-
fetch-depth: 0
25+
- name: Run tests
26+
run: npm test
8527

86-
- name: Generate changelog
87-
id: changelog
88-
run: |
89-
echo "## Changes" > CHANGELOG.tmp
90-
git log --oneline --since="$(git describe --tags --abbrev=0 2>/dev/null || echo '1970-01-01')" >> CHANGELOG.tmp
28+
- name: Build project
29+
run: npm run build
9130

92-
- name: Create Release
93-
uses: actions/create-release@v1
94-
if: contains(github.event.head_commit.message, '[release]')
95-
env:
96-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Deploy to GitHub Pages
32+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
33+
uses: peaceiris/actions-gh-pages@v3
9734
with:
98-
tag_name: v${{ github.run_number }}
99-
release_name: Release v${{ github.run_number }}
100-
body_path: CHANGELOG.tmp
101-
draft: false
102-
prerelease: false
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
publish_dir: ./dist

0 commit comments

Comments
 (0)