Skip to content

Commit 6a686d0

Browse files
authored
Change key creation strategy for CI/CD pytest cache (#88)
* Change key creation strategy for pytest cache * Fix tests, add cache for pip * Adjust pytest settings * Cleanup in Makefile * Disable pytest cache on master and develop branches * Remove accepting less specific cache hits * Newline
1 parent 818bc63 commit 6a686d0

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
cache: "pip"
2122
- name: Install dependencies
2223
run: python -m pip install '.[openai, anthropic]' --group test
2324

@@ -38,13 +39,13 @@ jobs:
3839
INTERNAL_AI_BASE_URL: ${{ secrets.INTERNAL_AI_BASE_URL }}
3940

4041
- name: Restore pytest cache
42+
if: ${{ github.ref }} != "refs/heads/master" && ${{ github.ref }} != "refs/heads/develop"
4143
uses: actions/cache@565629816435f6c0b50676926c9b05c254113c0c
4244
with:
4345
path: .pytest_cache
4446
key: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-${{ github.sha }}
4547
restore-keys: |
4648
pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-
47-
pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-
4849
- name: Run unit tests
4950
run: make test-unit
5051
- name: Run entire test suite

Makefile

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
#
2-
# Conveniences for splunk-sdk development
3-
#
1+
### Conveniences for splunk-sdk-python development
42

5-
CONTAINER_NAME := "splunk"
6-
7-
# VIRTUALENV MANAGEMENT
3+
## VIRTUALENV MANAGEMENT
84

95
# https://docs.astral.sh/uv/reference/cli/#uv-run--upgrade
10-
# --no-config is used to skip all the internal Splunk package indexes
6+
# --no-config skips our Splunk package index
117
.PHONY: uv-sync
128
uv-sync:
13-
@echo "[splunk-sdk] Make sure to tun this only in the repo root!"
14-
uv sync --all-groups --all-extras --no-config
9+
uv sync --no-config
1510

1611
.PHONY: uv-upgrade
1712
uv-upgrade:
18-
@echo "[splunk-sdk] Make sure to run this only in the repo root!"
19-
uv sync --all-groups --all-extras --upgrade --no-config
13+
uv sync --no-config --upgrade
2014

2115
.PHONY: clean
22-
clean:
16+
clean:
2317
rm -rf ./build ./dist ./.venv ./.ruff_cache ./.pytest_cache ./splunk_sdk.egg-info ./__pycache__ ./**/__pycache__
2418

2519
.PHONY: docs
2620
docs:
2721
make -C ./docs html
2822

23+
## TESTING
24+
25+
# -ra generates a report on all failed tests
26+
# -vv lets us see what failed and why the rest of the suite is running
27+
PYTEST_CMD := python -m pytest --no-header -ra -vv
28+
2929
.PHONY: test
3030
test:
31-
# Previously failing tests go first
32-
python -m pytest --ff ./tests
31+
$(PYTEST_CMD) ./tests
3332

3433
.PHONY: test-unit
3534
test-unit:
36-
# Previously failing tests go first
37-
python -m pytest --ff ./tests/unit
35+
$(PYTEST_CMD) ./tests/unit
3836

3937
.PHONY: test-integration
4038
test-integration:
41-
# Previously failing tests go first
42-
python -m pytest --ff ./tests/integration ./tests/system
39+
# Previously failing tests go first
40+
$(PYTEST_CMD) --ff ./tests/integration ./tests/system
4341

4442
.PHONY: test-ai
4543
test-ai:
46-
# Previously failing tests go first
47-
python -m pytest --ff ./tests/integration/ai ./tests/unit/ai
44+
$(PYTEST_CMD) ./tests/integration/ai ./tests/unit/ai
45+
46+
## DOCKER
47+
48+
CONTAINER_NAME := splunk
49+
SPLUNK_HOME := /opt/splunk
4850

4951
.PHONY: docker-up
5052
docker-up:
@@ -81,8 +83,8 @@ docker-refresh: docker-remove docker-start
8183

8284
.PHONY: docker-splunk-restart
8385
docker-splunk-restart:
84-
docker exec -it splunk sudo sh -c '/opt/splunk/bin/splunk restart --run-as-root'
86+
docker exec -it $(CONTAINER_NAME) sudo sh -c '$(SPLUNK_HOME)/bin/splunk restart --run-as-root'
8587

8688
.PHONY: docker-tail-python-log
8789
docker-tail-python-log:
88-
docker exec splunk sudo tail /opt/splunk/var/log/splunk/python.log
90+
docker exec -it $(CONTAINER_NAME) sudo tail $(SPLUNK_HOME)/var/log/splunk/python.log

0 commit comments

Comments
 (0)