forked from opengisch/QField
-
Notifications
You must be signed in to change notification settings - Fork 0
300 lines (258 loc) ยท 12.8 KB
/
Copy pathlinux.yml
File metadata and controls
300 lines (258 loc) ยท 12.8 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
---
name: ๐ง Linux
on:
push:
branches:
- master
- release-**
pull_request:
release:
types: ['published']
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: build (linux)
runs-on: ubuntu-24.04
steps:
- name: ๐ฃ Checkout
uses: actions/checkout@v6.0.2
with:
submodules: recursive
- name: โป๏ธ Check disk space
run: df . -h
- name: ๐งน Reclaim disk space
run: |
sudo rm -rf /usr/local/lib/android/
sudo rm -rf /opt/ghc
- name: โป๏ธ Check disk space
run: df . -h
- name: ๐พ Prepare variables
id: vars
run: |
./scripts/ci/env_gh.sh
BUILD_ROOT="/home/runner"
echo "BUILD_ROOT=${BUILD_ROOT}" >> $GITHUB_ENV
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
- name: ๐ Setup ruby
uses: ruby/setup-ruby@v1.310.0
with:
ruby-version: '3.4' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: ๐ต Install Mono
run: |
sudo apt install ca-certificates gnupg
sudo gpg --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo chmod +r /usr/share/keyrings/mono-official-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
- name: ๐ฉ Install CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.29.0
- name: ๐จ Prepare build env
run: |
sudo apt-get update
sudo apt-get install -y gperf autopoint '^libxcb.*-dev' libx11-xcb-dev libsm-dev libegl1 libegl1-mesa-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libxrandr-dev libxxf86vm-dev autoconf-archive libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-0 gstreamer1.0-pipewire libfuse2 libpulse-dev libcups2-dev nasm python3-tk libltdl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.sh -O /tmp/cmakeinstall.sh
chmod +x /tmp/cmakeinstall.sh
sudo /tmp/cmakeinstall.sh --prefix=/usr/local --exclude-subdir
rm /tmp/cmakeinstall.sh
- name: Install linuxdeploy
uses: miurahr/install-linuxdeploy-action@v1
with:
dir: ${{ env.BUILD_ROOT }}
plugins: qt appimage
- name: ๐ฑ Install dependencies and generate project files
run: |
source ./scripts/version_number.sh
source ./scripts/ci/generate-version-details.sh
cmake -S "${{ github.workspace }}" \
-B "build" \
-G Ninja \
-D CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-D WITH_VCPKG=ON \
-D WITH_SPIX=ON \
-D WITH_NFC=OFF \
-D APP_VERSION="${APP_VERSION}" \
-D APP_VERSION_STR="${APP_VERSION_STR}" \
-D APP_PACKAGE_NAME="${APP_PACKAGE_NAME}" \
-D ENABLE_TESTS=ON \
-D NUGET_USERNAME=opengisch \
-D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_EXPORT_COMPILE_COMMANDS=ON \
-D CMAKE_COMPILE_WARNING_AS_ERROR=ON \
-D SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-D SENTRY_ENV="${APP_ENV}" \
-D LINUXDEPLOY_EXECUTABLE=${{ env.BUILD_ROOT }}/linuxdeploy-x86_64.AppImage \
-D VCPKG_INSTALL_OPTIONS="--x-abi-tools-use-exact-versions"
- name: ๐ Upload dep build logs
uses: actions/upload-artifact@v7
if: failure()
with:
name: build-logs-x64-linux
path: |
build/**/*.log
- name: Setup QFieldCloud
run: |
QFC_DIR=/tmp/qfieldcloud
git clone --depth 1 https://github.com/opengisch/QFieldCloud.git $QFC_DIR
cd $QFC_DIR
cp .env.example .env
export COMPOSE_FILE=docker-compose.yml:docker-compose.override.standalone.yml
sed -i \
-e 's|^WEB_HTTP_PORT=80$|WEB_HTTP_PORT=8080|' \
-e 's|^WEB_HTTPS_PORT=443$|WEB_HTTPS_PORT=8443|' \
-e 's|^OBJECT_STORAGE_BROWSER_PORT=8010$|OBJECT_STORAGE_BROWSER_PORT=8013|' \
-e 's|^DEBUG_APP_DEBUGPY_PORT=5678$|DEBUG_APP_DEBUGPY_PORT=""|' \
-e 's|^DEBUG_WORKER_WRAPPER_DEBUGPY_PORT=5679$|DEBUG_WORKER_WRAPPER_DEBUGPY_PORT=""|' \
.env
docker compose -p qfc up -d db rustfs memcached mkcert
echo "Waiting for database..."
for i in $(seq 1 30); do
docker compose -p qfc exec -T db pg_isready -q 2>/dev/null && break
[ "$i" -eq 30 ] && { docker compose -p qfc logs db --tail=20; exit 1; }
sleep 2
done
docker compose -p qfc up -d --build app
echo "Waiting for app..."
for i in $(seq 1 20); do
docker compose -p qfc exec -T app python -c "print('ok')" 2>/dev/null && break
[ "$i" -eq 20 ] && { docker compose -p qfc logs app --tail=20; exit 1; }
sleep 2
done
docker compose -p qfc exec -T app python manage.py migrate --no-input
docker compose -p qfc exec -T app python manage.py collectstatic --no-input
docker compose -p qfc exec -T app python manage.py createuser --username admin --email admin@localhost.local --password admin123 --superuser
docker compose -p qfc up -d --build nginx
echo "Waiting for nginx..."
for i in $(seq 1 40); do
curl -k -s -f https://localhost:8443/api/v1/status/ > /dev/null 2>&1 && break
[ "$i" -eq 40 ] && { docker compose -p qfc logs nginx --tail=20; docker compose -p qfc logs mkcert --tail=10; exit 1; }
sleep 3
done
docker compose -p qfc ps
- name: Test QFieldCloud
run: |
curl -k -s https://localhost:8443/api/v1/status/ | grep -q '"database":"ok"'
TOKEN=$(curl -k -s -X POST https://localhost:8443/api/v1/auth/login/ \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' | jq -r '.token')
[ "$TOKEN" != "null" ] && [ -n "$TOKEN" ] || { echo "Login failed"; exit 1; }
curl -k -s -H "Authorization: Token $TOKEN" https://localhost:8443/api/v1/users/admin/ | grep -q '"username":"admin"'
echo "QFieldCloud is ready"
- name: Initialize CodeQL
uses: github/codeql-action/init@v4.36.0
with:
languages: 'c-cpp'
- name: ๐ Build
run: |
xvfb-run cmake --build build --config ${{ env.BUILD_TYPE }}
- uses: ZedThree/clang-tidy-review@v0.23.1
id: review
if: github.event_name == 'pull_request'
with:
build_dir: "build"
lgtm_comment_body: ''
clang_tidy_checks: '-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,-bugprone-narrowing-conversions,-bugprone-easily-swappable-parameters,-clang-analyzer-optin.core.EnumCastOutOfRange,-performance-enum-size'
- name: Package
run: |
export LD_LIBRARY_PATH="${{ github.workspace }}/build/vcpkg_installed/x64-linux/lib/":${LD_LIBRARY_PATH}
cmake --build "build" --target bundle --config ${{ env.BUILD_TYPE }}
echo "ARTIFACT_PATHNAME=build/QField-x86_64.AppImage" >> $GITHUB_ENV
echo "ARTIFACT_NAME=qfield-${{ env.CI_PACKAGE_FILE_SUFFIX }}-linux-x64.AppImage" >> $GITHUB_ENV
- name: ๐ฆ Upload artifacts
if: ${{ env.ARTIFACT_NAME != null }}
uses: actions/upload-artifact@v7
id: artifact-linux
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATHNAME }}
- name: ๐งซ Test
env:
PROJ_LIB: ${{ github.workspace }}/build/vcpkg_installed/x64-linux/share/proj
QFIELDCLOUD_URL: https://localhost:8443
QFIELDCLOUD_USERNAME: admin
QFIELDCLOUD_PASSWORD: admin123
QFIELDCLOUD_REMOTE_URL: ${{ secrets.QFIELDCLOUD_TEST_SERVER_URL }}
QFIELDCLOUD_REMOTE_USERNAME: ${{ secrets.QFIELDCLOUD_TEST_USERNAME }}
QFIELDCLOUD_REMOTE_PASSWORD: ${{ secrets.QFIELDCLOUD_TEST_PASSWORD }}
run: |
pip install -r "${{ github.workspace }}/test/spix/requirements.txt"
docker compose -f "${{ github.workspace }}/test/docker-compose.yaml" up -d
echo "[test-clientssl]" >> ~/.pg_service.conf
echo "host=localhost" >> ~/.pg_service.conf
echo "port=5440" >> ~/.pg_service.conf
echo "dbname=gis" >> ~/.pg_service.conf
echo "user=docker" >> ~/.pg_service.conf
echo "password=docker" >> ~/.pg_service.conf
echo "sslmode=require" >> ~/.pg_service.conf
echo "sslcert=${{ github.workspace }}/test/postgis_docker/cert_keys/client.crt" >> ~/.pg_service.conf
echo "sslkey=${{ github.workspace }}/test/postgis_docker/cert_keys/client.key" >> ~/.pg_service.conf
echo "sslrootcert=${{ github.workspace }}/test/postgis_docker/cert_keys/server.crt" >> ~/.pg_service.conf
chown $USER ${{ github.workspace }}/test/postgis_docker/cert_keys/client.crt
chmod 700 ${{ github.workspace }}/test/postgis_docker/cert_keys/client.crt
chown $USER ${{ github.workspace }}/test/postgis_docker/cert_keys/client.key
chmod 700 ${{ github.workspace }}/test/postgis_docker/cert_keys/client.key
chown $USER ${{ github.workspace }}/test/postgis_docker/cert_keys/server.crt
chmod 700 ${{ github.workspace }}/test/postgis_docker/cert_keys/server.crt
cd build
export QFIELDCLOUD_URL="${QFIELDCLOUD_URL}"
export QFIELDCLOUD_USERNAME="${QFIELDCLOUD_USERNAME}"
export QFIELDCLOUD_PASSWORD="${QFIELDCLOUD_PASSWORD}"
export QFIELDCLOUD_REMOTE_URL="${QFIELDCLOUD_REMOTE_URL}"
export QFIELDCLOUD_REMOTE_USERNAME="${QFIELDCLOUD_REMOTE_USERNAME}"
export QFIELDCLOUD_REMOTE_PASSWORD="${QFIELDCLOUD_REMOTE_PASSWORD}"
xvfb-run --server-args="-screen 0 640x480x24" ctest --repeat until-pass:3 --output-on-failure -C ${{ env.BUILD_TYPE }}
- name: Docker cleanup
if: always()
run: |
cd /tmp/qfieldcloud
export COMPOSE_FILE=docker-compose.yml:docker-compose.override.standalone.yml
docker compose -p qfc down 2>/dev/null || true
docker compose -f "${{ github.workspace }}/test/docker-compose.yaml" down 2>/dev/null || true
- name: ๐ Upload package logs
uses: actions/upload-artifact@v7
if: failure()
with:
name: package-logs-x64-linux
path: build/_CPack_Packages/**/*.log
- name: ๐ Upload test report
if: always()
uses: actions/upload-artifact@v7
with:
name: "test-report-x64-linux-${{ env.BUILD_TYPE }}"
path: "build/report"
- name: ๐ Upload release asset
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && env.ARTIFACT_NAME != null
uses: shogo82148/actions-upload-release-asset@v1.10.1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ARTIFACT_PATHNAME }}
asset_name: ${{ env.ARTIFACT_NAME }}
overwrite: true
- name: ๐ฎ Upload debug symbols
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && env.ARTIFACT_NAME != null
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG_SLUG: opengisch
SENTRY_PROJECT_SLUG: qfield
run: |
bundle exec fastlane run sentry_debug_files_upload path:build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4.36.0
with:
category: "/language:c-cpp"
- name: Schedule download comment
uses: ./.github/actions/post_sticky_comment
if: github.event_name == 'pull_request'
with:
marker: linux
body: |
### ๐ง Linux AppImage builds
Download a [Linux AppImage build of this PR for testing](https://nightly.link/opengisch/QField/actions/runs/${{ github.run_id }}/${{ env.ARTIFACT_NAME }}.zip).
*(Built from commit ${{ github.event.pull_request.head.sha }})*
pr: ${{ github.event.number }}