Skip to content

Commit 6918a8f

Browse files
committed
Add github actions for code style and tests
1 parent cca3256 commit 6918a8f

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

.github/workflows/code-style.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master, main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: pre-commit/[email protected]

.github/workflows/tests.yml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# workflow name
2+
name: Tests
3+
4+
# Controls when the action will run. Triggers the workflow on push or pull request
5+
# events but only for the wanted branches
6+
on:
7+
pull_request:
8+
push:
9+
branches: [master, main]
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
linux_tests:
14+
# The type of runner that the job will run on
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
# Remove unsupported versions and add more versions. Use LTR version in the cov_tests job
19+
docker_tags: [release-3_10, release-3_16, latest]
20+
fail-fast: false
21+
22+
# Steps represent a sequence of tasks that will be executed as part of the job
23+
steps:
24+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25+
- uses: actions/checkout@v2
26+
with:
27+
submodules: true
28+
29+
- name: Pull qgis
30+
run: docker pull qgis/qgis:${{ matrix.docker_tags }}
31+
32+
# Runs all tests
33+
- name: Run tests
34+
run: >
35+
docker run --rm --net=host --volume `pwd`:/app -w=/app -e QGIS_PLUGIN_IN_CI=1 qgis/qgis:${{ matrix.docker_tags }} sh -c
36+
"pip3 install -qr requirements-dev.txt && xvfb-run -s '+extension GLX -screen 0 1024x768x24'
37+
pytest -v --cov=nlsgpkgloader --cov-report=xml"
38+
39+
# Upload coverage report. Will not work if the repo is private
40+
- name: Upload coverage to Codecov
41+
if: ${{ matrix.docker_tags == 'latest' && !github.event.repository.private }}
42+
uses: codecov/codecov-action@v1
43+
with:
44+
file: ./coverage.xml
45+
flags: unittests
46+
fail_ci_if_error: false # set to true when upload is working
47+
verbose: false
48+
49+
windows_tests:
50+
runs-on: windows-latest
51+
52+
steps:
53+
- uses: actions/checkout@v2
54+
with:
55+
submodules: true
56+
57+
- name: Choco install qgis
58+
uses: crazy-max/ghaction-chocolatey@v1
59+
with:
60+
args: install qgis-ltr -y
61+
62+
- name: Run tests
63+
shell: pwsh
64+
run: |
65+
$env:PATH="C:\Program Files\QGIS 3.16\bin;$env:PATH"
66+
$env:QGIS_PLUGIN_IN_CI=1
67+
python-qgis-ltr.bat -m pip install -qr requirements-dev.txt
68+
python-qgis-ltr.bat -m pytest -v
69+
70+
pre-release:
71+
name: "Pre Release"
72+
runs-on: "ubuntu-latest"
73+
needs: [linux_tests, windows_tests]
74+
75+
steps:
76+
- uses: hmarr/debug-action@v2
77+
78+
- uses: "marvinpinto/action-automatic-releases@latest"
79+
if: ${{ github.event.pull_request }}
80+
with:
81+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
82+
automatic_release_tag: "dev-pr"
83+
prerelease: true
84+
title: "Development Build made for PR #${{ github.event.number }}"
85+
86+
- uses: "marvinpinto/action-automatic-releases@latest"
87+
if: ${{ github.event.after != github.event.before }}
88+
with:
89+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
90+
automatic_release_tag: "dev"
91+
prerelease: true
92+
title: "Development Build made for master branch"
93+
94+
- uses: actions/checkout@v2
95+
with:
96+
submodules: true
97+
98+
- name: Set up Python 3.8
99+
uses: actions/setup-python@v1
100+
with:
101+
python-version: 3.8
102+
103+
# Needed if the plugin is using Transifex, to have the lrelease command
104+
# - name: Install Qt lrelease
105+
# run: sudo apt-get update && sudo apt-get install qt5-default qttools5-dev-tools
106+
107+
- name: Install qgis-plugin-ci
108+
run: pip3 install qgis-plugin-ci
109+
110+
# When Transifex is wanted: --transifex-token ${{ secrets.TRANSIFEX_TOKEN }}
111+
- name: Deploy plugin
112+
if: ${{ github.event.pull_request }}
113+
run: qgis-plugin-ci release dev-pr --github-token ${{ secrets.GITHUB_TOKEN }} --disable-submodule-update
114+
115+
# When Transifex is wanted: --transifex-token ${{ secrets.TRANSIFEX_TOKEN }}
116+
- name: Deploy plugin
117+
if: ${{ github.event.after != github.event.before }}
118+
run: qgis-plugin-ci release dev --github-token ${{ secrets.GITHUB_TOKEN }} --disable-submodule-update

0 commit comments

Comments
 (0)