Skip to content

Commit

Permalink
Refactor unittest workflow and Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Aug 14, 2024
1 parent 2b7341b commit edbb731
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ jobs:
python -m pip install --upgrade pip
pip install --user poetry
make install
- name: Check code style
- name: Prepare Env
run: |
echo "Preparing environment variables"
echo "TOS_ACCESS_KEY=${{ secrets.TOS_ACCESS_KEY }}" >> $GITHUB_ENV
echo "TOS_SECRET_KEY=${{ secrets.TOS_SECRET_KEY }}" >> $GITHUB_ENV
echo "TOS_REGION=${{ vars.TOS_REGION }}" >> $GITHUB_ENV
echo "TOS_ENDPOINT=${{ vars.TOS_ENDPOINT }}" >> $GITHUB_ENV
echo "TOSFS_LOGGING_LEVEL=${{ vars.TOSFS_LOGGING_LEVEL }}" >> $GITHUB_ENV
- name: Run tests
run: make test
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.ONESHELL:
ENV_PREFIX=$(shell poetry env info -p 2>/dev/null || { [ -d "/home/runner/.local" ] && echo "/home/runner/.local"; })/bin/
ENV_PREFIX=$(shell poetry env info -p 2>/dev/null)/bin/
TEST_DIR?="tosfs/tests/"

.PHONY: help
Expand Down Expand Up @@ -28,9 +28,9 @@ show: ## Show the current environment.

.PHONY: install
install: ## Install the project in dev mode.
$(ENV_PREFIX)pip install poetry
$(ENV_PREFIX)poetry lock
$(ENV_PREFIX)poetry install --with dev
pip install poetry
poetry lock
poetry install --with dev

.PHONY: fmt
fmt: ## Format code using black & isort.
Expand All @@ -49,7 +49,7 @@ lint: ## Run pep8, black, mypy linters.

.PHONY: test
test: ## Run tests and generate coverage report.
$(ENV_PREFIX)pytest -v -s --cov-config .coveragerc --cov=tosfs -l --tb=short --maxfail=1 ${TEST_DIR}
$(ENV_PREFIX)pytest -vv -s --cov-config .coveragerc --cov=tosfs -l --tb=short --maxfail=1 ${TEST_DIR}

.PHONY: watch
watch: ## Run tests on every change.
Expand Down

0 comments on commit edbb731

Please sign in to comment.