Skip to content

Commit

Permalink
Merge pull request #1955 from sass/embedded
Browse files Browse the repository at this point in the history
Merge the Dart Sass embedded compiler repo into the Dart Sass repo
  • Loading branch information
nex3 committed May 15, 2023
2 parents 8dddcb7 + 6d6d5ee commit bd771af
Show file tree
Hide file tree
Showing 39 changed files with 5,739 additions and 93 deletions.
18 changes: 18 additions & 0 deletions .github/util/build-protobuf/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build Protobuf
description: Check out and build the Dart Sass embedded protocol buffer.
inputs:
github-token: {required: true}
runs:
using: composite
steps:
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ inputs.github-token }}"}

- name: Check out embedded Sass protocol
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-protocol, path: build/embedded-protocol}

- name: Generate Dart from protobuf
run: dart run grinder protobuf
env: {UPDATE_SASS_PROTOCOL: false}
shell: bash
235 changes: 165 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,48 @@ on:
pull_request:

jobs:
format:
name: Code formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart format --fix .
- run: git diff --exit-code

static_analysis:
name: Static analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get

- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

- name: Analyze Dart
run: dart analyze --fatal-warnings ./

dartdoc:
name: Dartdoc
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: dartdoc sass
run: dart run dartdoc --quiet --no-generate-docs
--errors ambiguous-doc-reference,broken-link,deprecated
--errors unknown-directive,unknown-macro,unresolved-doc-reference
- name: dartdoc sass_api
run: cd pkg/sass_api && dart run dartdoc --quiet --no-generate-docs
--errors ambiguous-doc-reference,broken-link,deprecated
--errors unknown-directive,unknown-macro,unresolved-doc-reference

sass_spec_language:
name: "Language Tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.async_label }}"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -43,6 +85,10 @@ jobs:
with: {node-version: "${{ env.DEFAULT_NODE_VERSION }}"}
- run: npm install
working-directory: sass-spec

- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

- name: Run specs
run: npm run sass-spec -- --dart .. $extra_args
working-directory: sass-spec
Expand All @@ -52,7 +98,7 @@ jobs:
# They next need to be rotated April 2021. See
# https://github.com/nodejs/Release.
sass_spec_js:
name: "JS API Tests | Dart ${{ matrix.dart_channel }} | Node ${{ matrix.node_version }} | ${{ matrix.os }}"
name: "JS API Tests | Pure JS | Dart ${{ matrix.dart_channel }} | Node ${{ matrix.node_version }} | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"

strategy:
Expand Down Expand Up @@ -82,6 +128,9 @@ jobs:
with: {node-version: "${{ matrix.node_version }}"}
- run: npm install

- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

- name: Check out sass-spec
uses: sass/clone-linked-repo@v1
with: {repo: sass/sass-spec}
Expand All @@ -103,6 +152,72 @@ jobs:
run: npm run js-api-spec -- --sassSassRepo ../language --sassPackage ../build/npm
working-directory: sass-spec

# The versions should be kept up-to-date with the latest LTS Node releases.
# They next need to be rotated October 2021. See
# https://github.com/nodejs/Release.
sass_spec_js_embedded:
name: 'JS API Tests | Embedded | Node ${{ matrix.node_version }} | ${{ matrix.os }}'
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
node_version: [18]
include:
# Include LTS versions on Ubuntu
- os: ubuntu
node_version: 16
- os: ubuntu
node_version: 14

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with: {sdk: stable}
- run: dart pub get

- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

- name: Check out the embedded host
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-host-node}

- name: Check out the JS API definition
uses: sass/clone-linked-repo@v1
with: {repo: sass/sass, path: language}

- name: Initialize embedded host
run: |
npm install
npm run init -- --protocol-path=../build/embedded-protocol \
--compiler-path=.. --api-path=../language
npm run compile
mv {`pwd`/,dist/}lib/src/vendor/dart-sass
working-directory: embedded-host-node

- name: Check out sass-spec
uses: sass/clone-linked-repo@v1
with: {repo: sass/sass-spec}

- name: Install sass-spec dependencies
run: npm install
working-directory: sass-spec

- name: Version info
run: |
path=embedded-host-node/dist/lib/src/vendor/dart-sass/sass
if [[ -f "$path.cmd" ]]; then "./$path.cmd" --version
elif [[ -f "$path.bat" ]]; then "./$path.bat" --version
elif [[ -f "$path.exe" ]]; then "./$path.exe" --version
else "./$path" --version
fi
- name: Run tests
run: npm run js-api-spec -- --sassPackage ../embedded-host-node --sassSassRepo ../language
working-directory: sass-spec

dart_tests:
name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
Expand All @@ -119,9 +234,13 @@ jobs:
- uses: dart-lang/setup-dart@v1
with: {sdk: "${{ matrix.dart_channel }}"}
- run: dart pub get

- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

- run: dart run grinder pkg-standalone-dev
- name: Run tests
run: dart run test -p vm -x node -r expanded
run: dart run test -p vm -x node

# Unit tests that use Node.js, defined in test/.
#
Expand Down Expand Up @@ -158,37 +277,13 @@ jobs:
- uses: actions/setup-node@v3
with: {node-version: "${{ matrix.node_version }}"}
- run: npm install
- run: dart run grinder before-test
- name: Run tests
run: dart run test -j 2 -t node -r expanded

static_analysis:
name: Static analysis
runs-on: ubuntu-latest
- uses: ./.github/util/build-protobuf
with: {github-token: "${{ github.token }}"}

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: Analyze Dart
run: dart analyze --fatal-warnings --fatal-infos .

dartdoc:
name: Dartdoc
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: dartdoc sass
run: dart run dartdoc --quiet --no-generate-docs
--errors ambiguous-doc-reference,broken-link,deprecated
--errors unknown-directive,unknown-macro,unresolved-doc-reference
- name: dartdoc sass_api
run: cd pkg/sass_api && dart run dartdoc --quiet --no-generate-docs
--errors ambiguous-doc-reference,broken-link,deprecated
--errors unknown-directive,unknown-macro,unresolved-doc-reference
- run: dart run grinder before-test
- name: Run tests
run: dart run test -j 2 -t node

double_check:
name: Double-check
Expand All @@ -200,6 +295,7 @@ jobs:
- node_tests
- static_analysis
- dartdoc
- format
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand Down Expand Up @@ -283,8 +379,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run grinder protobuf
- name: Deploy
run: dart run grinder pkg-github-release pkg-github-linux-ia32 pkg-github-linux-x64
env:
Expand All @@ -306,6 +405,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run grinder protobuf
- uses: docker/setup-qemu-action@v2
- name: Deploy
run: |
Expand Down Expand Up @@ -341,11 +445,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
# Workaround for dart-lang/setup-dart#59
with:
architecture: ${{ matrix.architecture }}
- run: dart pub get
- run: dart run grinder protobuf
- name: Deploy
run: dart run grinder pkg-github-${{ matrix.platform }}
env:
Expand Down Expand Up @@ -397,6 +504,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run grinder protobuf
- uses: actions/setup-node@v3
with: {node-version: "${{ env.DEFAULT_NODE_VERSION }}"}
- name: Deploy
Expand Down Expand Up @@ -455,7 +563,6 @@ jobs:
runs-on: ubuntu-latest
needs: [bootstrap, bourbon, foundation, bulma]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -469,58 +576,46 @@ jobs:
message: Cut a release for a new Dart Sass version
commit: --allow-empty

release_embedded_compiler:
name: "Release Embedded Compiler"
release_embedded_host:
name: "Release Embedded Host"
runs-on: ubuntu-latest
needs: [deploy_pub, deploy_sub_packages]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

needs: [deploy_github_linux, deploy_github_linux_qemu, deploy_github]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
steps:
- uses: actions/checkout@v3
with:
repository: sass/dart-sass-embedded
repository: sass/embedded-host-node
token: ${{ secrets.GH_TOKEN }}
- uses: dart-lang/setup-dart@v1
- uses: frenck/action-setup-yq@v1
with: {version: v4.30.5} # frenck/action-setup-yq#35

- name: Get version
id: version
run: |
echo "sass=${GITHUB_REF##*/}" | tee --append $GITHUB_OUTPUT
echo "sass_api=$(curl --fail --silent --show-error --location https://raw.githubusercontent.com/sass/dart-sass/${GITHUB_REF##*/}/pkg/sass_api/pubspec.yaml | yq .version)" | tee --append $GITHUB_OUTPUT
run: echo "::set-output name=version::${GITHUB_REF##*/}"

- name: Update version
run: |
sed -i 's/version: .*/version: ${{ steps.version.outputs.sass }}/' pubspec.yaml
dart pub remove sass_api
dart pub remove sass
dart pub add sass:${{ steps.version.outputs.sass }}
dart pub add sass_api:^${{ steps.version.outputs.sass_api }}
# Delete a dependency override on Sass if it exists, and delete the
# dependency_overrides field if it's now empty. The embedded compiler
# often uses dev dependencies to run against the latest Dart Sass, but
# once we release the latest version that's no longer necessary.
#
# TODO(dart-lang/pub#3700): Use pub for this instead to avoid removing
# blank lines. See also mikefarah/yq#515.
yq -i '
del(.dependency_overrides.sass) |
to_entries |
map(select(.key != "dependency_overrides" or (.value | length >0))) |
from_entries
' pubspec.yaml
# The embedded compiler has a checked-in pubspec.yaml, so upgrade to
# make sure we're releasing against the latest version of all deps.
dart pub upgrade
curl --fail --silent --show-error --location --output CHANGELOG.md https://raw.githubusercontent.com/sass/dart-sass/${{ steps.version.outputs.sass }}/CHANGELOG.md
# Update binary package versions
for dir in $(ls npm); do
cat "npm/$dir/package.json" |
jq --arg version ${{ steps.version.outputs.version }} '
.version |= $version
' > package.json.tmp &&
mv package.json.tmp "npm/$dir/package.json"
done
# Update main package version and dependencies on binary packages
cat package.json |
jq --arg version ${{ steps.version.outputs.version }} '
.version |= $version |
."compiler-version" |= $version |
.optionalDependencies = (.optionalDependencies | .[] |= $version)
' > package.json.tmp &&
mv package.json.tmp package.json
curl https://raw.githubusercontent.com/sass/dart-sass/${{ steps.version.outputs.version }}/CHANGELOG.md > CHANGELOG.md
shell: bash

- uses: EndBug/add-and-commit@v8
with:
author_name: Sass Bot
author_email: sass.bot.beep.boop@gmail.com
message: Update Dart Sass version and release
tag: ${{ steps.version.outputs.sass }}
tag: ${{ steps.version.outputs.version }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ package-lock.json
node_modules/
/doc/api
/pkg/*/doc/api

# Generated protocol buffer files.
*.pb*.dart
Loading

0 comments on commit bd771af

Please sign in to comment.