Skip to content

Commit 38905d2

Browse files
authored
Seperate integration and unit test in CI (#295)
1 parent e3953f7 commit 38905d2

File tree

14 files changed

+133
-63
lines changed

14 files changed

+133
-63
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
include-hidden-files: true
119119

120120
Tests:
121-
name: Tests (Python-${{ matrix.python-version }}, Exasol-${{ matrix.exasol-version}})
121+
name: Unit-Tests (Python-${{ matrix.python-version }}, Exasol-${{ matrix.exasol-version}})
122122
needs: [ Documentation, Lint, Type-Check, Security]
123123
runs-on: ubuntu-latest
124124
env:
@@ -139,11 +139,11 @@ jobs:
139139
python-version: ${{ matrix.python-version }}
140140

141141
- name: Run Tests and Collect Coverage
142-
run: poetry run nox -s test:coverage -- -- --db-version ${{ matrix.exasol-version }}
142+
run: poetry run nox -s test:unit -- -- --coverage --db-version ${{ matrix.exasol-version }}
143143

144144
- name: Upload Artifacts
145145
uses: actions/[email protected]
146146
with:
147-
name: coverage-python${{ matrix.python-version }}
147+
name: coverage-python${{ matrix.python-version }}-fast
148148
path: .coverage
149149
include-hidden-files: true

.github/workflows/merge-gate.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,17 @@ jobs:
1414

1515
slow-checks:
1616
name: Slow
17-
runs-on: ubuntu-latest
18-
19-
# Even though the environment "manual-approval" will be created automatically,
20-
# it still needs to be configured to require interactive review.
21-
# See project settings on GitHub (Settings / Environments / manual-approval).
22-
environment: manual-approval
23-
24-
# Replace the steps below with the required actions
25-
# and/or add additional jobs if required
26-
# Note:
27-
# If you add additional jobs, make sure they are added as a requirement
28-
# to the approve-merge job's input requirements (needs).
29-
steps:
30-
- name: Tests
31-
run: |
32-
echo "Slow tests ran successfully"
33-
17+
uses: ./.github/workflows/slow-checks.yml
3418

3519
# This job ensures inputs have been executed successfully.
3620
approve-merge:
37-
name: Allow Merge
21+
name: Allow Merge
3822
runs-on: ubuntu-latest
3923
# If you need additional jobs to be part of the merge gate, add them below
4024
needs: [ fast-checks, slow-checks ]
4125

4226
# Each job requires a step, so we added this dummy step.
4327
steps:
44-
- name: Approve
28+
- name: Approve
4529
run: |
4630
echo "Merge Approved"

.github/workflows/report.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
- name: Copy Artifacts into Root Folder
3131
working-directory: ./artifacts
3232
run: |
33-
cp coverage-python3.9/.coverage ../
33+
poetry run coverage combine --keep coverage-python3.9*/.coverage
34+
cp .coverage ../
3435
cp lint-python3.9/.lint.txt ../
3536
cp security-python3.9/.security.json ../
3637

.github/workflows/slow-checks.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Slow-Checks
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
ALTERNATIVE_GITHUB_TOKEN:
7+
required: false
8+
9+
jobs:
10+
11+
Tests:
12+
name: Integration-Tests (Python-${{ matrix.python-version }}, Exasol-${{ matrix.exasol-version}})
13+
runs-on: ubuntu-latest
14+
# Even though the environment "manual-approval" will be created automatically,
15+
# it still needs to be configured to require interactive review.
16+
# See project settings on GitHub (Settings / Environments / manual-approval).
17+
environment: manual-approval
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.ALTERNATIVE_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
24+
exasol-version: [ "7.1.9" ]
25+
26+
steps:
27+
- name: SCM Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Python & Poetry Environment
31+
uses: ./.github/actions/python-environment
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Run Tests and Collect Coverage
36+
run: poetry run nox -s test:integration -- -- --coverage --db-version ${{ matrix.exasol-version }}
37+
38+
- name: Upload Artifacts
39+
uses: actions/[email protected]
40+
with:
41+
name: coverage-python${{ matrix.python-version }}-slow
42+
path: .coverage
43+
include-hidden-files: true

exasol/toolbox/nox/_shared.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ def _context_parser() -> argparse.ArgumentParser:
5656
parser = argparse.ArgumentParser(
5757
formatter_class=argparse.ArgumentDefaultsHelpFormatter
5858
)
59-
parser.add_argument("--db-version")
60-
parser.add_argument("--coverage", action="store_true")
59+
parser.add_argument(
60+
"--db-version", default="7.1.9", help="Specify the Exasol DB version to be used"
61+
)
62+
parser.add_argument(
63+
"--coverage", action="store_true", help="Enable the collection of coverage data"
64+
)
6165
return parser
6266

6367

exasol/toolbox/nox/_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _coverage(
7575
@nox.session(name="test:unit", python=False)
7676
def unit_tests(session: Session) -> None:
7777
"""Runs all unit tests"""
78-
context = _context(session, coverage=False)
78+
context = _context(session)
7979
_unit_tests(session, PROJECT_CONFIG, context)
8080

8181

@@ -89,7 +89,7 @@ def integration_tests(session: Session) -> None:
8989
* pre_integration_tests_hook(session: Session, config: Config, context: MutableMapping[str, Any]) -> bool:
9090
* post_integration_tests_hook(session: Session, config: Config, context: MutableMapping[str, Any]) -> bool:
9191
"""
92-
context = _context(session, coverage=False)
92+
context = _context(session)
9393
_integration_tests(session, PROJECT_CONFIG, context)
9494

9595

exasol/toolbox/sphinx/multiversion/main.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _create_parser():
231231
parser.add_argument(
232232
"--debug",
233233
action="store_true",
234-
help="enable debug mode with increased log verbosity, etc."
234+
help="enable debug mode with increased log verbosity, etc.",
235235
)
236236
return parser
237237

@@ -286,13 +286,15 @@ def _main(args, argv):
286286
conffile = os.path.join(confdir, "conf.py")
287287

288288
# Get git references
289-
gitrefs = list(git.get_refs(
290-
str(gitroot),
291-
config.smv_tag_whitelist,
292-
config.smv_branch_whitelist,
293-
config.smv_remote_whitelist,
294-
files=(sourcedir, conffile),
295-
))
289+
gitrefs = list(
290+
git.get_refs(
291+
str(gitroot),
292+
config.smv_tag_whitelist,
293+
config.smv_branch_whitelist,
294+
config.smv_remote_whitelist,
295+
files=(sourcedir, conffile),
296+
)
297+
)
296298

297299
# Order git refs
298300
if config.smv_prefer_remote_refs:
@@ -581,14 +583,18 @@ def _main(args, argv):
581583
with open(
582584
os.path.join(args.outputdir, "index.html"), "w", encoding="utf-8"
583585
) as f:
584-
logger.debug("Picked up Git references: %s", [ref.name for ref in gitrefs])
586+
logger.debug(
587+
"Picked up Git references: %s", [ref.name for ref in gitrefs]
588+
)
585589
tag_versions = [
586590
ref.name
587591
for ref in gitrefs
588592
if re.match(config.smv_tag_whitelist, ref.name)
589593
]
590594
tag_versions = sorted(
591-
tag_versions, key=lambda v: ExasolVersion.from_string(v), reverse=True
595+
tag_versions,
596+
key=lambda v: ExasolVersion.from_string(v),
597+
reverse=True,
592598
)
593599
branches = [
594600
ref.name

exasol/toolbox/templates/github/workflows/checks.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ jobs:
124124
include-hidden-files: true
125125

126126
Tests:
127-
name: Tests (Python-${{ matrix.python-version }}, Exasol-${{ matrix.exasol-version}})
128-
needs: [ Documentation, Lint, Type-Check, Security ]
127+
name: Unit-Tests (Python-${{ matrix.python-version }}, Exasol-${{ matrix.exasol-version}})
128+
needs: [ Documentation, Lint, Type-Check, Security]
129129
runs-on: ubuntu-latest
130130
env:
131131
GITHUB_TOKEN: ${{ secrets.ALTERNATIVE_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
@@ -144,13 +144,12 @@ jobs:
144144
with:
145145
python-version: ${{ matrix.python-version }}
146146

147-
- name: Run Tests and Compute Coverage
148-
run: poetry run nox -s test:coverage -- -- --db-version ${{ matrix.exasol-version }}
147+
- name: Run Tests and Collect Coverage
148+
run: poetry run nox -s test:unit -- -- --coverage --db-version ${{ matrix.exasol-version }}
149149

150150
- name: Upload Artifacts
151151
uses: actions/[email protected]
152152
with:
153-
name: coverage-python${{ matrix.python-version }}
153+
name: coverage-python${{ matrix.python-version }}-fast
154154
path: .coverage
155155
include-hidden-files: true
156-

exasol/toolbox/templates/github/workflows/merge-gate.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,17 @@ jobs:
1414

1515
slow-checks:
1616
name: Slow
17-
runs-on: ubuntu-latest
18-
19-
# Even though the environment "manual-approval" will be created automatically,
20-
# it still needs to be configured to require interactive review.
21-
# See project settings on GitHub (Settings / Environments / manual-approval).
22-
environment: manual-approval
23-
24-
# Replace the steps below with the required actions
25-
# and/or add additional jobs if required
26-
# Note:
27-
# If you add additional jobs, make sure they are added as a requirement
28-
# to the approve-merge job's input requirements (needs).
29-
steps:
30-
- name: Tests
31-
run: |
32-
echo "Slow tests ran successfully"
33-
17+
uses: ./.github/workflows/slow-checks.yml
3418

3519
# This job ensures inputs have been executed successfully.
3620
approve-merge:
37-
name: Allow Merge
21+
name: Allow Merge
3822
runs-on: ubuntu-latest
3923
# If you need additional jobs to be part of the merge gate, add them below
4024
needs: [ fast-checks, slow-checks ]
4125

4226
# Each job requires a step, so we added this dummy step.
4327
steps:
44-
- name: Approve
28+
- name: Approve
4529
run: |
4630
echo "Merge Approved"

exasol/toolbox/templates/github/workflows/report.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
- name: Copy Artifacts into Root Folder
3131
working-directory: ./artifacts
3232
run: |
33-
cp coverage-python3.9/.coverage ../
33+
poetry run coverage combine --keep coverage-python3.9*/.coverage
34+
cp .coverage ../
3435
cp lint-python3.9/.lint.txt ../
3536
cp security-python3.9/.security.json ../
3637

0 commit comments

Comments
 (0)