diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..e4cf7abe --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,165 @@ +# Run tests against supported Node versions, and (except for pull requests) +# against supported browsers. + +version: 2.1 + +orbs: + node: circleci/node@3.0.0 + +executors: + node14: + docker: + - image: circleci/node:14 + working_directory: ~/workspace + node12: + docker: + - image: circleci/node:12 + working_directory: ~/workspace + node10: + docker: + - image: circleci/node:10 + working_directory: ~/workspace + +jobs: + build: + parameters: + executor: + type: executor + executor: << parameters.executor >> + steps: + - checkout + - run: + name: Report Node and NPM versions + command: echo "Using Node $(node --version) and NPM $(npm --version)" + - run: + name: Install dependencies + command: npm install + - run: + name: Build + command: npm run build + - persist_to_workspace: + root: . + paths: + - . + + test_node: &test_node + parameters: + executor: + type: executor + executor: << parameters.executor >> + steps: + - attach_workspace: + at: . + - run: + name: Run tests + command: npm test + + # Warning: Sometimes takes a very long time (>25 minutes) on Circle. + # Probably not a good idea to run it from anything but a nightly. + test_node_with_long_property_tests: + <<: *test_node + environment: + JASMINE_LONG_PROPERTY_TESTS: y + + # Warning: Currently this is very flaky if anything else is using Sauce + # at the same time, possibly because we're not specifying the tunnel ID + # correctly. Probably not a good idea to run it from anything but a nightly. + test_browsers: + executor: node14 + steps: + - attach_workspace: + at: . + - run: + name: Install Sauce Connect + command: | + cd /tmp + curl https://saucelabs.com/downloads/sc-4.6.4-linux.tar.gz | tar zxf - + chmod +x sc-4.6.4-linux/bin/sc + mkdir ~/workspace/bin + cp sc-4.6.4-linux/bin/sc ~/workspace/bin + ~/workspace/bin/sc --version + - run: + name: Run tests + command: | + # Do everything in one step because Sauce Connect won't exit + # cleanly if we kill it from a different step than it started in. + + export PATH=$PATH:$HOME/workspace/bin + scripts/start-sauce-connect sauce-pidfile + set +o errexit + scripts/run-all-browsers + exitcode=$? + set -o errexit + scripts/stop-sauce-connect $(cat sauce-pidfile) + exit $exitcode + +workflows: + version: 2 + cron: + triggers: + - schedule: + # The choice of hour is somewhat load-bearing. test_browser currently + # tends to fail if there are other Sauce tunnels open. So we only + # run it at a time when that's unlikely. + # Times are UTC. + cron: "0 10 * * *" + filters: + branches: + only: + - main + jobs: + - build: + executor: node14 + name: build_node_14 + - build: + executor: node12 + name: build_node_12 + - build: + executor: node10 + name: build_node_10 + - test_node_with_long_property_tests: + executor: node14 + requires: + - build_node_14 + - test_node: + executor: node12 + name: test_node_12 + requires: + - build_node_12 + - test_node: + executor: node10 + name: test_node_10 + requires: + - build_node_10 + - test_browsers: + requires: + - build_node_14 + filters: + branches: + only: main + push: + jobs: + - build: + executor: node14 + name: build_node_14 + - build: + executor: node12 + name: build_node_12 + - build: + executor: node10 + name: build_node_10 + - test_node: + executor: node14 + name: test_node_14 + requires: + - build_node_14 + - test_node: + executor: node12 + name: test_node_12 + requires: + - build_node_12 + - test_node: + executor: node10 + name: test_node_10 + requires: + - build_node_10 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8f592ea0..a2bc33eb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -99,7 +99,7 @@ Follow these tips and your pull request, patch, or suggestion is much more likel ### Running Specs -Jasmine uses some internal tooling to test itself in browser on Travis. This tooling _should_ work locally as well. +Jasmine uses some internal tooling to test itself in browser on Circle CI. This tooling _should_ work locally as well. $ node spec/support/ci.js @@ -123,5 +123,5 @@ The easiest way to run the tests in **Internet Explorer** is to run a VM that ha * We do this because `jasmine.js` and `jasmine-html.js` are auto-generated (as you've seen in the previous steps) and accepting multiple pull requests when this auto-generated file changes causes lots of headaches * When we accept your pull request, we will generate these files as a separate commit and merge the entire branch into main -Note that we use Travis for Continuous Integration. We only accept green pull requests. +Note that we use Circle CI for Continuous Integration. We only accept green pull requests. diff --git a/.npmignore b/.npmignore index 16e59f5c..2f53304a 100644 --- a/.npmignore +++ b/.npmignore @@ -16,7 +16,8 @@ jasmine-core.gemspec .jshintrc .rspec .sass-cache/ -.travis.yml +.circleci +scripts/ *.sh *.py Gruntfile.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4015d631..00000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: node_js -node_js: 14 - -script: $TEST_COMMAND - -env: - global: - - USE_SAUCE=true - - TEST_COMMAND="bash travis-core-script.sh" - - secure: WSPWhlnC4mWSnSPquX+m1/BCu5ch5NygkaHuM2Nea7lD8oS3XLX8QncZZAsQ4lnNfqoDDuBOizG0AESiqNvE4y6x5qvLLTS6q+ce255ZEMZ71TBdZgDEEvGMEjOPPsVXiXyTQOP1lwOPlrbZvaPgWV7e11KIBab6DfFcQpnvDgo= - - secure: SW7CJhZnwaNT749Gdnhvqb5rbXlAOsygUAzh9qhtyvbqXKkmJdBIEsO01YF6pbju1X2twE9JvWCOxeZju43NgQChJlPsGbjY2j3k/TdQeTAJesQe2K7ytwghunI30gjEovtRH0T3w1EmcKPH8yj5eBIcB2OYoJHx8KEC7e68q1g= - -matrix: - include: - - node_js: "14" - env: JASMINE_LONG_PROPERTY_TESTS="y" TEST_COMMAND="npm test" - - node_js: "12" - env: TEST_COMMAND="npm test" - - node_js: "10" - env: TEST_COMMAND="npm test" - - env: JASMINE_BROWSER="internet explorer" SAUCE_BROWSER_VERSION=11 SAUCE_OS="Windows 8.1" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="internet explorer" SAUCE_BROWSER_VERSION=10 SAUCE_OS="Windows 8" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="firefox" SAUCE_BROWSER_VERSION='' SAUCE_OS="Windows 10" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="firefox" SAUCE_BROWSER_VERSION='78' SAUCE_OS="Windows 10" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="firefox" SAUCE_BROWSER_VERSION='68' SAUCE_OS="Windows 10" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="chrome" SAUCE_BROWSER_VERSION='' SAUCE_OS="Windows 10" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="safari" SAUCE_BROWSER_VERSION="14" SAUCE_OS="OS X 11.0" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="safari" SAUCE_BROWSER_VERSION="13" SAUCE_OS="OS X 10.13" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="safari" SAUCE_BROWSER_VERSION="8" SAUCE_OS="OS X 10.10" - if: type != pull_request - addons: - sauce_connect: true - - env: JASMINE_BROWSER="MicrosoftEdge" SAUCE_BROWSER_VERSION="" SAUCE_OS="Windows 10" - if: type != pull_request - addons: - sauce_connect: true diff --git a/README.md b/README.md index d10056ca..016b4fd9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [](http://jasmine.github.io) -[![Build Status](https://travis-ci.com/jasmine/jasmine.svg?branch=main)](https://travis-ci.com/jasmine/jasmine) +[![Build Status](https://circleci.com/gh/jasmine/jasmine.svg?style=shield)](https://circleci.com/gh/jasmine/jasmine) [![Open Source Helpers](https://www.codetriage.com/jasmine/jasmine/badges/users.svg)](https://www.codetriage.com/jasmine/jasmine) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjasmine%2Fjasmine?ref=badge_shield) diff --git a/RELEASE.md b/RELEASE.md index 8d0689b1..5b277c71 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -37,7 +37,7 @@ When ready to release - specs are all green and the stories are done: 1. Commit release notes and version changes (jasmine.js, version.rb, package.json) 1. Push -1. Wait for Travis to go green +1. Wait for Circle CI to go green ### Build standalone distribution @@ -77,7 +77,7 @@ Probably only need to do this when releasing a minor version, and not a patch ve 1. Create release notes using Anchorman as above 1. In `package.json`, update both the package version and the jasmine-core dependency version 1. Commit and push. -1. Wait for Travis to go green again. +1. Wait for Circle CI to go green again. 1. `grunt release `. (Note: This will publish the package by running `npm publish`.) #### Gem @@ -86,7 +86,7 @@ Probably only need to do this when releasing a minor version, and not a patch ve 1. Update the version number in `lib/jasmine/version.rb`. 1. Update the jasmine-core dependency version in `jasmine.gemspec`. 1. Commit and push. -1. Wait for Travis to go green again. +1. Wait for Circle CI to go green again. 1. `rake release` ### Finally diff --git a/package.json b/package.json index e65e990f..b90ced73 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "grunt-css-url-embed": "^1.11.1", "grunt-sass": "^3.0.2", "jasmine": "^3.4.0", - "jasmine-browser-runner": "^0.4.0", + "jasmine-browser-runner": "github:jasmine/jasmine-browser#main", "jsdom": "^15.0.0", "load-grunt-tasks": "^4.0.0", "node-sass": "^4.11.0", diff --git a/scripts/run-all-browsers b/scripts/run-all-browsers new file mode 100755 index 00000000..331109cc --- /dev/null +++ b/scripts/run-all-browsers @@ -0,0 +1,45 @@ +#!/bin/sh + +run_browser() { + browser=$1 + version=$2 + description="$browser $version" + if [ $version = "latest" ]; then + version="" + fi + + echo + echo + echo "Running $description" + echo + USE_SAUCE=true JASMINE_BROWSER=$browser SAUCE_BROWSER_VERSION=$version npm run ci + + if [ $? -eq 0 ]; then + echo "PASS: $description" >> "$passfile" + else + echo "FAIL: $description" >> "$failfile" + fi +} + +passfile=`mktemp -t jasmine-results.XXXXXX` || exit 1 +failfile=`mktemp -t jasmine-results.XXXXXX` || exit 1 +run_browser "internet explorer" 11 +run_browser "internet explorer" 10 +run_browser firefox latest +run_browser firefox 78 +run_browser firefox 68 +run_browser safari 14 +run_browser safari 13 +run_browser safari 12 +run_browser safari 11 +run_browser safari 10 +run_browser safari 9 +run_browser safari 8 +run_browser MicrosoftEdge latest + +echo +cat "$passfile" "$failfile" + +if [ -s "$failfile" ]; then + exit 1 +fi diff --git a/scripts/start-sauce-connect b/scripts/start-sauce-connect new file mode 100755 index 00000000..b2679c9a --- /dev/null +++ b/scripts/start-sauce-connect @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -o errexit +set -o pipefail + +if [ $# -gt 1 -o "$1" = "--help" ]; then + echo "Usage: $0 [pidfile]" 1>&2 + exit +fi + +if [ -z "$1" ]; then + pidfile=`mktemp` +else + pidfile="$1" +fi + +outfile=`mktemp` +echo "Starting Sauce Connect" +sc -u "$SAUCE_USERNAME" -k "$SAUCE_ACCESS_KEY" -X 4445 --pidfile "$pidfile" 2>&1 | tee "$outfile" & + +while ! fgrep "Sauce Connect is up, you may start your tests." "$outfile" > /dev/null; do + sleep 1 + + if ! ps -p $(cat "$pidfile") > /dev/null; then + echo "Sauce Connect exited" + exit 1 + fi +done + +if ! nc -z localhost 4445; then + echo "Can't connect to Sauce tunnel" + killall sc + exit 1 +fi diff --git a/scripts/stop-sauce-connect b/scripts/stop-sauce-connect new file mode 100755 index 00000000..1b82081a --- /dev/null +++ b/scripts/stop-sauce-connect @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -o errexit +set -o pipefail + +if [ -z "$1" ]; then + echo "Usage: $0 sauce-connect-pid" 1>&2 + exit +fi + +pid="$1" +echo "PID: $pid" + +echo "Stopping Sauce Connect" +# Sauce Connect docs say that we can just kill -9 it if we don't care about +# failing any ongoing sessions. In practice, that sometimes works but usually +# leaks a tunnel so badly that you can't even stop it from the web UI. +# Instead of doing that, we give Sauce Connect some time to shut down +# gracefully and then give up. +kill -INT $pid + +# Wait up to 2 minutes, then give up if it's still running +n=0 +while [ $n -lt 120 ] && ps -p $pid > /dev/null; do + sleep 1 + kill -INT $pid 2> /dev/null || true + n=$(($n + 1)) +done + +if ps -p $pid > /dev/null; then + echo "Could not shut down Sauce Connect" +fi + +exit $exitcode diff --git a/spec/npmPackage/npmPackageSpec.js b/spec/npmPackage/npmPackageSpec.js index ea292bc2..70af391b 100644 --- a/spec/npmPackage/npmPackageSpec.js +++ b/spec/npmPackage/npmPackageSpec.js @@ -99,4 +99,13 @@ describe('npm package', function() { expect(images).toContain('jasmine-horizontal.svg'); expect(images).toContain('jasmine_favicon.png'); }); + + it('does not have CI config files and scripts', function() { + expect(fs.existsSync(path.resolve(this.tmpDir, 'package/.circleci'))).toBe( + false + ); + expect(fs.existsSync(path.resolve(this.tmpDir, 'package/scripts'))).toBe( + false + ); + }); }); diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json index c9ffa120..b9985275 100644 --- a/spec/support/jasmine.json +++ b/spec/support/jasmine.json @@ -17,6 +17,7 @@ "helpers/integrationMatchers.js", "helpers/promises.js", "helpers/requireFastCheck.js", + "helpers/overrideConsoleLogForCircleCi.js", "helpers/nodeDefineJasmineUnderTest.js" ], "random": true diff --git a/travis-core-script.sh b/travis-core-script.sh deleted file mode 100644 index 1e5733b1..00000000 --- a/travis-core-script.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -if [ $USE_SAUCE == true ] -then - if [ $TRAVIS_SECURE_ENV_VARS != true ] - then - echo "skipping tests since we can't use sauce" - exit 0 - fi -fi - -npm run ci