diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fc4b98e4..f5fc51496 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,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: @@ -34,13 +34,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 }}" @@ -54,6 +49,59 @@ 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 + 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 }}" @@ -142,10 +190,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: @@ -158,7 +212,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: @@ -206,7 +260,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: @@ -241,7 +295,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: @@ -274,7 +328,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: @@ -290,7 +344,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: @@ -304,7 +358,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: diff --git a/tool/github-action/check-out-sass-spec.sh b/tool/github-action/check-out-sass-spec.sh new file mode 100755 index 000000000..8dd941df3 --- /dev/null +++ b/tool/github-action/check-out-sass-spec.sh @@ -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 diff --git a/tool/github-action/sass-spec-ref.sh b/tool/github-action/sass-spec-ref.sh deleted file mode 100755 index 069c0900b..000000000 --- a/tool/github-action/sass-spec-ref.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/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. - -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