diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..cf4c387 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 118 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 198d50c..d17ec69 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,3 +21,9 @@ updates: patternfly: patterns: - "@patternfly*" + + - package-ecosystem: "github-actions" + directory: "/" + open-pull-requests-limit: 3 + schedule: + interval: "weekly" diff --git a/.github/workflows/cockpit-lib-update.yml b/.github/workflows/cockpit-lib-update.yml index 2f9de38..d3dfa70 100644 --- a/.github/workflows/cockpit-lib-update.yml +++ b/.github/workflows/cockpit-lib-update.yml @@ -22,7 +22,7 @@ jobs: echo '${{ secrets.GITHUB_TOKEN }}' > ~/.config/github-token - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run cockpit-lib-update run: | diff --git a/.stylelintrc.json b/.stylelintrc.json index aa78cdb..0133e2c 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -1,11 +1,7 @@ { "extends": "stylelint-config-standard-scss", "rules": { - "declaration-colon-newline-after": null, - "selector-list-comma-newline-after": null, - "at-rule-empty-line-before": null, - "declaration-colon-space-before": null, "declaration-empty-line-before": null, "custom-property-empty-line-before": null, "comment-empty-line-before": null, @@ -19,9 +15,7 @@ "declaration-block-single-line-max-declarations": null, "font-family-no-duplicate-names": null, "function-url-quotes": null, - "indentation": null, "keyframes-name-pattern": null, - "max-line-length": null, "no-descending-specificity": null, "no-duplicate-selectors": null, "scss/at-extend-no-missing-placeholder": null, diff --git a/Makefile b/Makefile index c1b06e1..ed388b9 100644 --- a/Makefile +++ b/Makefile @@ -29,10 +29,11 @@ all: $(DIST_TEST) COCKPIT_REPO_FILES = \ pkg/lib \ test/common \ + test/static-code \ $(NULL) COCKPIT_REPO_URL = https://github.com/cockpit-project/cockpit.git -COCKPIT_REPO_COMMIT = fca64d4b989ceadabbfda311b971a41490aa2187 # 310 + 2 commits +COCKPIT_REPO_COMMIT = d2a0a971cde5af5353691ee030620be06c2dbc67 # 310.2 + 1 commits $(COCKPIT_REPO_FILES): $(COCKPIT_REPO_STAMP) COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}' @@ -178,6 +179,9 @@ prepare-check: $(NODE_MODULES_TEST) $(VM_IMAGE) test/common check: prepare-check test/common/run-tests ${RUN_TESTS_OPTIONS} +codecheck: test/static-code $(NODE_MODULES_TEST) + test/static-code + # checkout Cockpit's bots for standard test VM images and API to launch them bots: $(COCKPIT_REPO_STAMP) test/common/make-bots diff --git a/README.md b/README.md index 1bcc677..3371559 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ remove manually the symlink: Cockpit Starter Kit uses [ESLint](https://eslint.org/) to automatically check JavaScript code style in `.js` and `.jsx` files. -eslint is executed within every build. +eslint is executed as part of `test/static-code`, aka. `make codecheck`. For developer convenience, the ESLint can be started explicitly by: @@ -125,7 +125,7 @@ Rules configuration can be found in the `.eslintrc.json` file. Cockpit uses [Stylelint](https://stylelint.io/) to automatically check CSS code style in `.css` and `scss` files. -styleint is executed within every build. +styleint is executed as part of `test/static-code`, aka. `make codecheck`. For developer convenience, the Stylelint can be started explicitly by: @@ -137,12 +137,6 @@ Violations of some rules can be fixed automatically by: Rules configuration can be found in the `.stylelintrc.json` file. -During fast iterative development, you can also choose to not run eslint/stylelint. -This speeds up the build and avoids build failures due to e. g. ill-formatted -css or other issues: - - $ ./build.js -es - # Running tests locally Run `make check` to build an RPM, install it into a standard Cockpit test VM diff --git a/build.js b/build.js index 8fca807..4210743 100755 --- a/build.js +++ b/build.js @@ -11,19 +11,14 @@ import { cockpitCompressPlugin } from './pkg/lib/esbuild-compress-plugin.js'; import { cockpitPoEsbuildPlugin } from './pkg/lib/cockpit-po-plugin.js'; import { cockpitRsyncEsbuildPlugin } from './pkg/lib/cockpit-rsync-plugin.js'; import { esbuildStylesPlugins } from './pkg/lib/esbuild-common.js'; -import { eslintPlugin } from './pkg/lib/esbuild-eslint-plugin.js'; -import { stylelintPlugin } from './pkg/lib/esbuild-stylelint-plugin.js'; const production = process.env.NODE_ENV === 'production'; const useWasm = os.arch() !== 'x64'; const esbuild = (await import(useWasm ? 'esbuild-wasm' : 'esbuild')).default; -const lintDefault = process.env.LINT ? process.env.LINT === '0' : production; const parser = (await import('argparse')).default.ArgumentParser(); parser.add_argument('-r', '--rsync', { help: "rsync bundles to ssh target after build", metavar: "HOST" }); parser.add_argument('-w', '--watch', { action: 'store_true', help: "Enable watch mode", default: process.env.ESBUILD_WATCH === "true" }); -parser.add_argument('-e', '--no-eslint', { action: 'store_true', help: "Disable eslint linting", default: lintDefault }); -parser.add_argument('-s', '--no-stylelint', { action: 'store_true', help: "Disable stylelint linting", default: lintDefault }); const args = parser.parse_args(); if (args.rsync) @@ -55,8 +50,6 @@ function notifyEndPlugin() { }; } -const cwd = process.cwd(); - // similar to fs.watch(), but recursively watches all subdirectories function watch_dirs(dir, on_change) { const callback = (ev, dir, fname) => { @@ -95,8 +88,6 @@ const context = await esbuild.context({ target: ['es2020'], plugins: [ cleanPlugin(), - ...args.no_stylelint ? [] : [stylelintPlugin({ filter: new RegExp(cwd + '\/src\/.*\.(css?|scss?)$') })], - ...args.no_eslint ? [] : [eslintPlugin({ filter: new RegExp(cwd + '\/src\/.*\.(jsx?|js?)$') })], // Esbuild will only copy assets that are explicitly imported and used // in the code. This is a problem for index.html and manifest.json which are not imported copy({ diff --git a/package.json b/package.json index a73b6c8..1eecfc4 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,10 @@ "jed": "1.1.1", "qunit": "2.20.0", "sass": "1.70.0", - "stylelint": "15.11.0", - "stylelint-config-standard": "34.0.0", - "stylelint-config-standard-scss": "11.1.0", - "stylelint-formatter-pretty": "3.2.1" + "stylelint": "16.2.1", + "stylelint-config-standard": "36.0.0", + "stylelint-config-standard-scss": "13.0.0", + "stylelint-formatter-pretty": "4.0.0" }, "dependencies": { "@patternfly/patternfly": "5.2.0", diff --git a/packaging/cockpit-sensors.spec.in b/packaging/cockpit-sensors.spec.in index c87f9ce..5816f11 100644 --- a/packaging/cockpit-sensors.spec.in +++ b/packaging/cockpit-sensors.spec.in @@ -32,7 +32,7 @@ rm -rf dist %endif %build -LINT=0 NODE_ENV=production make +NODE_ENV=production make %install %make_install PREFIX=/usr diff --git a/test/browser/browser.sh b/test/browser/browser.sh index e88aa23..1534d93 100755 --- a/test/browser/browser.sh +++ b/test/browser/browser.sh @@ -5,7 +5,7 @@ export TEST_BROWSER=${TEST_BROWSER:-firefox} TESTS="$(realpath $(dirname "$0"))" export SOURCE="$(realpath $TESTS/../..)" -export LOGS="$(pwd)/logs" +export LOGS="${TMT_TEST_DATA:-$(pwd)/logs}" mkdir -p "$LOGS" chmod a+w "$LOGS" diff --git a/test/run b/test/run index 576d364..5c14f0d 100755 --- a/test/run +++ b/test/run @@ -8,9 +8,5 @@ TEST_SCENARIO="${TEST_SCENARIO:-}" [ "${TEST_SCENARIO}" = "${TEST_SCENARIO##firefox}" ] || export TEST_BROWSER=firefox export RUN_TESTS_OPTIONS=--track-naughties -# linters are off by default for production builds, but we want to run them in CI -export LINT=1 - +make codecheck make check - -ruff check test/check*