|
1 | 1 | name: Run Mergin Plugin Tests |
2 | 2 |
|
3 | | -on: |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
4 | 8 | push: |
5 | 9 | workflow_dispatch: |
6 | 10 | inputs: |
7 | 11 | PYTHON_API_CLIENT_VER: |
8 | | - description: 'python-api-client version: either a tag, release, or a branch' |
| 12 | + description: "python-api-client version: either a tag, release, or a branch" |
9 | 13 | required: true |
10 | | - default: 'master' |
| 14 | + default: "master" |
11 | 15 | type: string |
12 | 16 |
|
13 | 17 | env: |
| 18 | + CONDA_PKGS_DIRS: ~/conda_pkgs_dir |
| 19 | + DEBIAN_FRONTEND: noninteractive |
| 20 | + QT_QPA_PLATFORM: offscreen |
| 21 | + XDG_RUNTIME_DIR: /tmp |
| 22 | + QT_SCALE_FACTOR: 1 |
| 23 | + QT_AUTO_SCREEN_SCALE_FACTOR: 0 |
| 24 | + QT_FONT_DPI: 96 |
14 | 25 | # Assign the version provided by 'workflow_dispatch' if available; otherwise, use the default. |
15 | 26 | PYTHON_API_CLIENT_VER: ${{ inputs.PYTHON_API_CLIENT_VER != '' && inputs.PYTHON_API_CLIENT_VER || 'master' }} |
16 | 27 | PLUGIN_NAME: Mergin |
17 | | - TEST_FUNCTION: suite.test_all |
18 | | - DOCKER_IMAGE: qgis/qgis |
19 | 28 |
|
20 | | -concurrency: |
21 | | - group: ci-${{github.ref}}-autotests |
22 | | - cancel-in-progress: true |
23 | | - |
24 | 29 | jobs: |
25 | 30 | run-tests: |
26 | | - runs-on: ubuntu-latest |
| 31 | + runs-on: ubuntu-24.04 |
27 | 32 |
|
28 | 33 | strategy: |
| 34 | + fail-fast: false |
29 | 35 | matrix: |
30 | | - docker_tags: [release-3_22, release-3_34] |
| 36 | + qgis-version: ["3.22", "3.28", "3.34", "3.40", "3.44"] |
31 | 37 |
|
32 | 38 | steps: |
| 39 | + - name: Checkout plugin code |
| 40 | + uses: actions/checkout@v6 |
| 41 | + with: |
| 42 | + path: plugin |
33 | 43 |
|
34 | | - - name: Checkout client code |
35 | | - uses: actions/checkout@v3 |
| 44 | + - name: Checkout python-client |
| 45 | + uses: actions/checkout@v6 |
36 | 46 | with: |
37 | 47 | repository: MerginMaps/python-api-client |
38 | 48 | ref: ${{ env.PYTHON_API_CLIENT_VER }} |
39 | 49 | path: client |
40 | 50 |
|
| 51 | + - name: Cache conda packages |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: ~/conda_pkgs_dir |
| 55 | + key: conda-pkgs-${{ runner.os }}-${{ matrix.qgis-version }} |
| 56 | + |
| 57 | + - name: Setup conda |
| 58 | + uses: conda-incubator/setup-miniconda@v3 |
| 59 | + with: |
| 60 | + use-mamba: true |
| 61 | + channels: conda-forge,defaults |
| 62 | + |
| 63 | + - name: Create environment and install QGIS |
| 64 | + run: | |
| 65 | + conda create -n qgis_env --no-default-packages --yes |
| 66 | + conda install -n qgis_env qgis=${{ matrix.qgis-version }} pytest pytest-qt pytest-cov --yes |
| 67 | + conda run -n qgis_env pip install --no-cache-dir pytest-qgis |
| 68 | + # mergin cilent dependencies |
| 69 | + conda run -n qgis_env pip install python-dateutil pytz wheel |
| 70 | +
|
41 | 71 | - name: Install python-api-client dependencies |
42 | 72 | run: | |
43 | | - pip3 install python-dateutil pytz wheel |
44 | 73 | cd client |
45 | 74 | mkdir -p mergin/deps |
46 | | - pip3 install pygeodiff --target=mergin/deps |
47 | | - python3 setup.py sdist bdist_wheel |
| 75 | + conda run -n qgis_env pip install pygeodiff --target=mergin/deps |
| 76 | + conda run -n qgis_env python setup.py sdist bdist_wheel |
48 | 77 | # without __init__.py the deps dir may get recognized as "namespace package" in python |
49 | 78 | # and it can break qgis plugin unloading mechanism - see #126 |
50 | 79 | touch mergin/deps/__init__.py |
51 | | - pip3 wheel -r mergin_client.egg-info/requires.txt -w mergin/deps |
| 80 | + conda run -n qgis_env pip wheel -r mergin_client.egg-info/requires.txt -w mergin/deps |
52 | 81 | unzip -o mergin/deps/pygeodiff-*.whl -d mergin/deps |
53 | 82 |
|
54 | | - - name: Checkout plugin code |
55 | | - uses: actions/checkout@v3 |
56 | | - with: |
57 | | - path: plugin |
58 | | - |
59 | | - - name: Copy client files to the plugin directory |
60 | | - run: | |
61 | | - cp -r client/mergin plugin/Mergin |
62 | | -
|
63 | | - - name: Docker pull and create qgis-testing-environment |
64 | | - run: | |
65 | | - docker pull "$DOCKER_IMAGE":${{ matrix.docker_tags }} |
66 | | - docker run -d --name qgis-testing-environment -v "$GITHUB_WORKSPACE"/plugin:/tests_directory -e DISPLAY=:99 "$DOCKER_IMAGE":${{ matrix.docker_tags }} |
67 | | - # Wait for xvfb to finish starting |
68 | | - printf "Waiting for the docker...🐳..." |
69 | | - sleep 10 |
70 | | - echo " done 🥩" |
| 83 | + - name: Copy client files to plugin directory |
| 84 | + run: cp -r client/mergin plugin/${{ env.PLUGIN_NAME }} |
71 | 85 |
|
72 | | - - name: Docker set up QGIS |
73 | | - run: | |
74 | | - docker exec qgis-testing-environment sh -c "qgis_setup.sh $PLUGIN_NAME" |
75 | | - docker exec qgis-testing-environment sh -c "rm -f /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME" |
76 | | - docker exec qgis-testing-environment sh -c "ln -s /tests_directory/$PLUGIN_NAME /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME" |
77 | | -
|
78 | | - - name: Docker run plugin tests |
79 | | - run: | |
80 | | - docker exec qgis-testing-environment sh -c "cd /tests_directory/$PLUGIN_NAME/test && qgis_testrunner.sh $TEST_FUNCTION" |
| 86 | + - name: Run tests |
| 87 | + run: conda run -n qgis_env pytest ${{ github.workspace }}/plugin/tests --cov=Mergin --cov-report=term-missing:skip-covered -rP -vv -s |
| 88 | + env: |
| 89 | + PYTHONPATH: ${{ github.workspace }}/plugin |
0 commit comments