checkPlugins: remove lib/travis.yml and add github badges if they aren't present (#4731)

A future PR should remove all Travis badges and CI jobs.
pull/4740/head
John McLear 2021-02-09 09:41:41 +00:00 committed by GitHub
parent ebdb2798ff
commit 94a65062c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 109 deletions

View File

@ -277,7 +277,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
console.warn('Run npm install in the plugin folder and commit the package-lock.json file.'); console.warn('Run npm install in the plugin folder and commit the package-lock.json file.');
} }
} }
if (files.indexOf('readme') === -1 && files.indexOf('readme.md') === -1) { if (files.indexOf('readme') === -1 && files.indexOf('readme.md') === -1) {
console.warn('README.md file not found, please create'); console.warn('README.md file not found, please create');
if (autoFix) { if (autoFix) {
@ -310,8 +309,8 @@ fs.readdir(pluginPath, (err, rootFiles) => {
} }
if (files.indexOf('readme') !== -1 && files.indexOf('readme.md') !== -1) { if (readMeFileName) {
const readme = let readme =
fs.readFileSync(`${pluginPath}/${readMeFileName}`, {encoding: 'utf8', flag: 'r'}); fs.readFileSync(`${pluginPath}/${readMeFileName}`, {encoding: 'utf8', flag: 'r'});
if (readme.toLowerCase().indexOf('license') === -1) { if (readme.toLowerCase().indexOf('license') === -1) {
console.warn('No license section in README'); console.warn('No license section in README');
@ -319,6 +318,22 @@ fs.readdir(pluginPath, (err, rootFiles) => {
console.warn('Please add License section to README manually.'); console.warn('Please add License section to README manually.');
} }
} }
// eslint-disable-next-line max-len
const publishBadge = `![Publish Status](https://github.com/ether/${pluginName}/workflows/Node.js%20Package/badge.svg)`;
// eslint-disable-next-line max-len
const testBadge = `![Backend Tests Status](https://github.com/ether/${pluginName}/workflows/Backend%20tests/badge.svg)`;
if (readme.toLowerCase().indexOf('travis') !== -1) {
console.warn('Remove Travis badges');
}
if (readme.indexOf('workflows/Node.js%20Package/badge.svg') === -1) {
console.warn('No Github workflow badge detected');
if (autoFix) {
readme = `${publishBadge} ${testBadge}\n\n${readme}`;
// write readme to file system
fs.writeFileSync(`${pluginPath}/${readMeFileName}`, readme);
console.log('Wrote Github workflow badges to README');
}
}
} }
if (files.indexOf('license') === -1 && files.indexOf('license.md') === -1) { if (files.indexOf('license') === -1 && files.indexOf('license.md') === -1) {
@ -333,41 +348,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
} }
} }
let travisConfig =
fs.readFileSync('src/bin/plugins/lib/travis.yml', {encoding: 'utf8', flag: 'r'});
travisConfig = travisConfig.replace(/\[plugin_name\]/g, pluginName);
if (files.indexOf('.travis.yml') === -1) {
console.warn('.travis.yml file not found, please create. ' +
'.travis.yml is used for automatically CI testing Etherpad. ' +
'It is useful to know if your plugin breaks another feature for example.');
// TODO: Make it check version of the .travis file to see if it needs an update.
if (autoFix) {
console.log('Autofixing missing .travis.yml file');
fs.writeFileSync(`${pluginPath}/.travis.yml`, travisConfig);
console.log('Travis file created, please sign into travis and enable this repository');
}
}
if (autoFix) {
// checks the file versioning of .travis and updates it to the latest.
const existingConfig =
fs.readFileSync(`${pluginPath}/.travis.yml`, {encoding: 'utf8', flag: 'r'});
const existingConfigLocation = existingConfig.indexOf('##ETHERPAD_TRAVIS_V=');
const existingValue =
parseInt(existingConfig.substr(existingConfigLocation + 20, existingConfig.length));
const newConfigLocation = travisConfig.indexOf('##ETHERPAD_TRAVIS_V=');
const newValue = parseInt(travisConfig.substr(newConfigLocation + 20, travisConfig.length));
if (existingConfigLocation === -1) {
console.warn('no previous .travis.yml version found so writing new.');
// we will write the newTravisConfig to the location.
fs.writeFileSync(`${pluginPath}/.travis.yml`, travisConfig);
} else if (newValue > existingValue) {
console.log('updating .travis.yml');
fs.writeFileSync(`${pluginPath}/.travis.yml`, travisConfig);
}//
}
if (files.indexOf('.gitignore') === -1) { if (files.indexOf('.gitignore') === -1) {
console.warn('.gitignore file not found, please create. .gitignore files are useful to ' + console.warn('.gitignore file not found, please create. .gitignore files are useful to ' +
"ensure files aren't incorrectly commited to a repository."); "ensure files aren't incorrectly commited to a repository.");
@ -433,7 +413,6 @@ fs.readdir(pluginPath, (err, rootFiles) => {
// absolute path to etherpad-lite/src is used here so that pluginPath can be a symlink. // absolute path to etherpad-lite/src is used here so that pluginPath can be a symlink.
execSync( execSync(
`${npmInstall} --no-save ep_etherpad-lite@file:${__dirname}/../../`, {stdio: 'inherit'}); `${npmInstall} --no-save ep_etherpad-lite@file:${__dirname}/../../`, {stdio: 'inherit'});
// linting begins // linting begins
try { try {
console.log('Linting...'); console.log('Linting...');

View File

@ -1,70 +0,0 @@
language: node_js
node_js:
- "lts/*"
cache: false
services:
- docker
install:
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
#script:
# - "src/tests/frontend/travis/runner.sh"
env:
global:
- secure: "WMGxFkOeTTlhWB+ChMucRtIqVmMbwzYdNHuHQjKCcj8HBEPdZLfCuK/kf4rG\nVLcLQiIsyllqzNhBGVHG1nyqWr0/LTm8JRqSCDDVIhpyzp9KpCJQQJG2Uwjk\n6/HIJJh/wbxsEdLNV2crYU/EiVO3A4Bq0YTHUlbhUqG3mSCr5Ec="
- secure: "gejXUAHYscbR6Bodw35XexpToqWkv2ifeECsbeEmjaLkYzXmUUNWJGknKSu7\nEUsSfQV8w+hxApr1Z+jNqk9aX3K1I4btL3cwk2trnNI8XRAvu1c1Iv60eerI\nkE82Rsd5lwUaMEh+/HoL8ztFCZamVndoNgX7HWp5J/NRZZMmh4g="
jobs:
include:
- name: "Lint test package-lock"
install:
- "npm install lockfile-lint"
script:
- npx lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm
- name: "Run the Backend tests"
before_install:
- sudo add-apt-repository -y ppa:libreoffice/ppa
- sudo apt-get update
- sudo apt-get -y install libreoffice
- sudo apt-get -y install libreoffice-pdfimport
install:
- "npm install"
- "mkdir [plugin_name]"
- "mv !([plugin_name]) [plugin_name]"
- "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "cd etherpad"
- "mkdir -p node_modules"
- "mv ../[plugin_name] node_modules"
- "src/bin/installDeps.sh"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
- "cd src && npm install && cd -"
script:
- "src/tests/frontend/travis/runnerBackend.sh"
- name: "Test the Frontend"
before_script:
- "src/tests/frontend/travis/sauce_tunnel.sh"
install:
- "npm install"
- "mkdir [plugin_name]"
- "mv !([plugin_name]) [plugin_name]"
- "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "cd etherpad"
- "mkdir -p node_modules"
- "mv ../[plugin_name] node_modules"
- "src/bin/installDeps.sh"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
script:
- "src/tests/frontend/travis/runner.sh"
notifications:
irc:
channels:
- "irc.freenode.org#etherpad-lite-dev"
##ETHERPAD_TRAVIS_V=9
## Travis configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh