Skip to content

Commit

Permalink
test: Move static-code into common/
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinpitt authored and jelly committed Dec 5, 2024
1 parent 093e39c commit e395923
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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:

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ distcheck-hook::
# -----------------------------------------------------------------------------

TESTS = \
test/static-code \
test/common/static-code \
$(NULL)

clean-local::
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
File renamed without changes.
6 changes: 3 additions & 3 deletions tools/git-hook-post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e395923

Please sign in to comment.