test: Move static-code into common/

It conceptually fits better there, as it's shared by all external
projects. That makes importing easier as it doesn't have to be
enumerated separately in COCKPIT_REPO_FILES any more.
This commit is contained in:
Martin Pitt 2024-12-05 11:57:05 +01:00 committed by Jelle van der Waa
parent 093e39c861
commit e395923115
5 changed files with 11 additions and 11 deletions

View file

@ -180,14 +180,14 @@ down after the fact — without re-running tests — using something like:
There are also static code and syntax checks which you should run often:
test/static-code
test/common/static-code
It is highly recommended to set up a git pre-push hook, to avoid pushing PRs
that will fail on trivial errors:
ln -s ../../tools/git-hook-pre-push .git/hooks/pre-push
This calls `test/static-code` for each commit you're trying to push.
This calls `test/common/static-code` for each commit you're trying to push.
You can also set up a post-commit hook to do the same, after each commit:
@ -255,7 +255,7 @@ The tests require at least `pytest` 7.0.0 or higher to run.
Cockpit uses [ESLint](https://eslint.org/) to automatically check JavaScript
code style in `.js` and `.jsx` files.
The linter is executed as part of `test/static-code`.
The linter is executed as part of `test/common/static-code`.
For developer convenience, the ESLint can be started explicitly by:
@ -277,13 +277,13 @@ unused identifiers, and other JavaScript-related issues.
Cockpit uses [Stylelint](https://stylelint.io/) to automatically check CSS code
style in `.css` and `.scss` files.
The linter is executed as part of `test/static-code`.
The linter is executed as part of `test/common/static-code`.
For developer convenience, the Stylelint can be started explicitly by:
npm run stylelint
But note that this only covers files in `pkg/`. `test/static-code` covers
But note that this only covers files in `pkg/`. `test/common/static-code` covers
*all* (S)CSS files tracked in git.
Some rule violations can be automatically fixed by running:

View file

@ -78,7 +78,7 @@ distcheck-hook::
# -----------------------------------------------------------------------------
TESTS = \
test/static-code \
test/common/static-code \
$(NULL)
clean-local::

View file

@ -220,10 +220,10 @@ deps =
pytest: pytest-cov
pytest: pytest-timeout
pytest: pytest-xdist
allowlist_externals = test/static-code
allowlist_externals = test/common/static-code
setenv =
NO_QUNIT=1
commands =
pytest: python3 -m pytest -opythonpath= {posargs}
lint: test/static-code --tap
lint: test/common/static-code --tap
"""

View file

@ -14,9 +14,9 @@ readonly commit="$(git rev-parse --verify "${1:-HEAD}^{commit}")"
tmpdir="tmp/pre-push/${commit}"
rm -rf "tmp/pre-push/${commit}"
# unpack all of the changed files, plus the test/static-code from that commit
# unpack all of the changed files, plus the test/common/static-code from that commit
changed_files="$(git diff-tree --no-commit-id --no-renames --diff-filter=d --name-only -r "${commit}" --)"
required_files="$(git cat-file -p "${commit}":test/static-code | sed -n 's/^# requires: //p') test/static-code"
required_files="$(git cat-file -p "${commit}":test/common/static-code | sed -n 's/^# requires: //p') test/common/static-code"
git archive --prefix="${tmpdir}/" "${commit}" -- ${changed_files} ${required_files} | tar x
# check that node_modules always gets updated with package.json
@ -32,7 +32,7 @@ fi
cd "${tmpdir}"
git init -qb main .
git add .
WITH_PARTIAL_TREE=1 test/static-code
WITH_PARTIAL_TREE=1 test/common/static-code
)
# paranoia: make sure we delete what we think we will