From fc6a4fd8754fff791024099e9909d05d2bb5d635 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Wed, 13 Jan 2021 09:12:35 -0700 Subject: [PATCH 1/2] Set up Github actions CI --- .github/workflows/dart_ci.yml | 49 +++++++++++++++++++++++++++++++++ Dockerfile | 52 ++++++++++++++--------------------- README.md | 2 +- 3 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/dart_ci.yml diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml new file mode 100644 index 00000000..09c52c6e --- /dev/null +++ b/.github/workflows/dart_ci.yml @@ -0,0 +1,49 @@ +name: Dart CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [stable, dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.1 + with: + channel: ${{ matrix.sdk }} + + - name: Print Dart SDK version + run: dart --version + + - id: install + name: Install dependencies + run: dart pub get + + - name: Validate dependencies + run: dart pub run dependency_validator -i build_runner,build_test,build_web_compilers + if: always() && steps.install.outcome == 'success' + + # TODO: Uncomment this, and remove the Dart 2.7.2 format step in the Workiva Build Dockerfile + # once we are able to bump the lower bound of SDK. +# - name: Verify formatting +# run: dart format --output=none --line-length=120 --set-exit-if-changed . +# if: always() && ${{ matrix.sdk }} == 'stable' && steps.install.outcome == 'success' + + - name: Analyze project source + run: dart analyze + if: always() && steps.install.outcome == 'success' + + - name: Run tests (DDC) + run: dart pub run build_runner test -- --preset dartdevc + if: always() && steps.install.outcome == 'success' + + - name: Run tests (dart2js) + run: dart pub run build_runner test --release -- --preset dart2js + if: always() && steps.install.outcome == 'success' diff --git a/Dockerfile b/Dockerfile index 3fbd606e..183b4be2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,28 @@ -FROM drydock-prod.workiva.net/workiva/dart_build_image:1 +FROM google/dart:2.7 + +# Expose env vars for git ssh access +ARG GIT_SSH_KEY +ARG KNOWN_HOSTS_CONTENT +# Install SSH keys for git ssh access +RUN mkdir /root/.ssh +RUN echo "$KNOWN_HOSTS_CONTENT" > "/root/.ssh/known_hosts" +RUN echo "$GIT_SSH_KEY" > "/root/.ssh/id_rsa" +RUN chmod 700 /root/.ssh/ +RUN chmod 600 /root/.ssh/id_rsa +RUN echo "Setting up ssh-agent for git-based dependencies" +RUN eval "$(ssh-agent -s)" && \ + ssh-add /root/.ssh/id_rsa -# Chrome install taken from https://github.com/Workiva/dart_unit_test_image/blob/master@%7B13-01-2021%7D/Dockerfile - -# Set the expected Chrome major version. This allows us to update the expected version when -# we need to roll out a new version of this base image with a new chrome version as the only change -ENV EXPECTED_CHROME_VERSION=87 - -# Install Chrome -RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \ - apt-get -qq update && apt-get install -y google-chrome-stable && \ - mv /usr/bin/google-chrome-stable /usr/bin/google-chrome && \ - sed -i --follow-symlinks -e 's/\"\$HERE\/chrome\"/\"\$HERE\/chrome\" --no-sandbox/g' /usr/bin/google-chrome - -# Fail the build if the version doesn't match what we expected -RUN google-chrome --version | grep " $EXPECTED_CHROME_VERSION\." +WORKDIR /build/ +ADD pubspec.yaml /build +RUN pub get -# Need to analyze and format since dart_build_image only does it automatically for -# packages that depend on dart_dev -RUN dartanalyzer . +# TODO: Remove this and instead run it within the github actions CI on the stable channel once we are able to update the lower bound. RUN dartfmt --line-length=120 --dry-run --set-exit-if-changed . -RUN pub run dependency_validator -i build_runner,build_test,build_web_compilers +ARG BUILD_ARTIFACTS_AUDIT=/build/pubspec.lock -# TODO run tests using dart_unit_test_image in skynet, remove Chrome install -RUN pub run build_runner test --release -- --preset dart2js --exclude-tags=dart-2-7-dart2js-variadic-issues -RUN pub run build_runner test -- --preset dartdevc - -RUN dart ./tool/run_consumer_tests.dart --orgName Workiva --repoName over_react --testCmd "pub run dart_dev test -P dartdevc" - - -# We need 2.9.2 to verify the Chrome MemoryInfo workaround: https://github.com/cleandart/react-dart/pull/280, -# and to run the tests that fail in 2.7 +# We need 2.9.2 to verify the Chrome MemoryInfo workaround: https://github.com/cleandart/react-dart/pull/280 # TODO remove the workaround as well as this config once SDK lower bound is >=2.9.3 FROM google/dart:2.9.2 RUN dart --version @@ -74,10 +65,7 @@ WORKDIR /build/ ADD . /build/ RUN pub get -# Run dart2js tests that fail in 2.7 -RUN pub run build_runner test --release -- --preset dart2js --tags=dart-2-7-dart2js-variadic-issues # Run DDC tests to verify Chrome workaround RUN pub run build_runner test -- --preset dartdevc - FROM scratch diff --git a/README.md b/README.md index 3083ba71..a5ab1494 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Pub](https://img.shields.io/pub/v/react.svg)](https://pub.dev/packages/react) ![ReactJS v16.10.1](https://img.shields.io/badge/React_JS-v16.10.1-green.svg) -[![Build Status](https://travis-ci.com/cleandart/react-dart.svg?branch=master)](https://travis-ci.com/cleandart/react-dart) +[![Dart CI](https://github.com/Workiva/react-dart/workflows/Dart%20CI/badge.svg?branch=master)](https://github.com/Workiva/react-dart/actions?query=workflow%3A%22Dart+CI%22+branch%3Amaster) [![React Dart API Docs](https://img.shields.io/badge/api_docs-react-blue.svg)](https://pub.dev/documentation/react/latest/) _Thanks to the folks at [Vacuumlabs](https://www.vacuumlabs.com/) for creating this project! :heart:_ From 76147d6b17d8bd7348b36381d717eabf5fb361f4 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Wed, 13 Jan 2021 12:54:23 -0700 Subject: [PATCH 2/2] Restore sdk 2.7.x tests in workiva build --- Dockerfile | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 183b4be2..170f7df0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,27 @@ -FROM google/dart:2.7 - -# Expose env vars for git ssh access -ARG GIT_SSH_KEY -ARG KNOWN_HOSTS_CONTENT -# Install SSH keys for git ssh access -RUN mkdir /root/.ssh -RUN echo "$KNOWN_HOSTS_CONTENT" > "/root/.ssh/known_hosts" -RUN echo "$GIT_SSH_KEY" > "/root/.ssh/id_rsa" -RUN chmod 700 /root/.ssh/ -RUN chmod 600 /root/.ssh/id_rsa -RUN echo "Setting up ssh-agent for git-based dependencies" -RUN eval "$(ssh-agent -s)" && \ - ssh-add /root/.ssh/id_rsa +FROM drydock-prod.workiva.net/workiva/dart_build_image:1 -WORKDIR /build/ -ADD pubspec.yaml /build -RUN pub get +# Chrome install taken from https://github.com/Workiva/dart_unit_test_image/blob/master@%7B13-01-2021%7D/Dockerfile + +# Set the expected Chrome major version. This allows us to update the expected version when +# we need to roll out a new version of this base image with a new chrome version as the only change +ENV EXPECTED_CHROME_VERSION=87 + +# Install Chrome +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ + echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \ + apt-get -qq update && apt-get install -y google-chrome-stable && \ + mv /usr/bin/google-chrome-stable /usr/bin/google-chrome && \ + sed -i --follow-symlinks -e 's/\"\$HERE\/chrome\"/\"\$HERE\/chrome\" --no-sandbox/g' /usr/bin/google-chrome -# TODO: Remove this and instead run it within the github actions CI on the stable channel once we are able to update the lower bound. +# Fail the build if the version doesn't match what we expected +RUN google-chrome --version | grep " $EXPECTED_CHROME_VERSION\." + +# TODO: Remove this and instead run it within the github actions CI on the stable channel once SDK lower bound is >=2.9.3 RUN dartfmt --line-length=120 --dry-run --set-exit-if-changed . -ARG BUILD_ARTIFACTS_AUDIT=/build/pubspec.lock +# TODO: Remove these test runs once SDK lower bound is >=2.9.3 +RUN pub run build_runner test --release -- --preset dart2js --exclude-tags=dart-2-7-dart2js-variadic-issues +RUN pub run build_runner test -- --preset dartdevc # We need 2.9.2 to verify the Chrome MemoryInfo workaround: https://github.com/cleandart/react-dart/pull/280 # TODO remove the workaround as well as this config once SDK lower bound is >=2.9.3 @@ -67,5 +68,7 @@ ADD . /build/ RUN pub get # Run DDC tests to verify Chrome workaround RUN pub run build_runner test -- --preset dartdevc +# Run dart2js tests that fail in 2.7 +RUN pub run build_runner test --release -- --preset dart2js --tags=dart-2-7-dart2js-variadic-issues FROM scratch