Skip to content

Commit

Permalink
Run shared JS tests from the sass-spec repo (#1486)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Sep 16, 2021
1 parent 52ef3c6 commit cfb7e40
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 59 deletions.
92 changes: 75 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI

defaults:
run: {shell: bash}

env:
# Run on Node 14 because node-fibers doesn't support odd-numbered Node
# versions. Note: when changing this, also change
Expand All @@ -14,8 +17,8 @@ on:
pull_request:

jobs:
sass_spec:
name: "sass-spec | Dart ${{ matrix.dart_channel }} | ${{ matrix.async_label }}"
sass_spec_language:
name: "Language Tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.async_label }}"
runs-on: ubuntu-latest

strategy:
Expand All @@ -34,13 +37,8 @@ jobs:
- uses: dart-lang/setup-dart@v1
with: {sdk: "${{ matrix.dart_channel }}"}
- run: dart pub get
# Set up the environment to run the sass-spec runner which is written in Ruby
- name: Set up sass-spec
run: |
export sass_spec_ref=`tool/github-action/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
run: tool/github-action/check-out-sass-spec.sh
env:
PR_BRANCH: "${{ github.base_ref }}"
CURRENT_REF: "${{ github.ref }}"
Expand All @@ -54,6 +52,60 @@ jobs:
working-directory: sass-spec
env: {extra_args: "${{ matrix.async_args }}"}

# The versions should be kept up-to-date with the latest LTS Node releases.
# 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 }}"
runs-on: "${{ matrix.os }}"

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dart_channel: [stable]
node_version: [14]
include:
# Include LTS versions on Ubuntu
- os: ubuntu-latest
dart_channel: stable
node_version: 12
- os: ubuntu-latest
dart_channel: stable
node_version: 10
- os: ubuntu-latest
dart_channel: dev
node_version: 14

steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
with: {sdk: "${{ matrix.dart_channel }}"}
- run: dart pub get
- uses: actions/setup-node@v2
with: {node-version: "${{ matrix.node_version }}"}

- name: Check out sass-spec
run: tool/github-action/check-out-sass-spec.sh
env:
PR_BRANCH: "${{ github.base_ref }}"
CURRENT_REF: "${{ github.ref }}"
PR_BODY: "${{ github.event.pull_request.body }}"

- name: Build JS
run: dart pub run grinder pkg-npm-dev

- name: Link Dart Sass into sass-spec
run: npm install ../build/npm
working-directory: sass-spec

- name: Check out Sass specification
run: git clone https://github.com/sass/sass.git language --depth 1

- name: Run tests
run: npm run js-api-spec -- --sassSassRepo ../language
working-directory: sass-spec

dart_tests:
name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
Expand Down Expand Up @@ -142,10 +194,16 @@ jobs:
--errors ambiguous-doc-reference,broken-link,deprecated
--errors unknown-directive,unknown-macro,unresolved-doc-reference

sanity_checks:
name: Sanity checks
double_check:
name: Double-check
runs-on: ubuntu-latest
needs: [sass_spec, dart_tests, node_tests, static_analysis, dartdoc]
needs:
- sass_spec_language
- sass_spec_js
- dart_tests
- node_tests
- static_analysis
- dartdoc
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand All @@ -158,7 +216,7 @@ jobs:
deploy_github_linux:
name: "Deploy Github: Linux"
runs-on: ubuntu-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand Down Expand Up @@ -206,7 +264,7 @@ jobs:
deploy_npm:
name: Deploy npm
runs-on: ubuntu-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand Down Expand Up @@ -241,7 +299,7 @@ jobs:
deploy_pub:
name: "Deploy Pub"
runs-on: ubuntu-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand Down Expand Up @@ -274,7 +332,7 @@ jobs:
deploy_homebrew:
name: "Deploy Homebrew"
runs-on: ubuntu-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand All @@ -290,7 +348,7 @@ jobs:
deploy_chocolatey:
name: "Deploy Chocolatey"
runs-on: windows-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand All @@ -304,7 +362,7 @@ jobs:
deploy_website:
name: "Deploy sass-lang.com"
runs-on: ubuntu-latest
needs: [sanity_checks]
needs: [double_check]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'"

steps:
Expand Down
47 changes: 47 additions & 0 deletions tool/github-action/check-out-sass-spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash -e
# Copyright 2016 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.

# Echoes the sass-spec Git ref that should be checked out for the current GitHub
# Actions run. If we're running specs for a pull request which refers to a
# sass-spec pull request, we'll run against the latter rather than sass-spec
# main.
function choose-ref() {
if [ -z "$PR_BRANCH" ]; then
# Remove the "refs/heads/" prefix
current_branch="${CURRENT_REF:11}"
else
current_branch="$PR_BRANCH"
fi

if [[ "$current_branch" == feature.* ]]; then
default="$current_branch"
else
default=main
fi

# We don't have a PR_BRANCH so we are not in a pull request
if [ -z "$PR_BRANCH" ]; then
>&2 echo "Ref: $default."
echo "$default"
exit 0
fi

>&2 echo "$PR_BODY"

RE_SPEC_PR="sass/sass-spec(#|/pull/)([0-9]+)"

if [[ "$PR_BODY" =~ $RE_SPEC_PR ]]; then
ref="pull/${BASH_REMATCH[2]}/head"
>&2 echo "Ref: $ref."
echo "$ref"
else
>&2 echo "Ref: $default."
echo "$default"
fi
}

git init sass-spec
git -C sass-spec fetch git://github.com/sass/sass-spec "$(choose-ref)" --depth 1
git -C sass-spec checkout FETCH_HEAD
42 changes: 0 additions & 42 deletions tool/github-action/sass-spec-ref.sh

This file was deleted.

0 comments on commit cfb7e40

Please sign in to comment.