11name : Tests And Linting
22
33on :
4- pull_request :
54 push :
65 branches :
76 - main
7+ pull_request :
8+
9+ concurrency :
10+ group : test-${{ github.head_ref }}
11+ cancel-in-progress : true
12+
13+ env :
14+ PYTHONUNBUFFERED : " 1"
15+ FORCE_COLOR : " 1"
816
917jobs :
10- validate :
11- runs-on : ubuntu-latest
18+ run :
19+ name : Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
20+ runs-on : ${{ matrix.os }}
21+ timeout-minutes : 30
22+ strategy :
23+ fail-fast : false
24+ matrix :
25+ os : [ubuntu-latest]
26+ # os: [ubuntu-latest, windows-latest, macos-latest]
27+ python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
28+
1229 steps :
1330 - uses : actions/checkout@v4
1431
15- - uses : actions/setup-python@v5
32+ - if : runner.os == 'Linux'
33+ name : Install Microsoft ODBC Drivers & Free additional space
34+ run : |
35+ sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y || true
36+ sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
37+ sudo rm -rf \
38+ /usr/share/dotnet /usr/local/lib/android /opt/ghc \
39+ /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
40+ /usr/lib/jvm || true
41+ sudo apt-get autoremove -y \
42+ && sudo apt-get clean -y \
43+ && sudo rm -rf /root/.cache \
44+ && sudo rm -rf /var/apt/lists/* \
45+ && sudo rm -rf /var/cache/apt/* \
46+ && sudo apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
47+
48+ - name : Set up Python ${{ matrix.python-version }}
49+ uses : actions/setup-python@v5
1650 with :
17- python-version : " 3.11 "
51+ python-version : ${{ matrix.python-version }}
1852
19- - name : Install Pre-Commit
20- run : python -m pip install pre-commit && pre-commit install
53+ - name : Install Hatch
54+ run : pip install --upgrade hatch hatch-pip-compile
2155
22- - name : Load cached Pre-Commit Dependencies
23- id : cached-pre-commit-dependencies
24- uses : actions/cache@v4
25- with :
26- path : ~/.cache/pre-commit/
27- key : pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
56+ - if : matrix.python-version == '3.12' && runner.os == 'Linux'
57+ name : Lint
58+ run : hatch run lint:check
59+
60+ - if : matrix.python-version == '3.12' && runner.os == 'Linux'
61+ name : Run tests with coverage tracking
62+ run : hatch run +py=${{ matrix.python-version }} test:cov
2863
29- - name : Execute Pre-Commit
30- run : pre-commit run --show-diff-on-failure --color=always --all-files
64+ - if : matrix.python-version != '3.12' || runner.os != 'Linux'
65+ name : Run tests without tracking coverage
66+ run : hatch run +py=${{ matrix.python-version }} test:no-cov
3167
32- test :
68+ - if : matrix.python-version == '3.12' && runner.os == 'Linux'
69+ uses : actions/upload-artifact@v4
70+ with :
71+ name : coverage-xml
72+ path : coverage.xml
73+
74+ - if : matrix.python-version == '3.12' && runner.os == 'Linux'
75+ name : Upload coverage reports to Codecov
76+ uses : codecov/codecov-action@v4.5.0
77+ with :
78+ token : ${{ secrets.CODECOV_TOKEN }}
79+ slug : litestar-org/pytest-databases
80+ sonar :
81+ needs :
82+ - run
83+ if : github.event.pull_request.head.repo.fork == false && github.repository_owner == 'litestar-org'
3384 runs-on : ubuntu-latest
34- strategy :
35- fail-fast : true
36- matrix :
37- python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
38- timeout-minutes : 30
39- defaults :
40- run :
41- shell : bash
4285 steps :
4386 - name : Check out repository
4487 uses : actions/checkout@v4
45-
46- - uses : pdm-project/setup-pdm@v4
47- name : Set up PDM
4888 with :
49- python-version : ${{ matrix.python-version }}
89+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
90+ - name : Download Artifacts
91+ uses : actions/download-artifact@v4
92+ with :
93+ name : coverage-xml
5094
51- - name : Install dependencies
52- run : pdm install
95+ - name : Fix coverage file for sonarcloud
96+ run : sed -i "s/home\/runner\/work\/pytest-databases\/pytest-databases/github\/workspace/g" coverage.xml
5397
54- - name : Test
55- run : pdm run pytest -m ""
98+ - name : SonarCloud Scan
99+ uses : sonarsource/sonarcloud-github-action@master
100+ env :
101+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
102+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
103+ codeql :
104+ needs :
105+ - run
106+ runs-on : ubuntu-latest
107+ permissions :
108+ security-events : write
109+ steps :
110+ - name : Checkout repository
111+ uses : actions/checkout@v4
112+
113+ - name : Initialize CodeQL Without Dependencies
114+ uses : github/codeql-action/init@v3
115+
116+ - name : Perform CodeQL Analysis
117+ uses : github/codeql-action/analyze@v3
56118
57119 build-docs :
58- needs :
59- - validate
60120 if : github.event_name == 'pull_request'
61121 runs-on : ubuntu-latest
62122 steps :
@@ -68,16 +128,11 @@ jobs:
68128 with :
69129 python-version : " 3.11"
70130
71- - uses : pdm-project/setup-pdm@v4
72- name : Set up PDM
73- with :
74- python-version : " 3.11"
75-
76- - name : Install dependencies
77- run : pdm install -G:all
131+ - name : Install Hatch
132+ run : pip install --upgrade hatch hatch-containers hatch-pip-compile
78133
79134 - name : Build docs
80- run : pdm run make docs
135+ run : hatch run docs:build
81136
82137 - name : Save PR number
83138 env :
0 commit comments