Skip to content

Commit f7cc7f4

Browse files
authored
chore: linting action improvements (#120)
* fails the lint/test action if either tests or linting fail * wip: force a test failure * wip: force a lint failure * fixes tests and linting * ignore linting for complex method
1 parent 8ee7538 commit f7cc7f4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.github/workflows/lint-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,22 @@ jobs:
4040
pip install .[dev]
4141
pip install .[test]
4242
- name: Lint with Ruff
43+
id: lint
4344
run: |
4445
ruff check --output-format=github netbox_diode_plugin/
4546
continue-on-error: true
4647
- name: Test
48+
id: test
4749
run: |
4850
make docker-compose-netbox-plugin-test-cover
51+
continue-on-error: true
52+
- name: Check results
53+
if: always()
54+
run: |
55+
if [[ "${{ steps.lint.outcome }}" == "failure" || "${{ steps.test.outcome }}" == "failure" ]]; then
56+
echo "Either linting or tests failed"
57+
exit 1
58+
fi
4959
- name: Coverage comment
5060
uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2
5161
if: github.event.pull_request.head.repo.full_name == github.repository

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ docker-compose-netbox-plugin-test:
1717
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run -u root --rm netbox ./manage.py test $(TEST_FLAGS) --keepdb netbox_diode_plugin
1818
@$(MAKE) docker-compose-netbox-plugin-down
1919

20+
.PHONY: docker-compose-netbox-plugin-test-lint
21+
docker-compose-netbox-plugin-test-lint:
22+
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run -u root --rm netbox ruff check --output-format=github netbox_diode_plugin
23+
@$(MAKE) docker-compose-netbox-plugin-down
24+
2025
.PHONY: docker-compose-netbox-plugin-test-cover
2126
docker-compose-netbox-plugin-test-cover:
2227
-@$(DOCKER_COMPOSE) -f docker/docker-compose.yaml -f docker/docker-compose.test.yaml run --rm -u root -e COVERAGE_FILE=/opt/netbox/netbox/coverage/.coverage netbox sh -c "coverage run --source=netbox_diode_plugin --omit=*/migrations/* ./manage.py test --keepdb netbox_diode_plugin && coverage xml -o /opt/netbox/netbox/coverage/report.xml && coverage report -m | tee /opt/netbox/netbox/coverage/report.txt"

0 commit comments

Comments
 (0)