Skip to content

Commit 3c4a159

Browse files
ci: separate unit from load tests and remove pytest from pre-commit (#525)
* separate load tests from unit tests Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com> * remove unit tests from pre-commit Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com> * fix: checkout code Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com> * exclude tests folder for analysis Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com> --------- Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com>
1 parent 0469d55 commit 3c4a159

5 files changed

+24
-34
lines changed

.github/workflows/.pre-commit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
python-version: 3.11
1919
cache: pip
20-
- run: pip install -r backend/protocol_rpc/requirements.txt
20+
- run: pip install black
2121
# Set up Node.js
2222
- uses: actions/setup-node@v3
2323
with:

.github/workflows/backend_integration_tests_pr.yml

+8
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,11 @@ jobs:
132132
133133
- name: Run Docker Compose
134134
run: docker compose -f tests/db-sqlalchemy/docker-compose.yml --project-directory . up tests --build --force-recreate --always-recreate-deps
135+
136+
load-test:
137+
name: Load Tests
138+
needs: triggers
139+
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
140+
uses: ./.github/workflows/load-test-oha.yml
141+
with:
142+
oha-version: "v1.4.5"

.github/workflows/unit-tests-pr.yml

+14-23
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,27 @@ on:
1010
types:
1111
- submitted
1212
- edited
13-
14-
concurrency:
15-
group: unit-tests-${{ github.event.number }}
16-
cancel-in-progress: true
13+
push:
14+
branches:
15+
- main # so that test reports get uploaded to Codecov
1716

1817
permissions:
1918
contents: read
2019

2120
jobs:
22-
triggers:
23-
name: Get Triggers
24-
runs-on: ubuntu-latest
25-
outputs:
26-
is_pull_request_opened: ${{ github.event_name == 'pull_request' && github.event.action == 'opened'}}
27-
is_pull_request_review_approved: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'APPROVED'}}
28-
is_pull_request_labeled_with_run_tests: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-tests')}}
29-
steps:
30-
- run: true
31-
test:
21+
frontend-unit-tests:
3222
name: Unit Tests
33-
needs: triggers
34-
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
3523
uses: ./.github/workflows/frontend-unit-tests.yml
3624
secrets:
3725
codecov_token: ${{ secrets.CODECOV_TOKEN }}
3826

39-
load-test:
40-
name: Load Tests
41-
needs: triggers
42-
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
43-
uses: ./.github/workflows/load-test-oha.yml
44-
with:
45-
oha-version: "v1.4.5"
27+
backend-unit-tests:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: 3.11
34+
cache: pip
35+
- run: pip install -r backend/protocol_rpc/requirements.txt
36+
- run: pytest tests/unit -vv

.pre-commit-config.yaml

-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ repos:
99
- id: check-merge-conflict
1010
- id: no-commit-to-branch
1111
args: ["--branch", "main"]
12-
- repo: local
13-
hooks:
14-
- id: backend-unit-pytest
15-
name: backend unit tests with pytest
16-
entry: bash -c 'if [ -d "venv" ]; then source venv/bin/activate; pytest tests/unit; else pytest tests/unit; fi'
17-
language: system
18-
types: [python]
19-
pass_filenames: false
20-
files: backend
21-
always_run: false
2212
# Copied from https://black.readthedocs.io/en/stable/integrations/source_version_control.html
2313
- repo: https://github.com/psf/black-pre-commit-mirror
2414
rev: 24.4.2

sonar-project.properties

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ sonar.projectKey=yeagerai_genlayer-simulator
44
# relative paths to source directories. More details and properties are described
55
# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
66
sonar.sources=.
7+
sonar.exclusions=tests/**,

0 commit comments

Comments
 (0)