cordova icon indicating copy to clipboard operation
cordova copied to clipboard

[Plugins] Improve plugin tests

Open janpio opened this issue 7 years ago • 12 comments

Change plugin tests to:

  • [ ] test all relevant platforms
  • [ ] test all relevant platform versions: https://github.com/apache/cordova/issues/38
  • [ ] are structured and built in a similar way
    • [ ] same libraries and versions
    • [ ] package.json npm scripts
    • [ ] CI setup and configuration
  • [ ] are faster (= take minimal possible time to run)
  • [ ] are more consistent (= not flaky or brittle)
  • [ ] are simpler to understand
    • [ ] what runs in Travis, what in Saucelabs?
  • [ ] are properly documented

Currently blocked by https://github.com/apache/cordova/issues/28

janpio avatar Oct 01 '18 09:10 janpio

.travis.yml has this bit:

before_install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- node --version
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26,android-27;
  fi
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd
  /tmp/paramedic && npm install && popd
- npm install -g cordova

(or similar, as configs can be different)

This should:

  1. not have those confusing line breaks
  2. get the android-22,android-23,android-24,android-25,android-26,android-27 string from a variable so that it is not that easy to overlook
  3. probably something like nvm is available on travis by default?
  4. not switch from android, then to ios, then again android

janpio avatar Oct 01 '18 10:10 janpio

Maybe all this repeating stuff should not be handled in the plugin itself?

janpio avatar Oct 01 '18 10:10 janpio

Travis CI itself uses nvm to manage different Node.js versions: https://travis-ci.org/raphinesse/cordova-lib/jobs/435129609#L423

raphinesse avatar Oct 01 '18 10:10 raphinesse

Probably historical reasons plugins are still doing it this way, but can definitely be changed then.

janpio avatar Oct 01 '18 10:10 janpio

  • Chrome is missing for cordova-plugin-file
  • Idea: Plugins just define the supported platforms, rest is done by some other package that has all the saucelabs configuration etc
  • iOS/Obj-C testing is only present in some repos:
  - env: TEST_DIR=.
    language: objective-c
    osx_image: xcode7
  - env: TEST_DIR=./tests/ios
    language: objective-c
    osx_image: xcode7
  • Xcode versions used across tests are pretty random (and old!)
  • Node versions used across tests are also not identical ( most use 4.2, some use others)

janpio avatar Oct 01 '18 11:10 janpio

There actually are docs: https://github.com/apache/cordova-plugin-inappbrowser/blob/master/CONTRIBUTING.md#running-plugin-tests

janpio avatar Oct 03 '18 15:10 janpio

https://www.browserstack.com/ maybe?

janpio avatar Oct 03 '18 17:10 janpio

I'd like to vote to include a npm audit for the plugin tests 👍
Maybe GitHub Actions could be used for this task, too.

timbru31 avatar Jan 30 '19 19:01 timbru31

https://medium.com/@distillerytech/painless-travis-ci-cd-for-android-project-8c5bce253c4b shows a better way to accept the licences and move the Android API and build tools version to an env var. More lines of boilerplate, but those stay unchanged on version updates - so I would count that as a win on our side.

janpio avatar Mar 27 '19 14:03 janpio

@janpio Maybe also take a look at what I did for the CI tests of cordova-android. I think I simplified the whole Android SDK setup there too.

raphinesse avatar Mar 27 '19 15:03 raphinesse

Thanks for the pointer, will take a look at the changes done to https://github.com/apache/cordova-android/blob/master/.travis.yml as well.

janpio avatar Mar 27 '19 16:03 janpio

Work in progress via rollout of https://github.com/apache/cordova-paramedic/blob/master/.travis.yml to plugin repos.

janpio avatar May 10 '19 22:05 janpio