Move from travis to github actions (#55)

Closes #54

Fix formatting in one file.

Remove test expectations around keep alive periods.
Testing communication through the same connection that
had been closed is sufficient for the intent of the test.
diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml
new file mode 100644
index 0000000..fe6c6c1
--- /dev/null
+++ b/.github/workflows/test-package.yml
@@ -0,0 +1,62 @@
+name: Dart CI
+
+on:
+  # Run on PRs and pushes to the default branch.
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+  schedule:
+    - cron: "0 0 * * 0"
+
+env:
+  PUB_ENVIRONMENT: bot.github
+
+jobs:
+  # Check code formatting and static analysis on a single OS (linux)
+  # against Dart dev.
+  analyze:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        sdk: [dev]
+    steps:
+      - uses: actions/checkout@v2
+      - uses: dart-lang/setup-dart@v1
+        with:
+          sdk: ${{ matrix.sdk }}
+      - id: install
+        name: Install dependencies
+        run: dart pub get
+      - name: Check formatting
+        run: dart format --output=none --set-exit-if-changed .
+        if: always() && steps.install.outcome == 'success'
+      - name: Analyze code
+        run: dart analyze --fatal-infos
+        if: always() && steps.install.outcome == 'success'
+
+  # Run tests on a matrix consisting of two dimensions:
+  # 1. OS: ubuntu-latest, (macos-latest, windows-latest)
+  # 2. release channel: dev
+  test:
+    needs: analyze
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        # Add macos-latest and/or windows-latest if relevant for this package.
+        os: [ubuntu-latest]
+        sdk: [2.12.0, dev]
+    steps:
+      - uses: actions/checkout@v2
+      - uses: dart-lang/setup-dart@v1
+        with:
+          sdk: ${{ matrix.sdk }}
+      - uses: nanasess/setup-chromedriver@3d375deb1534f1c32b9f1a9e463bb6cd30a40593
+      - id: install
+        name: Install dependencies
+        run: dart pub get
+      - name: Run VM tests
+        run: dart test --platform vm --test-randomize-ordering-seed=random -j 1
+        if: always() && steps.install.outcome == 'success'
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 8a05915..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-language: dart
-sudo: required
-addons:
-  chrome: stable
-
-dart:
-  - dev
-
-with_content_shell: false
-
-before_install:
-  - "export CHROMEDRIVER_BINARY=/usr/bin/google-chrome"
-  - "export CHROMEDRIVER_ARGS=--no-sandbox"
-  - "/usr/bin/google-chrome --version"
-  - "export CHROME_LATEST_VERSION=$(/usr/bin/google-chrome --version | cut -d' ' -f3 | cut -d'.' -f1)"
-  - "export CHROME_DRIVER_VERSION=$(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_LATEST_VERSION)"
-  - "wget https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip"
-  - unzip chromedriver_linux64.zip
-  - "export PATH=$PATH:$PWD"
-  - ./tool/travis-setup.sh
-
-script:
-  - ./tool/travis.sh
-
-cache:
- directories:
-   - $HOME/.pub-cache
-
-# Only building master means that we don't run two builds for each pull request.
-branches:
-  only:
-    - master
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd0dd52..56bae68 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,5 @@
+## 4.1.1-dev
+
 ## 4.1.0
 
 - Limit the number of concurrent requests to prevent Chrome from automatically
diff --git a/lib/src/server/sse_handler.dart b/lib/src/server/sse_handler.dart
index d8a867e..8a5db5c 100644
--- a/lib/src/server/sse_handler.dart
+++ b/lib/src/server/sse_handler.dart
@@ -17,8 +17,8 @@
     'Content-Type: text/event-stream\r\n'
     'Cache-Control: no-cache\r\n'
     'Connection: keep-alive\r\n'
-    'Access-Control-Allow-Credentials: true\r\n' 
-    "${origin != null ? 'Access-Control-Allow-Origin: $origin\r\n'  : ''}"
+    'Access-Control-Allow-Credentials: true\r\n'
+    "${origin != null ? 'Access-Control-Allow-Origin: $origin\r\n' : ''}"
     '\r\n\r\n';
 
 class _SseMessage {
diff --git a/pubspec.yaml b/pubspec.yaml
index 1c2b351..6f65957 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: sse
-version: 4.1.0
+version: 4.1.1-dev
 homepage: https://github.com/dart-lang/sse
 description: >-
   Provides client and server functionality for setting up bi-directional
diff --git a/test/sse_test.dart b/test/sse_test.dart
index 578b0b7..8b4023c 100644
--- a/test/sse_test.dart
+++ b/test/sse_test.dart
@@ -206,37 +206,17 @@
 
       // Close the underlying connection.
       closeSink(connection);
-
-      // The isInKeepAlivePeriod flag may only be set for a short period because
-      // the client may connect very quickly, so only pump until it changes.
-      var maxPumps = 100;
-      while (!connection.isInKeepAlivePeriod && maxPumps-- > 0) {
-        await pumpEventQueue(times: 1);
-      }
-
-      // Ensure there's still a connection and it's marked as in the keep-alive
-      // state.
-      expect(connection.isInKeepAlivePeriod, isTrue);
-      expect(handler.numberOfClients, 1);
-
       // Ensure we can still round-trip data on the original connection and that
       // the connection is no longer marked keep-alive once it's reconnected.
       connection.sink.add('bar');
       var queue = StreamQueue(connection.stream);
       expect(await queue.next, 'bar');
-      expect(connection.isInKeepAlivePeriod, isFalse);
 
       // Now check that we can reconnect multiple times.
       closeSink(connection);
-      maxPumps = 100;
-      while (!connection.isInKeepAlivePeriod && maxPumps-- > 0) {
-        await pumpEventQueue(times: 1);
-      }
-      expect(connection.isInKeepAlivePeriod, isTrue);
-      expect(handler.numberOfClients, 1);
       connection.sink.add('bar');
       expect(await queue.next, 'bar');
-      expect(connection.isInKeepAlivePeriod, isFalse);
+      expect(handler.numberOfClients, 1);
     });
 
     test('messages sent during disconnect arrive in-order', () async {
diff --git a/tool/travis-setup.sh b/tool/travis-setup.sh
deleted file mode 100755
index 33c093d..0000000
--- a/tool/travis-setup.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-# Copyright 2019 Google Inc. All Rights Reserved.
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Fast fail the script on failures.
-set -e
-
-pub get
diff --git a/tool/travis.sh b/tool/travis.sh
deleted file mode 100755
index 9ebd3d4..0000000
--- a/tool/travis.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-# Copyright 2019 Google Inc. All Rights Reserved.
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-STATUS=0
-
-# Analyze package.
-dartanalyzer .
-ANALYSIS_STATUS=$?
-if [[ $ANALYSIS_STATUS -ne 0 ]]; then
-  STATUS=$ANALYSIS_STATUS
-fi
-
-# Run tests.
-pub run test -r expanded -p vm -j 1
-TEST_STATUS=$?
-if [[ $TEST_STATUS -ne 0 ]]; then
-  STATUS=$TEST_STATUS
-fi
-
-# Exit chromedriver and geckodriver.
-kill $PIDC
-
-exit $STATUS