-
Notifications
You must be signed in to change notification settings - Fork 11
91 lines (75 loc) · 2.74 KB
/
docker.yml
File metadata and controls
91 lines (75 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Docker
on:
workflow_dispatch:
workflow_run:
workflows: ["Publish to PyPI"]
types: [completed]
env:
IMAGE: sidequery/sidemantic
jobs:
docker:
name: Docker build, test, and push
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
id: version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION"
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: ${{ env.IMAGE }}:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start server (demo mode)
run: |
docker run -d --name sidemantic-test -p 5433:5433 ${{ env.IMAGE }}:test --demo
for i in $(seq 1 30); do
if docker logs sidemantic-test 2>&1 | grep -q "Listening on"; then
echo "Server ready"
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
- name: Verify server logs
run: docker logs sidemantic-test 2>&1
- name: Install psql
run: sudo apt-get update && sudo apt-get install -y postgresql-client
- name: Test connection
run: PGPASSWORD=any psql -h localhost -p 5433 -U any -d sidemantic -c "SELECT 1 AS test"
- name: Test metric aggregation (products)
run: |
PGPASSWORD=any psql -h localhost -p 5433 -U any -d sidemantic -c \
"SELECT category, product_count, avg_price, total_catalog_value FROM semantic_layer.products GROUP BY category ORDER BY category"
- name: Test metric aggregation (customers)
run: |
PGPASSWORD=any psql -h localhost -p 5433 -U any -d sidemantic -c \
"SELECT region, customer_count FROM semantic_layer.customers GROUP BY region ORDER BY region"
- name: Stop server
if: always()
run: docker stop sidemantic-test || true
- name: Push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ steps.version.outputs.version }}
cache-from: type=gha