-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (99 loc) · 3.16 KB
/
test-unit.yaml
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
name: "Unit tests"
on:
workflow_call:
permissions:
contents: read
pull-requests: write
jobs:
PythonLint:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install pip
run: |
python -m ensurepip --upgrade
- shell: bash
run: |-
pip3 install flake8
- shell: bash
run: |-
export PATH=$PATH:/builder/home/.local/bin
./bin/flake8_tests.sh
PythonUnitTests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.1
- name: Build docker compose
uses: docker/bake-action@v4
with:
files: docker-compose.yml, docker-compose.ci.yml
load: true
- name: "Prepare test environment"
shell: bash
run: |-
docker compose -f docker-compose.ci.yml up -d postgres redis
- name: "Wait for postgres to start"
shell: bash
run: |-
for i in 1 2 3 4 5; do docker compose -f docker-compose.ci.yml run --rm postgres psql -h postgres -U postgres -c "SELECT 1 FROM pg_database WHERE datname = 'tests'" && break || sleep 2; done
- name: "Create tests database"
shell: bash
run: |-
docker compose -f docker-compose.ci.yml run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- name: "List Enabled Query Runners"
shell: bash
run: |-
docker compose -f docker-compose.ci.yml run --rm server manage ds list_types
- name: "Execute unit tests"
shell: bash
run: |-
docker compose -f docker-compose.ci.yml run --user 0 --name tests server tests --junitxml=junit.xml --cov-report xml --cov=redash --cov-config .coveragerc tests/
- name: "Extract test results"
shell: bash
if: always()
run: |
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/junit.xml ./results.xml
ls -l
- name: "Publish unit test report"
uses: mikepenz/action-junit-report@v4
if: always()
with:
fail_on_failure: true
report_paths: results.xml
require_tests: true
include_passed: true
summary: true
job_summary: true
check_name: "Unit Tests Report"
- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md