[fix] build workflows of the themes
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
		
							parent
							
								
									e4f8f0483f
								
							
						
					
					
						commit
						a262859742
					
				
							
								
								
									
										7
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Makefile
									
									
									
									
									
								
							| @ -50,7 +50,7 @@ search.checker.%: install | |||||||
| 	$(Q)./manage pyenv.cmd searxng-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))" | 	$(Q)./manage pyenv.cmd searxng-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))" | ||||||
| 
 | 
 | ||||||
| PHONY += test ci.test test.shell | PHONY += test ci.test test.shell | ||||||
| ci.test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.pybabel | ci.test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.pybabel test.themes | ||||||
| test:    test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.shell | test:    test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.shell | ||||||
| test.shell: | test.shell: | ||||||
| 	$(Q)shellcheck -x -s dash \
 | 	$(Q)shellcheck -x -s dash \
 | ||||||
| @ -83,8 +83,9 @@ MANAGE += node.env node.env.dev node.clean | |||||||
| MANAGE += py.build py.clean | MANAGE += py.build py.clean | ||||||
| MANAGE += pyenv pyenv.install pyenv.uninstall | MANAGE += pyenv pyenv.install pyenv.uninstall | ||||||
| MANAGE += format.python | MANAGE += format.python | ||||||
| MANAGE += test.yamllint test.pylint test.pyright test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean | MANAGE += test.yamllint test.pylint test.pyright test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean test.themes | ||||||
| MANAGE += themes.all themes.simple themes.simple.test pygments.less | MANAGE += themes.all themes.fix themes.test | ||||||
|  | MANAGE += themes.simple themes.simple.pygments themes.simple.fix | ||||||
| MANAGE += static.build.commit static.build.drop static.build.restore | MANAGE += static.build.commit static.build.drop static.build.restore | ||||||
| MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs | MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,7 +6,8 @@ Development Quickstart | |||||||
| 
 | 
 | ||||||
| .. _npm: https://www.npmjs.com/ | .. _npm: https://www.npmjs.com/ | ||||||
| .. _Node.js: https://nodejs.org/ | .. _Node.js: https://nodejs.org/ | ||||||
| 
 | .. _eslint: https://eslint.org/ | ||||||
|  | .. _stylelint: https://stylelint.io/ | ||||||
| 
 | 
 | ||||||
| .. sidebar:: further read | .. sidebar:: further read | ||||||
| 
 | 
 | ||||||
| @ -40,7 +41,8 @@ to our ":ref:`how to contribute`" guideline. | |||||||
| 
 | 
 | ||||||
| If you implement themes, you will need to setup a :ref:`Node.js environment | If you implement themes, you will need to setup a :ref:`Node.js environment | ||||||
| <make node.env>`.  Before you call *make run* (2.), you need to compile the | <make node.env>`.  Before you call *make run* (2.), you need to compile the | ||||||
| modified styles and JavaScript: ``make node.clean themes.all`` | modified styles and JavaScript: ``make node.clean themes.all``.  If eslint_ or | ||||||
|  | stylelint_ report some issues, try ``make themes.fix``. | ||||||
| 
 | 
 | ||||||
| Alternatively you can also compile selective the theme you have modified, | Alternatively you can also compile selective the theme you have modified, | ||||||
| e.g. the *simple* theme. | e.g. the *simple* theme. | ||||||
|  | |||||||
| @ -21,9 +21,10 @@ module.exports = function (grunt) { | |||||||
|     pkg: grunt.file.readJSON('package.json'), |     pkg: grunt.file.readJSON('package.json'), | ||||||
|     watch: { |     watch: { | ||||||
|       scripts: { |       scripts: { | ||||||
|         files: ['gruntfile.js', 'src/**'], |         files: ['gruntfile.js', 'eslint.config.mjs', '.stylelintrc.json', 'src/**'], | ||||||
|         tasks: [ |         tasks: [ | ||||||
|           'eslint', |           'eslint', | ||||||
|  | 	  'stylelint', | ||||||
|           'copy', |           'copy', | ||||||
|           'uglify', |           'uglify', | ||||||
|           'less', |           'less', | ||||||
| @ -49,6 +50,7 @@ module.exports = function (grunt) { | |||||||
|     stylelint: { |     stylelint: { | ||||||
|       options: { |       options: { | ||||||
|         formatter: 'unix', |         formatter: 'unix', | ||||||
|  |         fix: grunt.option('fix') | ||||||
|       }, |       }, | ||||||
|       src: [ |       src: [ | ||||||
|         'src/less/**/*.less', |         'src/less/**/*.less', | ||||||
| @ -298,7 +300,7 @@ module.exports = function (grunt) { | |||||||
|   grunt.loadNpmTasks('grunt-stylelint'); |   grunt.loadNpmTasks('grunt-stylelint'); | ||||||
|   grunt.loadNpmTasks('grunt-eslint'); |   grunt.loadNpmTasks('grunt-eslint'); | ||||||
| 
 | 
 | ||||||
|   grunt.registerTask('test', ['eslint']); |   grunt.registerTask('test', ['eslint', 'stylelint']); | ||||||
| 
 | 
 | ||||||
|   grunt.registerTask('default', [ |   grunt.registerTask('default', [ | ||||||
|     'eslint', |     'eslint', | ||||||
|  | |||||||
| @ -29,12 +29,13 @@ | |||||||
|   "scripts": { |   "scripts": { | ||||||
|     "all": "npm install && grunt", |     "all": "npm install && grunt", | ||||||
|     "build": "grunt", |     "build": "grunt", | ||||||
|     "test": "grunt test", |     "clean": "rm -Rf node_modules", | ||||||
|     "eslint": "grunt eslint", |     "eslint": "grunt eslint", | ||||||
|     "eslint-fix": "grunt eslint --fix", |     "eslint-fix": "grunt eslint --fix", | ||||||
|     "watch": "grunt watch", |     "fix": "grunt test --fix", | ||||||
|     "clean": "rm -Rf node_modules", |  | ||||||
|     "stylelint": "grunt stylelint", |     "stylelint": "grunt stylelint", | ||||||
|     "stylelint-fix": "grunt stylelint --fix" |     "stylelint-fix": "grunt stylelint --fix", | ||||||
|  |     "test": "grunt test", | ||||||
|  |     "watch": "grunt watch --fix" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -100,7 +100,8 @@ static.build.commit() { | |||||||
|     static.build.drop &>/dev/null |     static.build.drop &>/dev/null | ||||||
| 
 | 
 | ||||||
|     (   set -e |     (   set -e | ||||||
|         # build the themes |         # fix & build the themes | ||||||
|  | 	themes.fix | ||||||
|         themes.all |         themes.all | ||||||
| 
 | 
 | ||||||
|         # add build files |         # add build files | ||||||
|  | |||||||
| @ -89,7 +89,6 @@ test.robot() { | |||||||
|     dump_return $? |     dump_return $? | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| test.rst() { | test.rst() { | ||||||
|     build_msg TEST "[reST markup] ${RST_FILES[*]}" |     build_msg TEST "[reST markup] ${RST_FILES[*]}" | ||||||
| 
 | 
 | ||||||
| @ -98,6 +97,12 @@ test.rst() { | |||||||
|     done |     done | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | test.themes() { | ||||||
|  |     build_msg TEST 'SearXNG themes' | ||||||
|  |     themes.test | ||||||
|  |     dump_return $? | ||||||
|  | } | ||||||
|  | 
 | ||||||
| test.pybabel() { | test.pybabel() { | ||||||
|     TEST_BABEL_FOLDER="build/test/pybabel" |     TEST_BABEL_FOLDER="build/test/pybabel" | ||||||
|     build_msg TEST "[extract messages] pybabel" |     build_msg TEST "[extract messages] pybabel" | ||||||
|  | |||||||
| @ -7,21 +7,41 @@ declare _creset | |||||||
| themes.help(){ | themes.help(){ | ||||||
|     cat <<EOF |     cat <<EOF | ||||||
| themes.: | themes.: | ||||||
|   all       : build all themes |   all       : test & build all themes | ||||||
|   live      : to get live builds of CSS & JS use 'LIVE_THEME=simple make run' |   test      : test all themes | ||||||
|   simple.:    build simple theme |   fix       : fix JS & CSS (LESS) | ||||||
|     test    : test simple theme |   live      : to get live builds of CSS & JS use: LIVE_THEME=simple make run | ||||||
|  |   simple.:    test & build simple theme .. | ||||||
|     pygments: build pygment's LESS files for simple theme |     pygments: build pygment's LESS files for simple theme | ||||||
|  |     test    : test simple theme | ||||||
|  |     fix     : fix JS & CSS (LESS) of the simple theme | ||||||
| EOF | EOF | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| themes.all() { | themes.all() { | ||||||
|     (   set -e |     (   set -e | ||||||
|  | 	node.env | ||||||
|         themes.simple |         themes.simple | ||||||
|     ) |     ) | ||||||
|     dump_return $? |     dump_return $? | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | themes.fix() { | ||||||
|  |     (   set -e | ||||||
|  | 	node.env | ||||||
|  |         themes.simple.fix | ||||||
|  |     ) | ||||||
|  |     dump_return $? | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | themes.test() { | ||||||
|  |     (   set -e | ||||||
|  | 	node.env | ||||||
|  |         themes.simple.test | ||||||
|  |     ) | ||||||
|  |     dump_return $? | ||||||
|  | } | ||||||
|  | 
 | ||||||
| themes.live() { | themes.live() { | ||||||
|     local LIVE_THEME="${LIVE_THEME:-${1}}" |     local LIVE_THEME="${LIVE_THEME:-${1}}" | ||||||
|     case "${LIVE_THEME}" in |     case "${LIVE_THEME}" in | ||||||
| @ -29,30 +49,30 @@ themes.live() { | |||||||
|             theme="searx/static/themes/${LIVE_THEME}" |             theme="searx/static/themes/${LIVE_THEME}" | ||||||
|             ;; |             ;; | ||||||
|         '') |         '') | ||||||
|             die_caller 42 "missing theme argument" |             die 42 "missing theme argument" | ||||||
|             ;; |             ;; | ||||||
|         *) |         *) | ||||||
|             die_caller 42 "unknown theme '${LIVE_THEME}' // [simple]'" |             die 42 "unknown theme '${LIVE_THEME}' // [simple]'" | ||||||
|             ;; |             ;; | ||||||
|     esac |     esac | ||||||
|     build_msg GRUNT "theme: $1 (live build)" |     build_msg SIMPLE "theme: $1 (live build)" | ||||||
|     nodejs.ensure |     node.env | ||||||
|  |     themes.simple.pygments | ||||||
|     cd "${theme}" |     cd "${theme}" | ||||||
|     { |     { | ||||||
|         npm install |  | ||||||
|         npm run watch |         npm run watch | ||||||
|     } 2>&1 \ |     } # 2>&1 \ | ||||||
|         | prefix_stdout "${_Blue}THEME ${1} ${_creset}  " \ |       #       | prefix_stdout "${_Blue}THEME ${1} ${_creset}  " \ | ||||||
|         | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |' |       #       | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| themes.simple() { | themes.simple() { | ||||||
|     (   set -e |     (   set -e | ||||||
| 	node.env |  | ||||||
| 	themes.simple.pygments | 	themes.simple.pygments | ||||||
|     ) | 	build_msg SIMPLE "theme: run build" | ||||||
|     build_msg GRUNT "theme: simple" | 	# "run build" includes tests from eslint and stylelint | ||||||
| 	npm --prefix searx/static/themes/simple run build | 	npm --prefix searx/static/themes/simple run build | ||||||
|  |     ) | ||||||
|     dump_return $? |     dump_return $? | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -67,11 +87,14 @@ themes.simple.pygments() { | |||||||
|     return 0 |     return 0 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | themes.simple.fix() { | ||||||
|  |     build_msg SIMPLE "theme: fix" | ||||||
|  |     npm --prefix searx/static/themes/simple run fix | ||||||
|  |     dump_return $? | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| themes.simple.test() { | themes.simple.test() { | ||||||
|     build_msg TEST "theme: simple" |     build_msg SIMPLE "theme: run test" | ||||||
|     node.env |  | ||||||
|     npm --prefix searx/static/themes/simple install |  | ||||||
|     npm --prefix searx/static/themes/simple run test |     npm --prefix searx/static/themes/simple run test | ||||||
|     dump_return $? |     dump_return $? | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user