Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Bash code review #209

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.bpan/
/.venv/
/tests/__pycache__/
/__pycache__/
11 changes: 11 additions & 0 deletions .setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ SHELL := bash
.DELETE_ON_ERROR:
.SECONDEXPANSION:

define run-with
$(if $(shell command -v $1), \
$3, \
$(error ERROR: Can't 'make $2'. No '$1' command found.))
endef

ifeq (,$(shell git diff --stat))
GIT_STATUS_IS_CLEAN := 1
endif

PYTHON := $(shell command -v python3 || command -v python)
ifeq (,$(and $(PYTHON),$(findstring Python 3.,$(shell $(PYTHON) --version))))
$(error Python 3 not installed for testing)
endif
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ endif
endif

BPAN := .bpan
VENV := .venv

export PATH := .venv/bin:$(PATH)

#------------------------------------------------------------------------------
# User targets
Expand All @@ -20,9 +22,10 @@ test: checkstyle test-unit
test-unit: test-bash test-python

test-bash: $(BPAN)
prove -r $(if $v,-v )$(test)
$(call run-with,prove,$@,\
prove -r $(if $v,-v )$(test))

test-python:
test-python: $(VENV)
py.test tests

test-online:
Expand All @@ -34,24 +37,28 @@ test-online:
checkstyle: test-shellcheck test-yaml

test-shellcheck:
@which shellcheck >/dev/null 2>&1 || echo "Command 'shellcheck' not found, can not execute shell script checks"
shellcheck -x $$(file --mime-type * | sed -n 's/^\(.*\):.*text\/x-shellscript.*$$/\1/p')
$(call run-with,shellcheck,$@,\
shellcheck -x $$(grep -rEl '^#!/.*sh' [a-z]* | grep -v '\.swp$$' | sort))

test-yaml:
@which yamllint >/dev/null 2>&1 || echo "Command 'yamllint' not found, can not execute YAML syntax checks"
yamllint --strict $$(git ls-files "*.yml" "*.yaml" ":!external/")
$(call run-with,yamllint,$@,\
yamllint --strict $$(git ls-files "*.yml" "*.yaml" ":!external/"))

update-deps:
tools/update-deps --specfile dist/rpm/os-autoinst-scripts-deps.spec

clean:
$(RM) job_post_response
$(RM) -r $(BPAN)
$(RM) -r $(BPAN) $(VENV)
$(RM) -r .pytest_cache/
find . -name __pycache__ | xargs -r $(RM) -r

#------------------------------------------------------------------------------
# Internal targets
#------------------------------------------------------------------------------
$(BPAN):
git clone https://github.com/bpan-org/bpan.git --depth 1 $@
git clone --quiet https://github.com/bpan-org/bpan.git --depth 1 $@

$(VENV):
$(PYTHON) -m venv $@
pip install pytest requests &>/dev/null
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ false matches of job failures unrelated to the specified ticket.
example from progress.opensuse.org, label the job and retrigger if specified
in the issue (see the source code for details how to mark tickets)

For tickets referencing "auto_review" it is suggested to add a text section based on the following template:
For tickets referencing "auto_review" it is suggested to add a text section
based on the following template:

```
## Steps to reproduce
Expand Down Expand Up @@ -183,7 +184,9 @@ It will be automatically cloned.
make checkstyle

#### openqa-label-known-issues
Generate a list of recent incomplete jobs of your local openQA instance. Here's an example using `psql`:

Generate a list of recent incomplete jobs of your local openQA instance. Here's
an example using `psql`:

```
psql \
Expand Down
Loading