Merge pull request #653 from sass/multi-os

Test Windows and OS X on Travis
This commit is contained in:
Natalie Weizenbaum 2019-04-29 16:42:23 -07:00 committed by GitHub
commit 797d18f27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 149 additions and 120 deletions

View File

@ -1,35 +1,12 @@
## Testing
# Set the language to Ruby so that we can run sass-spec tests.
language: ruby
language: shell
env:
global:
- DART_CHANNEL=stable
- DART_VERSION=latest
matrix:
# Language specs, defined in sass/sass-spec
- TASK=specs
- TASK=specs DART_CHANNEL=dev
- TASK=specs ASYNC=true
# Unit tests, defined in test/.
- TASK=tests
- TASK=tests DART_CHANNEL=dev
# TODO(nweiz): Make this "stable" when laverdet/node-fibers#409 is fixed.
- TASK=tests NODE_VERSION=11
# Keep these up-to-date with the latest LTS Node releases. They next need to
# be rotated December 2019. See https://github.com/nodejs/Release.
- TASK=tests NODE_VERSION=lts/carbon
- TASK=tests NODE_VERSION=lts/dubnium
# Miscellaneous checks.
- TASK=analyze
- TASK=format
rvm:
- 2.3.1
# Only building master means that we don't run two builds for each pull request.
branches:
@ -44,36 +21,82 @@ cache:
directories:
- $HOME/.pub-cache
install:
# Install the Dart SDK.
- curl -o dart.zip "https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/release/$DART_VERSION/sdk/dartsdk-linux-x64-release.zip"
- unzip dart.zip
- export PATH="$PATH:`pwd`/dart-sdk/bin"
- pub get
# Install the Node SDK if we're running Node tests.
- if-node() { if [ ! -z "$NODE_VERSION" ]; then "$@"; fi }
- if-node . "$HOME/.nvm/nvm.sh"
- if-node nvm install "$NODE_VERSION"
- if-node nvm use "$NODE_VERSION"
- if-node pub run grinder before-test
# Download sass-spec and install its dependencies if we're running specs.
- if-specs() { if [ "$TASK" = specs ]; then "$@"; fi }
- if-specs export sass_spec_ref=`tool/travis/sass-spec-ref.sh`
- if-specs git init sass-spec
- if-specs git -C sass-spec fetch git://github.com/sass/sass-spec "$sass_spec_ref" --depth 1
- if-specs git -C sass-spec checkout FETCH_HEAD
- if-specs bundle install --gemfile=sass-spec/Gemfile --jobs=3 --retry=3
- if [ "$TASK" = tests ]; then pub run grinder app-snapshot; fi
script: tool/travis/test.sh
## Deployment
before_install:
- tool/travis/use_dart.sh
- export PATH="$PATH:`pwd`/dart-sdk/bin";
jobs:
include:
## Testing
# Language specs, defined in sass/sass-spec. These need Ruby to run the spec
# runner.
- &specs
name: sass-spec | Dart stable | synchronous
language: ruby
install:
- export sass_spec_ref=`tool/travis/sass-spec-ref.sh`
- git init sass-spec
- git -C sass-spec fetch git://github.com/sass/sass-spec "$sass_spec_ref" --depth 1
- git -C sass-spec checkout FETCH_HEAD
- bundle install --gemfile=sass-spec/Gemfile --jobs=3 --retry=3
script: tool/travis/task/specs.sh
- <<: *specs
name: sass-spec | Dart dev | synchronous
env: DART_CHANNEL=dev
- <<: *specs
name: sass-spec | Dart stable | asynchronous
env: ASYNC=true
# Pure Dart unit tests, defined in test/.
- &dart-tests
name: Dart tests | Dart stable
install: pub run grinder app-snapshot
task: tool/travis/task/dart_tests.sh
- <<: *dart-tests
name: Dart tests | Dart dev
env: DART_CHANNEL=dev
- <<: *dart-tests
os: windows
- <<: *dart-tests
os: osx
# Unit tests that use Node.js, defined in test/.
#
# The versions should be kept up-to-date with the latest LTS Node releases.
# They next need to be rotated December 2019. See
# https://github.com/nodejs/Release.
#
# TODO(nweiz): Run Node tests on Windows when [this issue][] is fixed.
#
# [this issue]: https://travis-ci.community/t/windows-instances-hanging-before-install/250/28.
- &node-tests
name: Node tests | Dart stable | Node 11
language: node_js
# TODO(nweiz): Make this "stable" when laverdet/node-fibers#409 is fixed.
node_js: 11
install: pub run grinder before-test
script: tool/travis/task/node_tests.sh
- <<: *node-tests
name: Node tests | Dart stable | Node Carbon
node_js: lts/carbon
- <<: *node-tests
name: Node tests | Dart stable | Node Dubnium
node_js: lts/dubnium
- <<: *node-tests
os: osx
# Miscellaneous checks.
- name: static analysis
language: dart
dart_task: {dartanalyzer: --fatal-warnings lib tool test}
- name: code formatting
language: dart
dart_task: dartfmt
## Deployment
# Sanity check before releasing anywhere.
- stage: sanity check
if: &deploy-if

View File

@ -8,34 +8,14 @@ branches:
# Semantic version tags and legacy branches of the form "1.2.x".
- "/^\\d+\\.\\d+\\.(\\d+([+-].*)?|x)$/"
# Don't run specs because sass-spec doesn't support Windows. They're also
# supposed to be platform-independent.
environment:
matrix:
- {TASK: tests, NODE: false}
- {TASK: tests, NODE: true}
install:
- choco install dart-sdk
- refreshenv
- pub get
- ps: >-
If ($env:NODE -eq "true") {
Install-Product node ''
pub run grinder npm-package
}
- ps: >-
If ($env:NODE -eq "false") {
pub run grinder app-snapshot
}
- ps: Install-Product node ''
- pub run grinder npm-package
- npm install
# Run this as CMD because npm's stderr will cause PowerShell to think it failed.
- IF "%NODE%"=="true" npm install
test_script:
- ps: >-
If ($env:NODE -eq "true") {
pub run test -t node
} Else {
pub run test -p vm -x node
}
# Only run Node tests on Windows because they won't work on Travis. See
# https://travis-ci.community/t/windows-instances-hanging-before-install/250/28.
test_script: pub run test -t node

View File

@ -2,7 +2,8 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
@TestOn('vm')
// OS X's modification time reporting is flaky, so we skip these tests on it.
@TestOn('vm && !mac-os')
import 'package:test/test.dart';

View File

@ -2,7 +2,8 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
@TestOn('vm')
// OS X's modification time reporting is flaky, so we skip these tests on it.
@TestOn('vm && !mac-os')
import 'package:test/test.dart';

View File

@ -2,7 +2,8 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
@TestOn('vm')
// OS X's modification time reporting is flaky, so we skip these tests on it.
@TestOn('vm && !mac-os')
@Tags(['node'])
import 'package:test/test.dart';

View File

@ -2,7 +2,8 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
@TestOn('vm')
// OS X's modification time reporting is flaky, so we skip these tests on it.
@TestOn('vm && !mac-os')
@Tags(['node'])
import 'package:test/test.dart';

View File

@ -2,7 +2,9 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
@TestOn('vm')
// Windows sees different bytes than other OSes, possibly because of newline
// normalization issues.
@TestOn('vm && !windows')
import 'dart:convert';
import 'dart:io';
@ -12,17 +14,20 @@ import 'package:test/test.dart';
import '../tool/grind/synchronize.dart' as synchronize;
void main() {
test("synchronized files are up-to-date", () {
synchronize.sources.forEach((sourcePath, targetPath) {
var source = File(sourcePath).readAsStringSync();
var target = File(targetPath).readAsStringSync();
/// The pattern of a checksum in a generated file.
final _checksumPattern = RegExp(r"^// Checksum: (.*)$", multiLine: true);
var hash = sha1.convert(utf8.encode(source));
if (!target.contains("Checksum: $hash")) {
fail("$targetPath is out-of-date.\n"
"Run pub run grinder to update it.");
}
void main() {
synchronize.sources.forEach((sourcePath, targetPath) {
test("synchronized file $targetPath is up-to-date", () {
var target = File(targetPath).readAsStringSync();
var actualHash = _checksumPattern.firstMatch(target)[1];
var source = File(sourcePath).readAsBytesSync();
var expectedHash = sha1.convert(source).toString();
expect(actualHash, equals(expectedHash),
reason: "$targetPath is out-of-date.\n"
"Run pub run grinder to update it.");
});
});
}

7
tool/travis/task/dart_tests.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -e
# Copyright 2019 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
echo "$(tput bold)Running Dart tests against Dart $(dart --version &> /dev/stdout).$(tput sgr0)"
pub run test -p vm -x node

7
tool/travis/task/node_tests.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -e
# Copyright 2019 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
echo "$(tput bold)Running Node tests against Node $(node --version).$(tput sgr0)"
pub run test -j 2 -t node

8
tool/travis/task/specs.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash -e
# Copyright 2019 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
echo "$(tput bold)Running sass-spec against $(dart --version &> /dev/stdout).$(tput sgr0)"
if [ "$ASYNC" = true ]; then extra_args="--dart-args --async"; fi
(cd sass-spec; bundle exec sass-spec.rb --dart .. $extra_args)

View File

@ -1,29 +0,0 @@
#!/bin/bash -e
# Copyright 2018 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
bold=$(tput bold)
none=$(tput sgr0)
if [ "$TASK" = analyze ]; then
echo "${bold}Analzing Dart code.$none"
dartanalyzer --fatal-warnings lib/ test/ tool/
elif [ "$TASK" = format ]; then
echo "${bold}Ensuring Dart code is formatted.$none"
./tool/assert-formatted.sh
elif [ "$TASK" = tests ]; then
if [ -z "$NODE_VERSION" ]; then
echo "${bold}Running Dart tests against $(dart --version &> /dev/stdout).$none"
pub run test -p vm -x node
else
echo "${bold}Running Node tests against Node $(node --version).$none"
pub run test -j 2 -t node
fi;
else
echo "${bold}Running sass-spec against $(dart --version &> /dev/stdout).$none"
if [ "$ASYNC" = true ]; then
extra_args="--dart-args --async"
fi;
(cd sass-spec; bundle exec sass-spec.rb --dart .. $extra_args)
fi

24
tool/travis/use_dart.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash -e
# Copyright 2019 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
# A script that installs Dart and runs "pub get" if the current worker isn't
# using Travis's Dart support.
if [ ! -z "$TRAVIS_DART_VERSION" ]; then exit 0; fi
echo "$(tput bold)Installing Dart $DART_CHANNEL/$DART_VERSION.$(tput sgr0)"
source tool/travis/utils.sh
os="$TRAVIS_OS_NAME"
if [ "$os" = osx ]; then os=macos; fi
travis_cmd curl -o dart.zip "https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/release/$DART_VERSION/sdk/dartsdk-$os-x64-release.zip"
travis_cmd unzip dart.zip
export PATH="$PATH:`pwd`/dart-sdk/bin";
if [ "$os" = windows ]; then echo 'pub.bat "$@"' > `pwd`/dart-sdk/bin/pub; fi
if [ "$os" = windows ]; then chmod a+x `pwd`/dart-sdk/bin/pub; fi
travis_cmd `pwd`/dart-sdk/bin/pub get