Skip to content

Commit ee75384

Browse files
committed
add e2e testing
1 parent 228278b commit ee75384

File tree

2 files changed

+256
-172
lines changed

2 files changed

+256
-172
lines changed

.github/workflows/build.yml

Lines changed: 177 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ name: Multi-Platform Build
22

33
on:
44
push:
5-
branches: [main, develop]
5+
branches:
6+
- main
7+
- develop
8+
- "v*" # matches any branch that starts with 'v'
69
pull_request:
710
branches: [main]
811
release:
912
types: [published]
1013

1114
jobs:
15+
securityIntention:
16+
name: Security Intention
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Security Intention
20+
run: |
21+
echo "This workflow is intended to build the project in a secure manner:"
22+
echo " - Only installs absolutely essential and trusted dependencies. (steps \"Install *\")"
23+
echo " - Uses HTTPS for direct package downloads"
24+
echo " - Only uses official Github Actions \"actions/*\""
1225
build:
1326
name: Build for ${{ matrix.os }}
1427
runs-on: ${{ matrix.runs-on }}
@@ -24,185 +37,177 @@ jobs:
2437
- os: linux
2538
runs-on: ubuntu-latest
2639
arch: x86_64
27-
28-
steps:
29-
- name: Security Intention
30-
run: |
31-
echo "This workflow is intended to build the project in a secure manner:"
32-
echo " - Only installs absolutely essential and trusted dependencies. (steps \"Install *\")"
33-
echo " - Uses HTTPS for direct package downloads"
34-
echo " - Only uses official Github Actions \"actions/*\""
35-
36-
- name: Checkout code
37-
uses: actions/checkout@v4
38-
39-
- name: Set up Go
40-
uses: actions/setup-go@v4
41-
with:
42-
go-version: "1.21"
43-
44-
- name: Install dependencies (Ubuntu)
45-
if: matrix.os == 'linux'
46-
run: |
47-
sudo apt-get update
48-
sudo apt-get install -y sqlite3 libsqlite3-dev build-essential
49-
50-
- name: Install dependencies (macOS)
51-
if: matrix.os == 'darwin'
52-
run: |
53-
brew install sqlite3
54-
55-
- name: Install dependencies (Windows)
56-
if: matrix.os == 'windows'
57-
run: |
58-
choco install sqlite
59-
60-
- name: Build SQLite (Unix)
61-
if: matrix.os != 'windows'
62-
run: |
63-
cd sqlite
64-
if [ ! -d "sqlite-latest" ]; then
65-
# Download and extract SQLite source if not present
66-
curl -O https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz
67-
tar xzf sqlite-autoconf-3450100.tar.gz
68-
mv sqlite-autoconf-3450100 sqlite-latest
69-
fi
70-
cd sqlite-latest
71-
./configure --prefix=$(pwd)/../install --enable-static --disable-shared "CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2"
72-
make
73-
make install
74-
75-
- name: Build SQLite (Windows)
76-
if: matrix.os == 'windows'
77-
run: |
78-
cd sqlite
79-
if (!(Test-Path "sqlite-latest")) {
80-
Invoke-WebRequest -Uri "https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz" -OutFile "sqlite-autoconf-3450100.tar.gz"
81-
tar -xzf sqlite-autoconf-3450100.tar.gz
82-
Rename-Item sqlite-autoconf-3450100 sqlite-latest
83-
}
84-
cd sqlite-latest
85-
# Use MSYS2/MinGW for Windows build
86-
bash -c "./configure --prefix=$(pwd)/../install --enable-static --disable-shared 'CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2'"
87-
bash -c "make"
88-
bash -c "make install"
89-
90-
- name: Build Bridge
91-
run: |
92-
cd bridge
93-
make
94-
95-
- name: Set build environment (Darwin ARM64)
96-
if: matrix.os == 'darwin' && matrix.arch == 'arm64'
97-
run: |
98-
echo "GOOS=darwin" >> $GITHUB_ENV
99-
echo "GOARCH=arm64" >> $GITHUB_ENV
100-
echo "CGO_ENABLED=1" >> $GITHUB_ENV
101-
102-
- name: Set build environment (Darwin AMD64)
103-
if: matrix.os == 'darwin' && matrix.arch == 'amd64'
104-
run: |
105-
echo "GOOS=darwin" >> $GITHUB_ENV
106-
echo "GOARCH=amd64" >> $GITHUB_ENV
107-
echo "CGO_ENABLED=1" >> $GITHUB_ENV
108-
109-
- name: Set build environment (Linux x86_64)
110-
if: matrix.os == 'linux' && matrix.arch == 'x86_64'
111-
run: |
112-
echo "GOOS=linux" >> $GITHUB_ENV
113-
echo "GOARCH=amd64" >> $GITHUB_ENV
114-
echo "CGO_ENABLED=1" >> $GITHUB_ENV
115-
116-
- name: Set build environment (Windows)
117-
if: matrix.os == 'windows'
118-
run: |
119-
echo "GOOS=windows" >> $env:GITHUB_ENV
120-
echo "GOARCH=amd64" >> $env:GITHUB_ENV
121-
echo "CGO_ENABLED=1" >> $env:GITHUB_ENV
122-
123-
- name: Build Client (Unix)
124-
if: matrix.os != 'windows'
125-
run: |
126-
cd client
127-
make build
128-
129-
- name: Build Client (Windows)
130-
if: matrix.os == 'windows'
131-
run: |
132-
cd client
133-
# Use make with MSYS2/MinGW
134-
bash -c "make build"
135-
136-
- name: Create release directory
137-
run: |
138-
mkdir -p release
139-
140-
- name: Package binary (Unix)
141-
if: matrix.os != 'windows'
142-
run: |
143-
if [ "${{ matrix.os }}" = "darwin" ] && [ "${{ matrix.arch }}" = "arm64" ]; then
144-
BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}"
145-
else
146-
BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}"
147-
fi
148-
cp client/bin/sqlrsync release/${BINARY_NAME}
149-
150-
- name: Package binary (Windows)
151-
if: matrix.os == 'windows'
152-
run: |
153-
$BINARY_NAME = "sqlrsync-${{ matrix.os }}-${{ matrix.arch }}.exe"
154-
Copy-Item "client/bin/sqlrsync.exe" "release/$BINARY_NAME"
155-
156-
- name: Upload artifacts
157-
uses: actions/upload-artifact@v4
158-
with:
159-
name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }}
160-
path: release/*
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v4
46+
with:
47+
go-version: "1.21"
48+
49+
- name: Install dependencies (Ubuntu)
50+
if: matrix.os == 'linux'
51+
run: |
52+
sudo apt-get update
53+
sudo apt-get install -y sqlite3 libsqlite3-dev build-essential
54+
55+
- name: Install dependencies (macOS)
56+
if: matrix.os == 'darwin'
57+
run: |
58+
brew install sqlite3
59+
60+
- name: Install dependencies (Windows)
61+
if: matrix.os == 'windows'
62+
run: |
63+
choco install sqlite
64+
65+
- name: Build SQLite (Unix)
66+
if: matrix.os != 'windows'
67+
run: |
68+
cd sqlite
69+
if [ ! -d "sqlite-latest" ]; then
70+
# Download and extract SQLite source if not present
71+
curl -O https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz
72+
tar xzf sqlite-autoconf-3450100.tar.gz
73+
mv sqlite-autoconf-3450100 sqlite-latest
74+
fi
75+
cd sqlite-latest
76+
./configure --prefix=$(pwd)/../install --enable-static --disable-shared "CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2"
77+
make
78+
make install
79+
80+
- name: Build SQLite (Windows)
81+
if: matrix.os == 'windows'
82+
run: |
83+
cd sqlite
84+
if (!(Test-Path "sqlite-latest")) {
85+
Invoke-WebRequest -Uri "https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz" -OutFile "sqlite-autoconf-3450100.tar.gz"
86+
tar -xzf sqlite-autoconf-3450100.tar.gz
87+
Rename-Item sqlite-autoconf-3450100 sqlite-latest
88+
}
89+
cd sqlite-latest
90+
# Use MSYS2/MinGW for Windows build
91+
bash -c "./configure --prefix=$(pwd)/../install --enable-static --disable-shared 'CFLAGS=-DSQLITE_ENABLE_DBPAGE_VTAB=1 -O2'"
92+
bash -c "make"
93+
bash -c "make install"
94+
95+
- name: Build Bridge
96+
run: |
97+
cd bridge
98+
make
99+
100+
- name: Set build environment (Darwin ARM64)
101+
if: matrix.os == 'darwin' && matrix.arch == 'arm64'
102+
run: |
103+
echo "GOOS=darwin" >> $GITHUB_ENV
104+
echo "GOARCH=arm64" >> $GITHUB_ENV
105+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
106+
107+
- name: Set build environment (Darwin AMD64)
108+
if: matrix.os == 'darwin' && matrix.arch == 'amd64'
109+
run: |
110+
echo "GOOS=darwin" >> $GITHUB_ENV
111+
echo "GOARCH=amd64" >> $GITHUB_ENV
112+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
113+
114+
- name: Set build environment (Linux x86_64)
115+
if: matrix.os == 'linux' && matrix.arch == 'x86_64'
116+
run: |
117+
echo "GOOS=linux" >> $GITHUB_ENV
118+
echo "GOARCH=amd64" >> $GITHUB_ENV
119+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
120+
121+
- name: Set build environment (Windows)
122+
if: matrix.os == 'windows'
123+
run: |
124+
echo "GOOS=windows" >> $env:GITHUB_ENV
125+
echo "GOARCH=amd64" >> $env:GITHUB_ENV
126+
echo "CGO_ENABLED=1" >> $env:GITHUB_ENV
127+
128+
- name: Build Client (Unix)
129+
if: matrix.os != 'windows'
130+
run: |
131+
cd client
132+
make build
133+
134+
- name: Build Client (Windows)
135+
if: matrix.os == 'windows'
136+
run: |
137+
cd client
138+
# Use make with MSYS2/MinGW
139+
bash -c "make build"
140+
141+
- name: Create release directory
142+
run: |
143+
mkdir -p release
144+
145+
- name: Package binary (Unix)
146+
if: matrix.os != 'windows'
147+
run: |
148+
if [ "${{ matrix.os }}" = "darwin" ] && [ "${{ matrix.arch }}" = "arm64" ]; then
149+
BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}"
150+
else
151+
BINARY_NAME="sqlrsync-${{ matrix.os }}-${{ matrix.arch }}"
152+
fi
153+
cp client/bin/sqlrsync release/${BINARY_NAME}
154+
155+
- name: Package binary (Windows)
156+
if: matrix.os == 'windows'
157+
run: |
158+
$BINARY_NAME = "sqlrsync-${{ matrix.os }}-${{ matrix.arch }}.exe"
159+
Copy-Item "client/bin/sqlrsync.exe" "release/$BINARY_NAME"
160+
161+
- name: Upload artifacts
162+
uses: actions/upload-artifact@v4
163+
with:
164+
name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }}
165+
path: release/*
161166

162167
release:
163168
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
164169
needs: build
165-
permissions:
170+
permissions:
166171
contents: write
167172
packages: write
168173
issues: write
169174
pull-requests: write
170175
actions: write
171176
runs-on: ubuntu-latest
172177
steps:
173-
- uses: actions/checkout@v5
174-
175-
- name: Extract version from main.go
176-
id: extract-version
177-
run: |
178-
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
179-
echo "version=$VERSION" >> $GITHUB_OUTPUT
180-
echo "Extracted version: $VERSION"
181-
182-
- name: Check if tag exists
183-
id: tag-check
184-
run: |
185-
VERSION=${{ steps.extract-version.outputs.version }}
186-
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
187-
echo "Tag v$VERSION already exists"
188-
echo "tag-created=false" >> $GITHUB_OUTPUT
189-
else
190-
echo "Tag v$VERSION does not exist, will create"
191-
echo "tag-created=true" >> $GITHUB_OUTPUT
192-
fi
193-
194-
- name: Download all release artifacts
195-
if: steps.tag-check.outputs.tag-created == 'true'
196-
uses: actions/download-artifact@v5
197-
198-
- name: Create tag and GitHub Release, attach artifact
199-
env:
200-
GH_TOKEN: ${{ github.token }}
201-
run: |
202-
TAG=v${{ steps.extract-version.outputs.version }}
203-
git config user.name "${{ github.actor }}"
204-
git config user.email "${{ github.actor }}@users.noreply.github.com"
205-
git tag -a $TAG -m "Release $TAG"
206-
git push origin $TAG
207-
# create the release and attach the artifact (gh CLI)
208-
gh release create $TAG --generate-notes sqlrsync-*/sqlrsync-*
178+
- uses: actions/checkout@v5
179+
180+
- name: Extract version from main.go
181+
id: extract-version
182+
run: |
183+
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
184+
echo "version=$VERSION" >> $GITHUB_OUTPUT
185+
echo "Extracted version: $VERSION"
186+
187+
- name: Check if tag exists
188+
id: tag-check
189+
run: |
190+
VERSION=${{ steps.extract-version.outputs.version }}
191+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
192+
echo "Tag v$VERSION already exists"
193+
echo "tag-created=false" >> $GITHUB_OUTPUT
194+
else
195+
echo "Tag v$VERSION does not exist, will create"
196+
echo "tag-created=true" >> $GITHUB_OUTPUT
197+
fi
198+
199+
- name: Download all release artifacts
200+
if: steps.tag-check.outputs.tag-created == 'true'
201+
uses: actions/download-artifact@v5
202+
203+
- name: Create tag and GitHub Release, attach artifact
204+
env:
205+
GH_TOKEN: ${{ github.token }}
206+
run: |
207+
TAG=v${{ steps.extract-version.outputs.version }}
208+
git config user.name "${{ github.actor }}"
209+
git config user.email "${{ github.actor }}@users.noreply.github.com"
210+
git tag -a $TAG -m "Release $TAG"
211+
git push origin $TAG
212+
# create the release and attach the artifact (gh CLI)
213+
gh release create $TAG --generate-notes sqlrsync-*/sqlrsync-*

0 commit comments

Comments
 (0)