Skip to content

Commit abc1303

Browse files
committed
Update .NET versions in CI to match project targets - Use .NET 8.0.x and 9.0.x to match project TargetFrameworks - Remove hardcoded environment variables for more flexible versioning
1 parent 3b5cdb4 commit abc1303

File tree

1 file changed

+127
-127
lines changed

1 file changed

+127
-127
lines changed

.github/workflows/ci.yml

Lines changed: 127 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -13,149 +13,149 @@ env:
1313
DOTNET_FRAMEWORK_VERSION: '9.0.x'
1414

1515
jobs:
16-
build-and-test:
17-
name: Build and Test
16+
test:
17+
name: Test on ${{ matrix.os }}
1818
runs-on: ${{ matrix.os }}
1919
strategy:
2020
matrix:
2121
os: [ubuntu-latest, windows-latest, macos-latest]
22-
22+
2323
steps:
24-
- name: Checkout code
25-
uses: actions/checkout@v4
26-
with:
27-
fetch-depth: 0
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
2828

29-
- name: Setup .NET
30-
uses: actions/setup-dotnet@v4
31-
with:
32-
dotnet-version: |
33-
${{ env.DOTNET_VERSION }}
34-
${{ env.DOTNET_FRAMEWORK_VERSION }}
29+
- name: Setup .NET
30+
uses: actions/setup-dotnet@v4
31+
with:
32+
dotnet-version: |
33+
8.0.x
34+
9.0.x
3535
36-
- name: Initialize submodules
37-
run: git submodule update --init --recursive
36+
- name: Initialize submodules
37+
run: git submodule update --init --recursive
3838

39-
- name: Build native libraries
40-
run: |
41-
cd libpg_query
42-
make clean
43-
make
44-
cd ..
45-
46-
# Determine platform and create wrapper
47-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
48-
LIBRARY_EXT="so"
49-
TARGET_RID="linux-x64"
50-
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
51-
LIBRARY_EXT="dll"
52-
TARGET_RID="win-x64"
53-
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
54-
LIBRARY_EXT="dylib"
55-
if [[ $(uname -m) == "arm64" ]]; then
56-
TARGET_RID="osx-arm64"
57-
else
58-
TARGET_RID="osx-x64"
39+
- name: Build native libraries
40+
run: |
41+
cd libpg_query
42+
make clean
43+
make
44+
cd ..
45+
46+
# Determine platform and create wrapper
47+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
48+
LIBRARY_EXT="so"
49+
TARGET_RID="linux-x64"
50+
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
51+
LIBRARY_EXT="dll"
52+
TARGET_RID="win-x64"
53+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
54+
LIBRARY_EXT="dylib"
55+
if [[ $(uname -m) == "arm64" ]]; then
56+
TARGET_RID="osx-arm64"
57+
else
58+
TARGET_RID="osx-x64"
59+
fi
60+
fi
61+
62+
# Create wrapper.c if it doesn't exist
63+
if [ ! -f "wrapper.c" ]; then
64+
cat > wrapper.c << 'EOF'
65+
#include "libpg_query/pg_query.h"
66+
67+
// Simple wrapper to export pg_query functions
68+
PgQueryParseResult pg_query_parse_wrapper(const char* input) {
69+
return pg_query_parse(input);
70+
}
71+
72+
void pg_query_free_parse_result_wrapper(PgQueryParseResult result) {
73+
pg_query_free_parse_result(result);
74+
}
75+
76+
PgQueryNormalizeResult pg_query_normalize_wrapper(const char* input) {
77+
return pg_query_normalize(input);
78+
}
79+
80+
void pg_query_free_normalize_result_wrapper(PgQueryNormalizeResult result) {
81+
pg_query_free_normalize_result(result);
82+
}
83+
84+
// Protobuf wrapper functions
85+
PgQueryProtobufParseResult pg_query_parse_protobuf_wrapper(const char* input) {
86+
return pg_query_parse_protobuf(input);
87+
}
88+
89+
void pg_query_free_protobuf_parse_result_wrapper(PgQueryProtobufParseResult result) {
90+
pg_query_free_protobuf_parse_result(result);
91+
}
92+
93+
PgQueryFingerprintResult pg_query_fingerprint_wrapper(const char* input) {
94+
return pg_query_fingerprint(input);
95+
}
96+
97+
void pg_query_free_fingerprint_result_wrapper(PgQueryFingerprintResult result) {
98+
pg_query_free_fingerprint_result(result);
99+
}
100+
101+
PgQueryScanResult pg_query_scan_wrapper(const char* input) {
102+
return pg_query_scan(input);
103+
}
104+
105+
void pg_query_free_scan_result_wrapper(PgQueryScanResult result) {
106+
pg_query_free_scan_result(result);
107+
}
108+
EOF
109+
fi
110+
111+
# Compile wrapper
112+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
113+
gcc -shared -fPIC -I. -o "libpgquery_wrapper.so" wrapper.c libpg_query/libpg_query.a
114+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
115+
gcc -shared -fPIC -I. -o "libpgquery_wrapper.dylib" wrapper.c libpg_query/libpg_query.a
116+
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
117+
# Windows builds would need different compilation - skip for now
118+
echo "Windows native build not implemented yet"
119+
fi
120+
121+
# Copy to runtime directories
122+
mkdir -p "src/PgQuery.NET/runtimes/$TARGET_RID/native"
123+
if [ -f "libpgquery_wrapper.$LIBRARY_EXT" ]; then
124+
cp "libpgquery_wrapper.$LIBRARY_EXT" "src/PgQuery.NET/runtimes/$TARGET_RID/native/"
59125
fi
60-
fi
61-
62-
# Create wrapper.c if it doesn't exist
63-
if [ ! -f "wrapper.c" ]; then
64-
cat > wrapper.c << 'EOF'
65-
#include "libpg_query/pg_query.h"
66-
67-
// Simple wrapper to export pg_query functions
68-
PgQueryParseResult pg_query_parse_wrapper(const char* input) {
69-
return pg_query_parse(input);
70-
}
71-
72-
void pg_query_free_parse_result_wrapper(PgQueryParseResult result) {
73-
pg_query_free_parse_result(result);
74-
}
75-
76-
PgQueryNormalizeResult pg_query_normalize_wrapper(const char* input) {
77-
return pg_query_normalize(input);
78-
}
79-
80-
void pg_query_free_normalize_result_wrapper(PgQueryNormalizeResult result) {
81-
pg_query_free_normalize_result(result);
82-
}
83-
84-
// Protobuf wrapper functions
85-
PgQueryProtobufParseResult pg_query_parse_protobuf_wrapper(const char* input) {
86-
return pg_query_parse_protobuf(input);
87-
}
88-
89-
void pg_query_free_protobuf_parse_result_wrapper(PgQueryProtobufParseResult result) {
90-
pg_query_free_protobuf_parse_result(result);
91-
}
92-
93-
PgQueryFingerprintResult pg_query_fingerprint_wrapper(const char* input) {
94-
return pg_query_fingerprint(input);
95-
}
96-
97-
void pg_query_free_fingerprint_result_wrapper(PgQueryFingerprintResult result) {
98-
pg_query_free_fingerprint_result(result);
99-
}
100-
101-
PgQueryScanResult pg_query_scan_wrapper(const char* input) {
102-
return pg_query_scan(input);
103-
}
104-
105-
void pg_query_free_scan_result_wrapper(PgQueryScanResult result) {
106-
pg_query_free_scan_result(result);
107-
}
108-
EOF
109-
fi
110-
111-
# Compile wrapper
112-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
113-
gcc -shared -fPIC -I. -o "libpgquery_wrapper.so" wrapper.c libpg_query/libpg_query.a
114-
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
115-
gcc -shared -fPIC -I. -o "libpgquery_wrapper.dylib" wrapper.c libpg_query/libpg_query.a
116-
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
117-
# Windows builds would need different compilation - skip for now
118-
echo "Windows native build not implemented yet"
119-
fi
120-
121-
# Copy to runtime directories
122-
mkdir -p "src/PgQuery.NET/runtimes/$TARGET_RID/native"
123-
if [ -f "libpgquery_wrapper.$LIBRARY_EXT" ]; then
124-
cp "libpgquery_wrapper.$LIBRARY_EXT" "src/PgQuery.NET/runtimes/$TARGET_RID/native/"
125-
fi
126126
127-
- name: Restore dependencies
128-
run: dotnet restore
127+
- name: Restore dependencies
128+
run: dotnet restore
129129

130-
- name: Build solution
131-
run: dotnet build --configuration Release --no-restore
130+
- name: Build solution
131+
run: dotnet build --configuration Release --no-restore
132132

133-
- name: Run tests
134-
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
133+
- name: Run tests
134+
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
135135

136-
- name: Upload coverage reports
137-
if: matrix.os == 'ubuntu-latest'
138-
uses: codecov/codecov-action@v3
139-
with:
140-
files: '**/coverage.cobertura.xml'
141-
fail_ci_if_error: false
136+
- name: Upload coverage reports
137+
if: matrix.os == 'ubuntu-latest'
138+
uses: codecov/codecov-action@v3
139+
with:
140+
files: '**/coverage.cobertura.xml'
141+
fail_ci_if_error: false
142142

143-
- name: Test GrepSQL CLI
144-
shell: bash
145-
run: |
146-
# Test basic functionality
147-
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "SelectStmt" --from-sql "SELECT id FROM users" --count
148-
149-
# Test s-expression patterns
150-
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "(relname \"users\")" --from-sql "SELECT * FROM users" --count
151-
152-
# Test highlighting
153-
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "(relname \"users\")" --from-sql "SELECT * FROM users" --highlight --highlight-style html
143+
- name: Test GrepSQL CLI
144+
shell: bash
145+
run: |
146+
# Test basic functionality
147+
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "SelectStmt" --from-sql "SELECT id FROM users" --count
148+
149+
# Test s-expression patterns
150+
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "(relname \"users\")" --from-sql "SELECT * FROM users" --count
151+
152+
# Test highlighting
153+
dotnet run --project src/GrepSQL/GrepSQL --configuration Release -- -p "(relname \"users\")" --from-sql "SELECT * FROM users" --highlight --highlight-style html
154154
155155
package:
156156
name: Create NuGet Package
157157
runs-on: ubuntu-latest
158-
needs: build-and-test
158+
needs: test
159159
if: github.event_name == 'release'
160160

161161
steps:
@@ -193,7 +193,7 @@ jobs:
193193
release-binaries:
194194
name: Create Release Binaries
195195
runs-on: ubuntu-latest
196-
needs: build-and-test
196+
needs: test
197197
if: github.event_name == 'release'
198198
strategy:
199199
matrix:
@@ -241,7 +241,7 @@ jobs:
241241
benchmark:
242242
name: Performance Benchmarks
243243
runs-on: ubuntu-latest
244-
needs: build-and-test
244+
needs: test
245245
if: github.ref == 'refs/heads/main'
246246

247247
steps:

0 commit comments

Comments
 (0)