From e12ef6f481254a49b7128fc7f302064757a59097 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 24 Jan 2022 18:29:11 -0800 Subject: [PATCH 1/2] Allow PRs to be linked to the Dart Sass and embedded protocol repos --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ tool/grind.dart | 5 ++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac5dce35..b81280ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,28 @@ jobs: with: { version: "${{ env.protoc_version }}", repo-token: "${{ github.token }}" } - uses: dart-lang/setup-dart@v1 with: {sdk: "${{ matrix.dart_channel }}"} + + - name: Check out Dart Sass + uses: sass/clone-linked-repo@v1 + with: + repo: sass/dart-sass + path: build/dart-sass + default-ref: null + + - name: Add Dart Sass to pubspec + run: > + if [[ -d build/dart-sass ]]; then + echo "dependency_overrides: {sass: {path: build/dart-sass}}" >> pubspec.yaml + fi + shell: bash + + - name: Check out embedded Sass protocol + uses: sass/clone-linked-repo@v1 + with: {repo: sass/embedded-protocol, path: build/embedded-protocol} + - run: dart pub get - run: dart pub run grinder protobuf + env: {UPDATE_SASS_PROTOCOL: false} - run: dart pub run grinder pkg-standalone-dev - name: Run tests run: dart pub run test -r expanded @@ -42,8 +62,28 @@ jobs: - uses: arduino/setup-protoc@v1 with: { version: "${{ env.protoc_version }}", repo-token: "${{ github.token }}" } - uses: dart-lang/setup-dart@v1 + + - name: Check out Dart Sass + uses: sass/clone-linked-repo@v1 + with: + repo: sass/dart-sass + path: build/dart-sass + default-ref: null + + - name: Add Dart Sass to pubspec + run: > + if [[ -d build/dart-sass ]]; then + echo "dependency_overrides: {sass: {path: build/dart-sass}}" >> pubspec.yaml + fi + shell: bash + + - name: Check out embedded Sass protocol + uses: sass/clone-linked-repo@v1 + with: {repo: sass/embedded-protocol, path: build/embedded-protocol} + - run: dart pub get - run: dart pub run grinder protobuf + env: {UPDATE_SASS_PROTOCOL: false} - name: Analyze dart run: dartanalyzer --fatal-warnings ./ diff --git a/tool/grind.dart b/tool/grind.dart index 81a17d40..c0930e8b 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -50,7 +50,10 @@ dart pub run protoc_plugin %* run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']); } - await cloneOrPull("git://github.com/sass/embedded-protocol"); + if (Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false') { + await cloneOrPull("git://github.com/sass/embedded-protocol"); + } + await runAsync("protoc", arguments: [ "-Ibuild/embedded-protocol", From 2b34ec0b1a8c4fe785920e9b4a0674fc335e8f8a Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 25 Jan 2022 17:15:37 -0800 Subject: [PATCH 2/2] Add a test that verifies the Dart Sass version This ensures it matches the version declared in the pubspec, so that we don't end up merging a different version than the PR tested. --- pubspec.lock | 4 ++-- pubspec.yaml | 4 ++-- test/dependencies_test.dart | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/dependencies_test.dart diff --git a/pubspec.lock b/pubspec.lock index bd0fd39c..f5363710 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -315,7 +315,7 @@ packages: name: sass url: "https://pub.dartlang.org" source: hosted - version: "1.48.0" + version: "1.49.0" sass_analysis: dependency: "direct dev" description: @@ -331,7 +331,7 @@ packages: name: sass_api url: "https://pub.dartlang.org" source: hosted - version: "1.0.0-beta.28" + version: "1.0.0-beta.29" shelf: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1dd70a61..6736832f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass_embedded -version: 1.0.0-beta.16 +version: 1.0.0-dev description: An implementation of the Sass embedded protocol using Dart Sass. homepage: https://github.com/sass/dart-sass-embedded @@ -14,7 +14,7 @@ dependencies: meta: ^1.1.0 path: ^1.6.0 protobuf: ^2.0.0 - sass: ^1.42.0 + sass: 1.49.0 sass_api: ^1.0.0-beta.5 source_span: ^1.1.0 stack_trace: ^1.6.0 diff --git a/test/dependencies_test.dart b/test/dependencies_test.dart new file mode 100644 index 00000000..bf2f2ca5 --- /dev/null +++ b/test/dependencies_test.dart @@ -0,0 +1,30 @@ +// Copyright 2022 Google LLC. 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. + +import 'dart:io'; + +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:test/test.dart'; + +/// This package's pubspec. +var _pubspec = Pubspec.parse(File('pubspec.yaml').readAsStringSync(), + sourceUrl: Uri.parse('pubspec.yaml')); + +void main() { + // Assert that our declared dependency on Dart Sass is either a Git dependency + // or the same version as the version we're testing against. + + test('depends on a compatible version of Dart Sass', () { + var sassDependency = _pubspec.dependencies['sass']; + if (sassDependency is GitDependency) return; + + var actualVersion = + (Process.runSync('dart', ['run', 'sass', '--version']).stdout as String) + .trim(); + expect(sassDependency, isA()); + expect(actualVersion, + equals((sassDependency as HostedDependency).version.toString())); + }); +}