Skip to content

Commit 949e909

Browse files
authored
Merge pull request #211 from stronk7/remove_old_npm_stuff_forever
Remove old npm stuff forever
2 parents 6871038 + f343c8c commit 949e909

33 files changed

+142
-280
lines changed

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: php
22

33
os: linux
4-
dist: xenial
4+
dist: focal
55

66
addons:
77
apt:
@@ -10,13 +10,16 @@ addons:
1010

1111
cache:
1212
directories:
13-
- $HOME/cachedir
13+
- $HOME/cachedir
1414

1515
services:
1616
- mysql
1717

1818
php:
19-
- 7.4
19+
- 7.4
20+
21+
node:
22+
- 16
2023

2124
env:
2225
- TEST_SUITE="0-*"
@@ -29,10 +32,10 @@ before_install:
2932

3033
install:
3134
- git clone --depth 1 https://github.com/bats-core/bats-core.git $HOME/bats-core
32-
- nvm install 8.9
33-
- nvm use 8.9
35+
# Install local_ci own dependencies
3436
- travis_retry composer install
35-
- npm install
37+
- travis_retry npm install
38+
# Performance for MySQL.
3639
- echo -e "[server]\ninnodb_flush_log_at_trx_commit=0" | sudo tee -a /etc/mysql/my.cnf # General speed bump.
3740
# Move MySQL data to tmpfs (see core travis). Without that we get random timeouts here and there.
3841
- sudo mkdir /mnt/ramdisk

grunt_process/grunt_process.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ rm -fr ${outputfile}.stderr
3535
# Prepare all the npm stuff if needed
3636
# (only if the job is in charge of handling it, aka, $npminstall was passed
3737
if [[ -n ${npminstall} ]]; then
38-
. ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh
38+
source ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh
3939
fi
4040

4141
# Ensure we have grunt cli available before continue.

php_lint/php_lint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ for mfile in ${mfiles} ; do
6262
fullpath=$gitdir/$mfile
6363

6464
if [ -e $fullpath ] ; then
65-
if LINTERRORS=$(($phpcmd -l $fullpath >/dev/null) 2>&1)
65+
# We have to ensure that error_log is not set because it makes the
66+
# CLI to add blank lines to output. Crazy but true.
67+
if LINTERRORS=$(($phpcmd -d error_log= -l $fullpath >/dev/null) 2>&1)
6668
then
6769
echo "$fullpath - OK"
6870
else

rebase_security/rebase_security.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ then
185185
loops=0
186186

187187
# Ensure (gruntcmd or (recesscmd and shiftercmd)) are available (depends on $gitbranch)
188-
. ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh
188+
source ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh
189189

190190
fix_conflict
191191
until $gitcmd rebase --continue; do

remote_branch_checker/lib.php

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ public function run($format, $patchset) {
9090
}
9191
}
9292

93-
// For the 'js coding style problems section', conditionally use eslint or jshint
9493
if (file_exists($this->directory . '/eslint.xml')) {
95-
// Process the jshint output, weighting errors with 5 and warnings with 1
94+
// Process the eslint output, weighting errors with 5 and warnings with 1
9695
$params = array(
9796
'title' => 'Javascript coding style problems',
9897
'abbr' => 'js',
@@ -107,22 +106,6 @@ public function run($format, $patchset) {
107106
$smurf->appendChild($snode);
108107
}
109108
}
110-
} else {
111-
// Process the jshint output, weighting errors with 5 and warnings with 1
112-
$params = array(
113-
'title' => 'Javascript coding style problems',
114-
'abbr' => 'js',
115-
'description' => 'This section shows the coding style problems detected in the code by jshint',
116-
'url' => 'https://docs.moodle.org/dev/Javascript/Coding_style',
117-
'codedir' => dirname($this->directory) . '/',
118-
'errorweight' => 5,
119-
'warningweight' => 1);
120-
if ($node = $this->apply_xslt($params, $this->directory . '/jshint.xml', 'checkstyle2smurf.xsl')) {
121-
if ($check = $node->getElementsByTagName('check')->item(0)) {
122-
$snode = $doc->importNode($check, true);
123-
$smurf->appendChild($snode);
124-
}
125-
}
126109
}
127110

128111
if (file_exists($this->directory . '/stylelint.xml')) {
@@ -141,22 +124,6 @@ public function run($format, $patchset) {
141124
$smurf->appendChild($snode);
142125
}
143126
}
144-
} else {
145-
// Process the csslint output, weighting errors with 5 and warnings with 1
146-
$params = array(
147-
'title' => 'CSS problems',
148-
'abbr' => 'css',
149-
'description' => 'This section shows CSS problems detected by csslint',
150-
'url' => 'https://github.com/CSSLint/csslint/wiki/Rules', //TODO: MDLSITE-1796 Create CSS guidelines and link them here.
151-
'codedir' => dirname($this->directory) . '/',
152-
'errorweight' => 5,
153-
'warningweight' => 1);
154-
if ($node = $this->apply_xslt($params, $this->directory . '/csslint.xml', 'checkstyle2smurf.xsl')) {
155-
if ($check = $node->getElementsByTagName('check')->item(0)) {
156-
$snode = $doc->importNode($check, true);
157-
$smurf->appendChild($snode);
158-
}
159-
}
160127
}
161128

162129
// Process the docs output, weighting errors with 3 and warnings with 1

remote_branch_checker/remote_branch_checker.sh

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env bash
22
# $gitcmd: Path to git executable.
33
# $phpcmd: Path to php executable.
4-
# $jshintcmd: Path to jshint executable.
5-
# $csslintcmd: Path to csslint executable.
64
# $remote: Remote repo where the branch to check resides.
75
# $branch: Remote branch we are going to check.
86
# $integrateto: Local branch where the remote branch is going to be integrated.
@@ -22,7 +20,7 @@ set +x
2220
set -e
2321

2422
# Verify everything is set
25-
required="WORKSPACE gitcmd phpcmd jshintcmd csslintcmd remote branch integrateto issue"
23+
required="WORKSPACE gitcmd phpcmd remote branch integrateto issue"
2624
for var in ${required}; do
2725
if [ -z "${!var}" ]; then
2826
echo "Error: ${var} environment variable is not defined. See the script comments."
@@ -287,8 +285,6 @@ echo "${WORKSPACE}/version.php" >> ${WORKSPACE}/work/patchset.files
287285
echo "${WORKSPACE}/config-dist.php" >> ${WORKSPACE}/work/patchset.files
288286

289287
# Add linting config files to patchset files to avoid it being deleted for use later..
290-
echo '.jshint' >> ${WORKSPACE}/work/patchset.files
291-
echo '.csslintrc' >> ${WORKSPACE}/work/patchset.files
292288
echo '.eslintrc' >> ${WORKSPACE}/work/patchset.files
293289
echo '.eslintignore' >> ${WORKSPACE}/work/patchset.files
294290
echo '.stylelintrc' >> ${WORKSPACE}/work/patchset.files
@@ -300,7 +296,7 @@ echo "Info: Calculating excluded files"
300296

301297
echo "Info: Preparing npm"
302298
# Everything is ready, let's install all the required node stuff that some tools will use.
303-
. ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh >> "${WORKSPACE}/work/prepare_npm.txt" 2>&1
299+
source ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh >> "${WORKSPACE}/work/prepare_npm.txt" 2>&1
304300

305301
# Before deleting all the files not part of the patchest we calculate the
306302
# complete list of valid components (plugins, subplugins and subsystems)
@@ -514,43 +510,6 @@ else
514510
--path=${WORKSPACE} --format=xml --componentsfile="${WORKSPACE}/work/valid_components.txt" > "${WORKSPACE}/work/docs.xml"
515511
fi
516512

517-
# Exclude build directories from the results (e.g. lib/yui/build, lib/amd/build/)
518-
find $WORKSPACE -type d -path \*/build | sed "s|$WORKSPACE/||" > $WORKSPACE/.jshintignore
519-
520-
# Run jshint if we haven't got eslint results
521-
if [ ! -f "${WORKSPACE}/work/eslint.xml" ]; then
522-
echo "Info: Running jshint..."
523-
${jshintcmd} --config $WORKSPACE/.jshintrc --exclude-path $WORKSPACE/.jshintignore \
524-
--reporter=checkstyle ${WORKSPACE} > "${WORKSPACE}/work/jshint.xml"
525-
fi
526-
527-
# Run csslint if we haven't got stylelint results
528-
if [ ! -f "${WORKSPACE}/work/stylelint.xml" ]; then
529-
echo "Info: Running csslint..."
530-
if [ ! -f ${WORKSPACE}/.csslintrc ]; then
531-
echo "csslintrc file not found, defaulting to error checking only"
532-
echo '--errors=errors' > ${WORKSPACE}/.csslintrc
533-
echo '--exclude-list=vendor/,lib/editor/tinymce/,lib/yuilib/,theme/bootstrapbase/style/' >> ${WORKSPACE}/.csslintrc
534-
fi
535-
536-
${csslintcmd} --format=checkstyle-xml --quiet ${WORKSPACE} > "${WORKSPACE}/work/csslint.out"
537-
# Unfortunately csslint doesn't give us decent error codes.. so we have to grep:
538-
if grep -q '<?xml' ${WORKSPACE}/work/csslint.out
539-
then
540-
echo "Info: csslint check completed."
541-
mv ${WORKSPACE}/work/csslint.out ${WORKSPACE}/work/csslint.xml
542-
elif grep -q 'No files specified.' ${WORKSPACE}/work/csslint.out
543-
then
544-
echo "Info: No checkable CSS files detected in patchset."
545-
echo $emptycheckstyle > "${WORKSPACE}/work/csslint.xml"
546-
else
547-
echo "Error: Unknown csslint error occured. See csslint.out" >> ${errorfile}
548-
echo 'csslint exited with error:'
549-
cat ${WORKSPACE}/work/csslint.out
550-
exit 1
551-
fi
552-
fi
553-
554513
# ########## ########## ########## ##########
555514

556515
# Everything has been generated in the work directory, generate the report, observing $filtering

tests/1-compare_databases.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ setup () {
107107
assert_output --partial 'Column status of table enrol_lti_app_registration difference found in has_default: true !== false'
108108
assert_output --partial 'Column status of table enrol_lti_app_registration difference found in default_value: 0 !== null'
109109
assert_output --partial 'Column hidden of table grade_categories difference found in type: tinyint !== bigint'
110-
assert_output --partial 'Column hidden of table grade_categories difference found in max_length: 2 !== 18'
110+
assert_output --regexp 'Column hidden of table grade_categories difference found in max_length: 2 !== 1[89]'
111111
assert_output --partial 'Column hidden of table grade_categories_history difference found in type: tinyint !== bigint'
112-
assert_output --partial 'Column hidden of table grade_categories_history difference found in max_length: 2 !== 18'
112+
assert_output --regexp 'Column hidden of table grade_categories_history difference found in max_length: 2 !== 1[89]'
113113
assert_output --partial 'Error: Problem comparing databases ci_installed_'
114114
assert_output --partial 'Error: Process ended with 1 errors'
115115
refute_output --partial 'Ok: Process ended without errors'

tests/1-grunt_process.bats

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
load libs/shared_setup
44

55
setup () {
6-
create_git_branch MOODLE_32_STABLE v3.2.6
6+
create_git_branch MOODLE_39_STABLE v3.9.0
77

88
export npminstall=1
99
}
@@ -15,9 +15,9 @@ setup () {
1515
assert_output --partial "OK: All modules are perfectly processed by grunt"
1616
}
1717

18-
@test "grunt_process: Uncommited .less change" {
19-
# Create less change
20-
git_apply_fixture 32-grunt-less-unbuilt.patch
18+
@test "grunt_process: Uncommited .scss change" {
19+
# Create scss change
20+
git_apply_fixture 39-grunt-scss-unbuilt.patch
2121

2222
# Run test
2323
ci_run grunt_process/grunt_process.sh
@@ -26,12 +26,12 @@ setup () {
2626
assert_failure
2727
assert_output --partial "Done." # Grunt shouldn't have an issue here.
2828
assert_output --partial "WARN: Some modules are not properly processed by grunt. Changes detected:"
29-
assert_output --regexp "GRUNT-CHANGE: (.*)/theme/bootstrapbase/style/moodle.css"
29+
assert_output --regexp "GRUNT-CHANGE: (.*)/theme/boost/style/moodle.css"
3030
}
3131

3232
@test "grunt_process: Uncommited .js change" {
3333
# Create js change.
34-
git_apply_fixture 32-grunt-js-unbuilt.patch
34+
git_apply_fixture 39-grunt-js-unbuilt.patch
3535

3636
# Run test
3737
ci_run grunt_process/grunt_process.sh

tests/2-remote_branch_checker.bats

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,9 @@
22

33
load libs/shared_setup
44

5-
# TODO: we will get rid of these depencies soon.
6-
prepare_prechecker_npmbins () {
7-
npmglobals=$LOCAL_CI_TESTS_CACHEDIR/prechecker_npmglobals
8-
9-
mkdir -p $npmglobals
10-
cd $npmglobals
11-
12-
export csslintcmd=$npmglobals/node_modules/.bin/csslint
13-
if [[ ! -f $csslintcmd ]]; then
14-
npm --silent install csslint
15-
fi
16-
17-
export jshintcmd=$npmglobals/node_modules/.bin/jshint
18-
if [[ ! -f $jshintcmd ]]; then
19-
npm --silent install jshint
20-
fi
21-
cd $OLDPWD
22-
}
23-
245
setup () {
25-
prepare_prechecker_npmbins
26-
27-
create_git_branch MOODLE_34_STABLE v3.4.0 # Must be always a .0 version coz we precheck it in master.
6+
# This was the first .0 version coming with .nvmrc file, so it's the minimum supported by local_ci.
7+
create_git_branch MOODLE_38_STABLE v3.8.0 # Must be always a .0 version coz we precheck it in master.
288
export WORKSPACE=$gitdir
299
export phpcsstandard=$LOCAL_CI_TESTS_PHPCS_DIR
3010
}
@@ -53,70 +33,69 @@ assert_prechecker () {
5333

5434
@test "remote_branch_checker/remote_branch_checker.sh: old branch failing" {
5535
# An extremely old branch running jshint..
56-
assert_prechecker local_ci_fixture_oldbranch MDLSITE-3899 b3f5865eabbbdd439ac7f2ec763046f2ac7f0b37
36+
assert_prechecker local_ci_fixture_oldbranch MDLSITE-3899 v2.9.0-rc1
5737
}
5838

5939
@test "remote_branch_checker/remote_branch_checker.sh: all possible checks failing" {
6040
# A branch with a good number of errors
61-
assert_prechecker local_ci_fixture_manyproblems MDL-53136 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
41+
assert_prechecker local_ci_fixture_manyproblems_38 MDL-53136 v3.8.0
6242
}
6343

6444
@test "remote_branch_checker/remote_branch_checker.sh: all checks passing" {
65-
# from https://integration.moodle.org/job/Precheck%20remote%20branch/25996/
66-
assert_prechecker MDL-53572-master-8ce58c9 MDL-53572 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
45+
assert_prechecker local_ci_fixture_all_passing MDL-53572 v3.9.0
6746
}
6847

6948
@test "remote_branch_checker/remote_branch_checker.sh: stylelint checks" {
70-
assert_prechecker prechecker-fixture-stylelint MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
49+
assert_prechecker local_ci_fixture_stylelint MDL-12345 v3.9.0
7150
}
7251

7352
@test "remote_branch_checker/remote_branch_checker.sh: all results reported despite no php/js/css files" {
7453
# Ensure we always report each section, even if there are no php/css/js files to check
75-
assert_prechecker fixture-non-code-update MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
54+
assert_prechecker local_ci_fixture_noncode_update MDL-12345 v3.9.0
7655
}
7756

7857
@test "remote_branch_checker/remote_branch_checker.sh: thirdparty css modification" {
79-
# Ensure stylelint doesn't complain about the third party css, but thirdpart does
58+
# Ensure stylelint doesn't complain about the third party css, but thirdparty does
8059
# TODO: thirdparty check bug with reporting same file twice..
81-
assert_prechecker fixture-thirdparty-css MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
60+
assert_prechecker local_ci_fixture_thirdparty_css MDL-12345 v3.9.0
8261
}
8362

8463
@test "remote_branch_checker/remote_branch_checker.sh: upgrade external backup" {
85-
assert_prechecker local_ci_fixture_upgrade_external_backup MDL-12345 c69c33b14d9fb83ca22bde558169e36b5e1047cf
64+
assert_prechecker local_ci_fixture_upgrade_external_backup MDL-12345 v4.0.0
8665
}
8766

8867
@test "remote_branch_checker/remote_branch_checker.sh: upgrade external backup skipped for plugins" {
8968
# With branches named PLUGIN-xxxx, the upgrade_external_backup check will be skipped,
9069
# no matter the verified branch has 3 warnings when running for non plugins.
91-
assert_prechecker local_ci_fixture_upgrade_external_backup_skipped_for_plugins PLUGIN-12345 c69c33b14d9fb83ca22bde558169e36b5e1047cf
70+
assert_prechecker local_ci_fixture_upgrade_external_backup_skipped_for_plugins PLUGIN-12345 v4.0.0
9271
}
9372

9473
@test "remote_branch_checker/remote_branch_checker.sh: phpcs aware of all components" {
9574
assert_prechecker local_ci_fixture_phpcs_aware_components MDL-12345 c69c33b14d9fb83ca22bde558169e36b5e1047cf
9675
}
9776

9877
@test "remote_branch_checker/remote_branch_checker.sh: bad amos script" {
99-
assert_prechecker fixture-bad-amos-commands MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
78+
assert_prechecker local_ci_fixture_bad_amos_command MDL-12345 v3.9.0
10079
}
10180

10281
@test "remote_branch_checker/remote_branch_checker.sh: good amos commands" {
103-
assert_prechecker fixture-good-amos-commit MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
82+
assert_prechecker local_ci_fixture_good_amos_commit MDL-12345 v3.9.0
10483
}
10584

10685
@test "remote_branch_checker/remote_branch_checker.sh: mustache lint" {
107-
assert_prechecker fixture-mustache-lint MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
86+
assert_prechecker local_ci_fixture_mustache_lint MDL-12345 v3.9.0
10887
}
10988

11089
@test "remote_branch_checker/remote_branch_checker.sh: mustache lint eslint problem" {
111-
assert_prechecker fixture-mustache-lint-js MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
90+
assert_prechecker local_ci_fixture_mustache_lint_js MDL-12345 v3.9.0
11291
}
11392

11493
@test "remote_branch_checker/remote_branch_checker.sh: gherkin lint" {
115-
assert_prechecker fixture-gherkin-lint MDL-12345 f968cd44e8ee5d54b1bc56823040ff770dbf18af
94+
assert_prechecker local_ci_fixture_gherkin_lint MDL-12345 v3.9.0
11695
}
11796

11897
@test "remote_branch_checker/remote_branch_checker.sh: grunt build failed" {
119-
assert_prechecker fixture-grunt-build-failed MDL-12345 665c3ac59c35b7387a4fc70b8ac6600ce9ffeb87
98+
assert_prechecker local_ci_fixture_grunt_build_failed MDL-12345 v3.9.0
12099
}
121100

122101
@test "remote_branch_checker/remote_branch_checker.sh: remote which doesnt exist" {

0 commit comments

Comments
 (0)