Skip to content

Commit b0be524

Browse files
committed
implemented
1 parent 473871d commit b0be524

File tree

16 files changed

+44467
-0
lines changed

16 files changed

+44467
-0
lines changed

.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2022,
6+
"sourceType": "module"
7+
},
8+
"rules": {
9+
"@typescript-eslint/no-explicit-any": "off",
10+
"@typescript-eslint/no-non-null-assertion": "off",
11+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
12+
},
13+
"env": {
14+
"node": true,
15+
"es2022": true
16+
}
17+
}

.github/workflows/ci.yaml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '24'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Run linter
27+
run: npm run lint
28+
29+
- name: Check formatting
30+
run: npm run format-check
31+
32+
- name: Build TypeScript
33+
run: npm run build
34+
35+
- name: Package action
36+
run: npm run package
37+
38+
- name: Check if dist is up to date
39+
run: |
40+
if [[ -n $(git status --porcelain) ]]; then
41+
echo "dist folder is not up to date. Please run 'npm run package' and commit the changes."
42+
git diff
43+
exit 1
44+
fi
45+
46+
test-action:
47+
runs-on: ubuntu-latest
48+
49+
services:
50+
postgres:
51+
image: postgres:17
52+
env:
53+
POSTGRES_USER: postgres
54+
POSTGRES_PASSWORD: postgres
55+
POSTGRES_DB: testdb
56+
options: >-
57+
--health-cmd pg_isready
58+
--health-interval 10s
59+
--health-timeout 5s
60+
--health-retries 5
61+
ports:
62+
- 5432:5432
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Create test schema file
69+
run: |
70+
cat > schema.sql <<EOF
71+
CREATE TABLE IF NOT EXISTS users (
72+
id SERIAL PRIMARY KEY,
73+
username VARCHAR(50) UNIQUE NOT NULL,
74+
email VARCHAR(100) UNIQUE NOT NULL,
75+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
76+
);
77+
78+
CREATE TABLE IF NOT EXISTS posts (
79+
id SERIAL PRIMARY KEY,
80+
user_id INTEGER REFERENCES users(id),
81+
title VARCHAR(200) NOT NULL,
82+
content TEXT,
83+
published_at TIMESTAMP,
84+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
85+
);
86+
87+
CREATE INDEX IF NOT EXISTS idx_posts_user_id ON posts(user_id);
88+
CREATE INDEX IF NOT EXISTS idx_posts_published_at ON posts(published_at);
89+
EOF
90+
91+
- name: Test PostgreSQL action (dry-run)
92+
uses: ./
93+
with:
94+
command: psqldef
95+
sqldef-version: v0.17.24
96+
schema-file: schema.sql
97+
pg-user: postgres
98+
pg-password: postgres
99+
pg-host: localhost
100+
pg-port: 5432
101+
pg-database: testdb
102+
103+
test-mysql:
104+
runs-on: ubuntu-latest
105+
106+
services:
107+
mysql:
108+
image: mysql:8.0
109+
env:
110+
MYSQL_ROOT_PASSWORD: root
111+
MYSQL_DATABASE: testdb
112+
options: >-
113+
--health-cmd="mysqladmin ping"
114+
--health-interval=10s
115+
--health-timeout=5s
116+
--health-retries=5
117+
ports:
118+
- 3306:3306
119+
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v4
123+
124+
- name: Create MySQL test schema file
125+
run: |
126+
cat > schema.sql <<EOF
127+
CREATE TABLE IF NOT EXISTS users (
128+
id INT AUTO_INCREMENT PRIMARY KEY,
129+
username VARCHAR(50) UNIQUE NOT NULL,
130+
email VARCHAR(100) UNIQUE NOT NULL,
131+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
132+
);
133+
134+
CREATE TABLE IF NOT EXISTS posts (
135+
id INT AUTO_INCREMENT PRIMARY KEY,
136+
user_id INT,
137+
title VARCHAR(200) NOT NULL,
138+
content TEXT,
139+
published_at TIMESTAMP NULL,
140+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
141+
FOREIGN KEY (user_id) REFERENCES users(id),
142+
INDEX idx_posts_user_id (user_id),
143+
INDEX idx_posts_published_at (published_at)
144+
);
145+
EOF
146+
147+
- name: Test MySQL action
148+
uses: ./
149+
with:
150+
command: mysqldef
151+
sqldef-version: v0.17.24
152+
schema-file: schema.sql
153+
mysql-user: root
154+
mysql-password: root
155+
mysql-host: 127.0.0.1
156+
mysql-port: 3306
157+
mysql-database: testdb
158+
159+
test-sqlite:
160+
runs-on: ubuntu-latest
161+
162+
steps:
163+
- name: Checkout code
164+
uses: actions/checkout@v4
165+
166+
- name: Create SQLite test schema file
167+
run: |
168+
cat > schema.sql <<EOF
169+
CREATE TABLE IF NOT EXISTS users (
170+
id INTEGER PRIMARY KEY AUTOINCREMENT,
171+
username TEXT UNIQUE NOT NULL,
172+
email TEXT UNIQUE NOT NULL,
173+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
174+
);
175+
176+
CREATE TABLE IF NOT EXISTS posts (
177+
id INTEGER PRIMARY KEY AUTOINCREMENT,
178+
user_id INTEGER REFERENCES users(id),
179+
title TEXT NOT NULL,
180+
content TEXT,
181+
published_at TIMESTAMP,
182+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
183+
);
184+
185+
CREATE INDEX IF NOT EXISTS idx_posts_user_id ON posts(user_id);
186+
CREATE INDEX IF NOT EXISTS idx_posts_published_at ON posts(published_at);
187+
EOF
188+
189+
- name: Test SQLite action
190+
uses: ./
191+
with:
192+
command: sqlite3def
193+
sqldef-version: v0.17.24
194+
schema-file: schema.sql
195+
sqlite-database: test.db
196+
197+
test-all-platforms:
198+
strategy:
199+
matrix:
200+
os: [ubuntu-latest, windows-latest, macos-latest]
201+
202+
runs-on: ${{ matrix.os }}
203+
204+
steps:
205+
- name: Checkout code
206+
uses: actions/checkout@v4
207+
208+
- name: Create test schema file
209+
shell: bash
210+
run: |
211+
cat > schema.sql <<EOF
212+
CREATE TABLE IF NOT EXISTS test_table (
213+
id INTEGER PRIMARY KEY,
214+
name TEXT NOT NULL
215+
);
216+
EOF
217+
218+
- name: Test SQLite action on ${{ matrix.os }}
219+
uses: ./
220+
with:
221+
command: sqlite3def
222+
sqldef-version: v0.17.24
223+
schema-file: schema.sql
224+
sqlite-database: test.db

.github/workflows/example.yaml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: SQLDef Preview Example
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'schema.sql'
7+
8+
jobs:
9+
postgresql-preview:
10+
runs-on: ubuntu-latest
11+
12+
services:
13+
postgres:
14+
image: postgres:16
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: testdb
19+
options: >-
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
ports:
25+
- 5432:5432
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Preview PostgreSQL schema changes
34+
uses: gfx/sqldef-preview-action@main
35+
with:
36+
command: psqldef
37+
sqldef-version: v0.17.24
38+
schema-file: schema.sql
39+
pg-user: postgres
40+
pg-password: postgres
41+
pg-host: localhost
42+
pg-port: 5432
43+
pg-database: testdb
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
46+
mysql-preview:
47+
runs-on: ubuntu-latest
48+
49+
services:
50+
mysql:
51+
image: mysql:8.0
52+
env:
53+
MYSQL_ROOT_PASSWORD: root
54+
MYSQL_DATABASE: testdb
55+
options: >-
56+
--health-cmd="mysqladmin ping"
57+
--health-interval=10s
58+
--health-timeout=5s
59+
--health-retries=5
60+
ports:
61+
- 3306:3306
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Preview MySQL schema changes
70+
uses: gfx/sqldef-preview-action@main
71+
with:
72+
command: mysqldef
73+
sqldef-version: v0.17.24
74+
schema-file: schema.sql
75+
mysql-user: root
76+
mysql-password: root
77+
mysql-host: localhost
78+
mysql-port: 3306
79+
mysql-database: testdb
80+
github-token: ${{ secrets.GITHUB_TOKEN }}
81+
82+
sqlite-preview:
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
91+
- name: Preview SQLite schema changes
92+
uses: gfx/sqldef-preview-action@main
93+
with:
94+
command: sqlite3def
95+
sqldef-version: v0.17.24
96+
schema-file: schema.sql
97+
sqlite-database: test.db
98+
github-token: ${{ secrets.GITHUB_TOKEN }}
99+
100+
mssql-preview:
101+
runs-on: ubuntu-latest
102+
103+
services:
104+
sqlserver:
105+
image: mcr.microsoft.com/mssql/server:2022-latest
106+
env:
107+
ACCEPT_EULA: Y
108+
SA_PASSWORD: YourStrong@Passw0rd
109+
MSSQL_PID: Developer
110+
options: >-
111+
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' -Q 'SELECT 1'"
112+
--health-interval 10s
113+
--health-timeout 5s
114+
--health-retries 10
115+
ports:
116+
- 1433:1433
117+
118+
steps:
119+
- name: Checkout code
120+
uses: actions/checkout@v4
121+
with:
122+
fetch-depth: 0
123+
124+
- name: Wait for SQL Server
125+
run: |
126+
for i in {1..30}; do
127+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' -Q 'SELECT 1' && break
128+
echo "Waiting for SQL Server..."
129+
sleep 2
130+
done
131+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' -Q "CREATE DATABASE testdb"
132+
133+
- name: Preview MSSQL schema changes
134+
uses: gfx/sqldef-preview-action@main
135+
with:
136+
command: mssqldef
137+
sqldef-version: v0.17.24
138+
schema-file: schema.sql
139+
mssql-user: sa
140+
mssql-password: YourStrong@Passw0rd
141+
mssql-host: localhost
142+
mssql-port: 1433
143+
mssql-database: testdb
144+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
build/
3+
*.log
4+
.DS_Store
5+
coverage/
6+

0 commit comments

Comments
 (0)