Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions grunt_process/grunt_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ if [[ -n ${npminstall} ]]; then
source ${mydir}/../prepare_npm_stuff/prepare_npm_stuff.sh
fi

# Ensure we have grunt cli available before continue.
gruntcmd="$(${npmcmd} bin)"/grunt
if [ ! -x $gruntcmd ]; then
# Ensure we have grunt binary available before continue.
#
if [[ ! -x node_modules/.bin/grunt ]]; then
echo "Error: grunt executable not found" | tee "${outputfile}"
exitstatus=1
else
Expand All @@ -63,7 +63,7 @@ else
fi

set +e
$gruntcmd $tasks --no-color > >(tee "${outputfile}") 2> >(tee "${outputfile}".stderr >&2)
npx grunt $tasks --no-color > >(tee "${outputfile}") 2> >(tee "${outputfile}".stderr >&2)
exitstatus=$?
set -e
fi
Expand Down
76 changes: 22 additions & 54 deletions prepare_npm_stuff/prepare_npm_stuff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,72 +90,40 @@ if [[ -f ${gitdir}/package.json ]]; then

echo "INFO: Installing npm stuff following package/shrinkwrap details"

if ! hash ${npmcmd} 2>/dev/null; then
echo "ERROR: npm not found in the system. Use .nvmrc OR install it in the PATH"
exit 2
fi

# Always run npm install to keep our npm packages correct
${npmcmd} --no-color install

# Verify there is a grunt executable available, installing if missing
gruntcmd="$(${npmcmd} bin)"/grunt
if [[ ! -f ${gruntcmd} ]]; then
echo "WARN: grunt-cli executable not found. Installing everything"
${npmcmd} --no-color --no-save install grunt-cli
fi
else

# Install shifter version if there is not package.json
# (this is required for branches < 29_STABLE)
shifterinstall=""
shiftercmd="$(${npmcmd} bin)"/shifter
if [[ ! -f ${shiftercmd} ]]; then
echo "WARN: shifter executable not found. Installing it"
shifterinstall=1
else
# Have shifter, look its version matches expected one
# Cannot use --version because it's varying (performing calls to verify latest). Use --help instead
shiftercurrent=$(${shiftercmd} --no-color --help | head -1 | cut -d "@" -f2)
if [[ "${shiftercurrent}" != "${shifterversion}" ]]; then
echo "WARN: shifter executable "${shiftercurrent}" found, "${shifterversion}" expected. Installing it"
shifterinstall=1
else
# All right, shifter found and version matches
echo "INFO: shifter executable (${shifterversion}) found"
# Verify that grunt-cli is available (locally), installing if missing
if ! ${npmcmd} list --parseable | grep -q grunt-cli; then
# Last chance, look for the binary itself.
if [[ ! -x node_modules/.bin/grunt ]]; then
echo "WARN: grunt binary not found. Installing it now"
${npmcmd} --no-color --no-save install grunt-cli
fi
fi
if [[ -n ${shifterinstall} ]]; then
${npmcmd} --no-color install shifter@${shifterversion}
echo "INFO: shifter executable (${shifterversion}) installed"
fi

# Install recess version if there is not package.json
# (this is required for branches < 29_STABLE)
recessinstall=""
recesscmd="$(${npmcmd} bin)"/recess
if [[ ! -f ${recesscmd} ]]; then
echo "WARN: recess executable not found. Installing it"
recessinstall=1
else
# Have recess, look its version matches expected one
recesscurrent=$(${recesscmd} --no-color --version)
if [[ "${recesscurrent}" != "${recessversion}" ]]; then
echo "WARN: recess executable "${recesscurrent}" found, "${recessversion}" expected. Installing it"
recessinstall=1
else
# All right, recess found and version matches
echo "INFO: recess executable (${recessversion}) found"
fi
fi
if [[ -n ${recessinstall} ]]; then
${npmcmd} --no-color install recess@${recessversion}
echo "INFO: recess executable (${recessversion}) installed"
# Verify that stylelint-checkstyle-formatter is available (locally), installing if missing
if ! ${npmcmd} list --parseable | grep -q stylelint-checkstyle-formatter; then
echo "WARN: stylelint-checkstyle-formatter package not found. Installing it now"
${npmcmd} --no-color --no-save install stylelint-checkstyle-formatter
fi
else
echo "ERROR: Something is wrong. Missing package.json"
fi

# Move back to base directory.
cd ${gitdir}

# Output information about installed binaries.
echo "INFO: Installation ended"
echo "INFO: Available binaries @ ${gitdir}"
echo "INFO: (Contents of $(${npmcmd} bin))"
for binary in $(ls $(${npmcmd} bin)); do
echo "INFO: - Installed ${binary}"
echo "INFO: Installed packages @ $(npm root)"
echo "INFO: (Contents of ${npmcmd} list --depth=1)"
for package in $(${npmcmd} list --depth=1 --parseable); do
echo "INFO: - Installed $(basename ${package})"
done
echo "============== END OF LIST =============="
47 changes: 23 additions & 24 deletions remote_branch_checker/remote_branch_checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@ cat "${WORKSPACE}/work/mustachelint.txt" | ${phpcmd} ${mydir}/checkstyle_convert

if [ -f $WORKSPACE/.gherkin-lintrc ]; then
echo "Info: Running gherkin-lint..."
gherkinlintcmd="$(${npmcmd} bin)"/gherkin-lint
if [ -x $gherkinlintcmd ]; then
$gherkinlintcmd --format=json '**/tests/behat/*.feature' 2> "${WORKSPACE}/work/gherkin-lint.txt"
cat "${WORKSPACE}/work/gherkin-lint.txt" | ${phpcmd} ${mydir}/checkstyle_converter.php --format=gherkinlint > "${WORKSPACE}/work/gherkin-lint.xml"
else
echo "Error: .gherkin-lintrc file found, but /gherkin-lint executable not found" | tee -a ${errorfile}
if ! ${npmcmd} list --depth=1 --parseable | grep -q gherkin-lint; then
echo "Error: .gherkin-lintrc file found, but gherkin-lint package not found" | tee -a ${errorfile}
exit 1
fi

# Run gherkin-lint
npx gherkin-lint --format=json '**/tests/behat/*.feature' 2> "${WORKSPACE}/work/gherkin-lint.txt"
cat "${WORKSPACE}/work/gherkin-lint.txt" | ${phpcmd} ${mydir}/checkstyle_converter.php --format=gherkinlint > "${WORKSPACE}/work/gherkin-lint.xml"
fi

# Run the grunt checker if Gruntfile exists. node stuff has been already installed.
Expand Down Expand Up @@ -425,28 +425,27 @@ set +e

if [ -f $WORKSPACE/.eslintrc ]; then
echo "Info: Running eslint..."
eslintcmd="$(${npmcmd} bin)"/eslint
if [ -x $eslintcmd ]; then
# TODO: Remove this once everybody is using nodejs 14 or up.
# We need to invoke eslint differently depending of the installed version.
# (new versions v6.8 and up have this option to avoid exiting with error if there aren't JS files)
eslintarg="--no-error-on-unmatched-pattern"
# Old versions don't have this option, they exit without error if there aren't JS files, so don't use it.
if ! $eslintcmd --help | grep -q -- $eslintarg; then
eslintarg=""
fi
$eslintcmd -f checkstyle $eslintarg $WORKSPACE > "${WORKSPACE}/work/eslint.xml"
else
echo "Error: .eslintrc file found, but eslint executable not found" | tee -a ${errorfile}
if ! ${npmcmd} list --depth=1 --parseable | grep -q eslint; then
echo "Error: .eslintrc file found, but eslint package not found" | tee -a ${errorfile}
exit 1
fi

# Run eslint
# TODO: Remove this once everybody is using nodejs 14 or up.
# We need to invoke eslint differently depending of the installed version.
# (new versions v6.8 and up have this option to avoid exiting with error if there aren't JS files)
eslintarg="--no-error-on-unmatched-pattern"
# Old versions don't have this option, they exit without error if there aren't JS files, so don't use it.
if ! npx eslint --help | grep -q -- $eslintarg; then
eslintarg=""
fi
npx eslint -f checkstyle $eslintarg $WORKSPACE > "${WORKSPACE}/work/eslint.xml"
fi

if [ -f $WORKSPACE/.stylelintrc ]; then
echo "Info: Running stylelint..."
stylelintcmd="$(${npmcmd} bin)"/stylelint
if [ ! -x $stylelintcmd ]; then
echo "Error: .stylelintrc file found, but stylelint executable not found" | tee -a ${errorfile}
if ! ${npmcmd} list --depth=1 --parseable | grep -q stylelint; then
echo "Error: .stylelintrc file found, but stylelint package not found" | tee -a ${errorfile}
exit 1
fi

Expand All @@ -456,10 +455,10 @@ if [ -f $WORKSPACE/.stylelintrc ]; then
# (new versions 7.7.0 and up have this option to avoid exiting with error if there aren't CSS files)
stylelintarg="--allow-empty-input"
# Old versions don't have this option, they exit without error if there aren't CSS files, so don't use it.
if ! $stylelintcmd --help | grep -q -- $stylelintarg; then
if ! npx stylelint --help | grep -q -- $stylelintarg; then
eslintarg=""
fi
if $stylelintcmd $stylelintarg --customFormatter 'node_modules/stylelint-checkstyle-formatter' "*/**/*.{css,less,scss}" > "${WORKSPACE}/work/stylelint.xml"
if npx stylelint $stylelintarg --customFormatter 'node_modules/stylelint-checkstyle-formatter' "*/**/*.{css,less,scss}" > "${WORKSPACE}/work/stylelint.xml"
then
echo "Info: stylelint completed without errors."
else
Expand Down
12 changes: 6 additions & 6 deletions tests/1-grunt_process.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ setup () {
# When a third party library is added, developers need to commit
# ignorefiles change since 3.2.

# Testing on in-dev 3.2dev
create_git_branch 32-dev 5a1728df39116fc701cc907e85a638aa7674f416
git_apply_fixture 32-thirdparty-lib-added.patch
# Testing on v3.5.9
create_git_branch 35-stable v3.5.9
git_apply_fixture 35-thirdparty-lib-added.patch

# Run test
ci_run grunt_process/grunt_process.sh
Expand All @@ -64,9 +64,9 @@ setup () {
# When a 3rd party library is added, but we are checking a 3rd part plugin
# we ignore any change in ignorefiles.

# Testing on in-dev 3.2dev
create_git_branch 32-dev 5a1728df39116fc701cc907e85a638aa7674f416
git_apply_fixture 32-thirdparty-lib-added.patch
# Testing on v3.5.9
create_git_branch 35-stable v3.5.9
git_apply_fixture 35-thirdparty-lib-added.patch

# Run test
export isplugin=1
Expand Down
8 changes: 5 additions & 3 deletions tests/2-remote_branch_checker.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ assert_prechecker () {
assert_files_same $smurfxmlfixture $WORKSPACE/work/smurf.xml
}

@test "remote_branch_checker/remote_branch_checker.sh: old branch failing" {
# An extremely old branch running jshint..
assert_prechecker local_ci_fixture_oldbranch MDLSITE-3899 v2.9.0-rc1
@test "remote_branch_checker/remote_branch_checker.sh: old branch (38_STABLE) failing" {
# An extremely old branch. MOODLE_38_STABLE (with node v14) is the oldest we support.
# (note MOODLE_35_STABLE and up also is supported but not v3.5.0, v3.6.0... support came later and
# we need to use always .0 versions in the tests as base, so 3.8.0 is the very first .0).
assert_prechecker local_ci_fixture_oldbranch_38 MDLSITE-3899 v3.8.0
}

@test "remote_branch_checker/remote_branch_checker.sh: all possible checks failing" {
Expand Down
4 changes: 4 additions & 0 deletions tests/3-prepare_npm_stuff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ setup () {
# Assert result.
# Cannot know if install will success or no (depends if npm/node binaries are elsewhere)
# (hence, we are not asserting the result, just that the case is handled)

# Note this can end with some warnings if npm/node is not installed elsewhere and with
# exit status = 2, but, as commented above, we are not asserting that here (success / failure...)
# so that's ok.
assert_output --partial "INFO: nvm not found, installing via git"
assert_output --partial "INFO: nvm git installation found, updating to latest release"
assert_output --partial "INFO: using nvm version:"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
From 4600d7d6fd5d5bd4f5bae80c3e89b838d95f2b1d Mon Sep 17 00:00:00 2001
From 96ec9462a7d7a05f39af044020b63e371831ab05 Mon Sep 17 00:00:00 2001
From: Dan Poltawski <dan@moodle.com>
Date: Tue, 12 Jul 2016 11:23:56 +0100
Subject: [PATCH 1/1] MDLSITE-4678 fixture: adding third party lib
Subject: [PATCH] MDLSITE-4678 fixture: adding third party lib

---
lib/thirdpartylibs.xml | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml
index 6440a73..3385d2f 100644
index c14a3e01d4..ba719b5f84 100644
--- a/lib/thirdpartylibs.xml
+++ b/lib/thirdpartylibs.xml
@@ -275,4 +275,10 @@
<license>GPL</license>
<version>2.3.0</version>
@@ -323,4 +323,10 @@
<license>MIT</license>
<version>1.1.1</version>
</library>
+ <library>
+ <location>integrationtest</location>
Expand All @@ -23,5 +23,5 @@ index 6440a73..3385d2f 100644
+ </library>
</libraries>
--
2.9.0
2.39.1

Loading