diff --git a/.github/util/initialize/action.yml b/.github/util/initialize/action.yml index ad2abda5e..30252d356 100644 --- a/.github/util/initialize/action.yml +++ b/.github/util/initialize/action.yml @@ -2,7 +2,7 @@ name: Initialize description: Check out Dart Sass and build the embedded protocol buffer. inputs: github-token: {required: true} - node-version: {required: false, default: 18} + node-version: {required: false, default: 'lts/*'} dart-sdk: {required: false, default: stable} architecture: {required: false} runs: diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 000000000..5f2bb57db --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,71 @@ +name: Build for android + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + lib: lib64 + platform: linux/amd64 + - arch: ia32 + lib: lib + platform: linux/amd64 + - arch: arm64 + lib: lib64 + platform: linux/arm64 + - arch: arm + lib: lib + platform: linux/arm64 + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:master # need qemu >= 7.0.0 + + - name: Compile Protobuf + run: | + docker run --rm -i \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + docker.io/library/dart <<'EOF' + set -e + curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1 + dart pub get + dart run grinder protobuf + EOF + + - name: Build + run: | + docker run --rm -i \ + --platform ${{ matrix.platform }} \ + --privileged \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + ghcr.io/dart-android/dart <<'EOF' + set -e + export DART_SDK=/system/${{ matrix.lib }}/dart + export PATH=$DART_SDK/bin:$PATH + dart pub get + dart run grinder pkg-standalone-android-${{ matrix.arch }} + EOF + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-android-${{ matrix.arch }} + path: build/*.tar.gz + if-no-files-found: error + compression-level: 0 diff --git a/.github/workflows/build-linux-musl.yml b/.github/workflows/build-linux-musl.yml new file mode 100644 index 000000000..050292f4a --- /dev/null +++ b/.github/workflows/build-linux-musl.yml @@ -0,0 +1,89 @@ +name: Build for linux-musl + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + platform: linux/amd64 + - arch: ia32 + platform: linux/386 + - arch: arm64 + platform: linux/arm64 + - arch: arm + platform: linux/arm/v7 + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Compile Protobuf + run: | + docker run --rm -i \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + docker.io/library/dart <<'EOF' + set -e + curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1 + dart pub get + dart run grinder protobuf + EOF + + # https://gitlab.com/qemu-project/qemu/-/issues/1729 + # + # There is a bug in qemu's mremap causing pthread_getattr_np in musl to stuck in a loop on arm. + # Unless qemu fixes the bug or we get a real linux-arm runner, we cannot build aot-snapshot + # for arm on CI. So, we create a kernel snapshot for arm build in amd64 container instead. + - name: Build + run: | + docker run --rm -i \ + --platform ${{ matrix.arch == 'arm' && 'linux/amd64' || matrix.platform }} \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + ghcr.io/dart-musl/dart <<'EOF' + set -e + dart pub get + dart run grinder pkg-standalone-linux-${{ matrix.arch }} + # Rename the artifact from -linux- to -linux-musl- to avoid conflict with glibc builds. + find build -name '*.tar.gz' -print0 | xargs -0 -n 1 -- sh -xc 'mv "$1" "$(echo "$1" | sed -e "s/linux/linux-musl/")"' -- + EOF + + # The kernel snapshot created for arm in the previous step is bundling a glibc based dart runtime + # due to how cli_pkg downloads the sdk for building non-native platforms. Therefore we need to + # replace it with musl-libc based dart runtime to create a working linux-musl-arm package. + - name: Fix Dart Runtime + if: matrix.arch == 'arm' + run: | + docker run --rm -i \ + --platform ${{ matrix.platform }} \ + --volume $PWD:$PWD \ + --workdir $PWD \ + ghcr.io/dart-musl/dart <<'EOF' + set -e + apk add --no-cache tar + cd build + DART_RUNTIME=$(tar -tzf *.tar.gz --wildcards "*/src/dart") + tar -xzf *.tar.gz + cp $DART_SDK/bin/dart $DART_RUNTIME + tar -czf *.tar.gz "$(dirname "$(dirname "$DART_RUNTIME")")" + EOF + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-linux-musl-${{ matrix.arch }} + path: build/*.tar.gz + if-no-files-found: error + compression-level: 0 diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 000000000..e36628c4a --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,62 @@ +name: Build for linux + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + platform: linux/amd64 + - arch: ia32 + platform: linux/amd64 + - arch: arm + platform: linux/arm/v7 + - arch: arm64 + platform: linux/arm64 + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Compile Protobuf + run: | + docker run --rm -i \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + docker.io/library/dart <<'EOF' + set -e + curl -fsSL -H "Authorization: Bearer ${{ github.token }}" "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m).tar.gz" | tar -xzC /usr/local --strip-components 1 + dart pub get + dart run grinder protobuf + EOF + + - name: Build + run: | + docker run --rm -i \ + --platform ${{ matrix.platform }} \ + --volume "$PWD:$PWD" \ + --workdir "$PWD" \ + docker.io/library/dart:latest <<'EOF' + set -e + dart pub get + dart run grinder pkg-standalone-linux-${{ matrix.arch }} + EOF + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-linux-${{ matrix.arch }} + path: build/*.tar.gz + if-no-files-found: error + compression-level: 0 diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 000000000..7d31257bc --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,38 @@ +name: Build for macos + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + + runs-on: ${{ matrix.runner }} + + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + runner: macos-latest + # https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/ + - arch: arm64 + runner: macos-latest-xlarge + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Build + run: dart run grinder pkg-standalone-macos-${{ matrix.arch }} + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-macos-${{ matrix.arch }} + path: build/*.tar.gz + if-no-files-found: error + compression-level: 0 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 000000000..7036dfa34 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,41 @@ +name: Build for windows + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + name: Build + + runs-on: ${{ matrix.runner }} + + strategy: + fail-fast: false + matrix: + include: + - arch: x64 + runner: windows-latest + - arch: ia32 + runner: windows-latest + # The support of windows-arm64 dart-sdk is in beta. + # TODO: Enable this once windows-arm64 support is stable. + # - arch: arm64 + # runner: windows-latest + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Build + run: dart run grinder pkg-standalone-windows-${{ matrix.arch }} + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-windows-${{ matrix.arch }} + path: build/*.zip + if-no-files-found: error + compression-level: 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e55102c9..cabc84e11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,14 +1,5 @@ name: CI -defaults: - run: {shell: bash} - -# The default Node version lives in ../util/initialize/action.yml. It should be -# kept up-to-date with the latest Node LTS releases, along with the various -# node-version matrices below. -# -# Next update: April 2021 - on: push: branches: [main, feature.*] @@ -16,317 +7,15 @@ on: pull_request: jobs: - format: - name: Code formatting - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - 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@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Analyze Dart - run: dart analyze --fatal-warnings ./ - - dartdoc: - name: Dartdoc - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - 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 - - strategy: - fail-fast: false - matrix: - dart_channel: [stable, dev] - async_label: [synchronous] - async_args: [''] - include: - - dart_channel: stable - async_label: asynchronous - async_args: '--cmd-args --async' - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - - uses: ./.github/util/sass-spec - - - name: Run specs - run: npm run sass-spec -- --dart .. $extra_args - 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 | Pure JS | 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: [18] - include: - # Include LTS versions on Ubuntu - - os: ubuntu-latest - dart_channel: stable - node-version: 16 - - os: ubuntu-latest - dart_channel: stable - node-version: 14 - - os: ubuntu-latest - dart_channel: dev - node-version: 18 - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - node-version: ${{ matrix.node-version }} - - uses: ./.github/util/sass-spec - - - name: Build JS - run: dart run grinder pkg-npm-dev - - - name: Check out Sass specification - uses: sass/clone-linked-repo@v1 - with: - repo: sass/sass - path: language - - - name: Run tests - 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 - if: "github.event_name != 'pull_request' || !contains(github.event.pull_request.body, 'skip sass-embedded')" - - 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@v4 - - uses: ./.github/util/initialize - with: - github-token: ${{ github.token }} - node-version: ${{ matrix.node-version }} - - uses: ./.github/util/sass-spec - - - name: Check out the embedded host - uses: sass/clone-linked-repo@v1 - with: {repo: sass/embedded-host-node} - - - name: Check out the language repo - uses: sass/clone-linked-repo@v1 - with: {repo: sass/sass, path: build/language} - - - name: Initialize embedded host - run: | - npm install - npm run init -- --compiler-path=.. --language-path=../build/language - npm run compile - mv {`pwd`/,dist/}lib/src/vendor/dart-sass - working-directory: embedded-host-node - - - 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 ../build/language - working-directory: sass-spec - - sass_spec_js_browser: - name: "JS API Tests | Browser | Dart ${{ matrix.dart_channel }}" - - strategy: - matrix: - dart_channel: [stable] - fail-fast: false - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: browser-actions/setup-chrome@v1 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - - uses: ./.github/util/sass-spec - - - name: Build JS - run: dart run grinder pkg-npm-dev - - - name: Install built dependencies - run: npm install - working-directory: build/npm - - - name: Check out Sass specification - uses: sass/clone-linked-repo@v1 - with: - repo: sass/sass - path: language - - - name: Run tests - run: npm run js-api-spec -- --sassSassRepo ../language --sassPackage ../build/npm --browser - working-directory: sass-spec - env: - CHROME_EXECUTABLE: chrome - - dart_tests: - name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }}" - runs-on: "${{ matrix.os }}" - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - dart_channel: [stable] - # TODO(nweiz): Re-enable this when - # https://github.com/dart-lang/sdk/issues/52121#issuecomment-1728534228 - # is addressed. - # include: [{os: ubuntu-latest, dart_channel: dev}] - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - - - run: dart run grinder pkg-standalone-dev - - name: Run tests - run: dart run test -x node - - # Unit tests that use Node.js, defined in test/. - # - # 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. - node_tests: - name: "Node 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: [18] - include: - # Include LTS versions on Ubuntu - - os: ubuntu-latest - dart_channel: stable - node-version: 16 - - os: ubuntu-latest - dart_channel: stable - node-version: 14 - - os: ubuntu-latest - dart_channel: dev - node-version: 18 - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - node-version: ${{ matrix.node-version }} - - - run: dart run grinder pkg-npm-dev - - name: Run tests - run: dart run test -t node -j 2 - - browser_tests: - name: "Browser Tests | Dart ${{ matrix.dart_channel }}" - - strategy: - matrix: - dart_channel: [stable] - fail-fast: false - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: browser-actions/setup-chrome@v1 - - uses: ./.github/util/initialize - with: - dart-sdk: ${{ matrix.dart_channel }} - github-token: ${{ github.token }} - - - run: dart run grinder pkg-npm-dev - - name: Run tests - run: dart run test -p chrome -j 2 - env: - CHROME_EXECUTABLE: chrome + test: + uses: ./.github/workflows/test.yml + secrets: inherit double_check: name: Double-check runs-on: ubuntu-latest - needs: - - sass_spec_language - - sass_spec_js - - sass_spec_js_browser - - sass_spec_js_embedded - - dart_tests - - node_tests - - browser_tests - - static_analysis - - dartdoc - - format - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" + needs: [test] + if: "startsWith(github.ref, 'refs/tags/') && github.event.repository.fork == false" steps: - uses: actions/checkout@v4 @@ -336,325 +25,16 @@ jobs: - name: Run checks run: dart run grinder double-check-before-release - bootstrap: - name: "Bootstrap ${{ matrix.bootstrap_version }}" - runs-on: ubuntu-latest - needs: [double_check] - - strategy: - fail-fast: false - matrix: - bootstrap_version: [4, 5] - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - run: dart run grinder fetch-bootstrap${{matrix.bootstrap_version}} - env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} - - name: Build - run: dart bin/sass.dart --quiet build/bootstrap/scss:build/bootstrap-output - - bourbon: - name: Bourbon - runs-on: ubuntu-latest + test_vendor: needs: [double_check] - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - run: dart run grinder fetch-bourbon - env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} - - name: Test - run: | - dart bin/sass.dart --quiet -I build/bourbon -I build/bourbon/spec/fixtures \ - build/bourbon/spec/fixtures:build/bourbon-output - - foundation: - name: Foundation - runs-on: ubuntu-latest - needs: [double_check] - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - run: dart run grinder fetch-foundation - env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} - # TODO(nweiz): Foundation has proper Sass tests, but they're currently not - # compatible with Dart Sass. Once they are, we should run those rather - # than just building the CSS output. - - name: Build - run: dart bin/sass.dart --quiet build/foundation-sites/assets:build/foundation-output - - bulma: - name: Bulma - runs-on: ubuntu-latest - needs: [double_check] - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - run: dart run grinder fetch-bulma - env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} - - name: Build - run: dart bin/sass.dart --quiet build/bulma/bulma.sass build/bulma-output.css - - deploy_github_linux: - name: "Deploy Github: linux-ia32, linux-x64" - runs-on: ubuntu-latest - needs: [bootstrap, bourbon, foundation, bulma] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder pkg-github-release pkg-github-linux-ia32 pkg-github-linux-x64 - env: - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_github_linux_qemu: - name: "Deploy Github: linux-${{ matrix.arch }}" - runs-on: ubuntu-latest - strategy: - matrix: - include: - - arch: arm - platform: linux/arm/v7 - - arch: arm64 - platform: linux/arm64 - needs: [deploy_github_linux] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - uses: docker/setup-qemu-action@v3 - - name: Deploy - run: | - docker run --rm \ - --env "GH_TOKEN=$GH_TOKEN" \ - --env "GH_USER=$GH_USER" \ - --platform ${{ matrix.platform }} \ - --volume "$PWD:$PWD" \ - --workdir "$PWD" \ - docker.io/library/dart:latest \ - /bin/sh -c "dart pub get && dart run grinder pkg-github-linux-${{ matrix.arch }}" - env: - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_github: - name: "Deploy Github: ${{ matrix.platform }}" - runs-on: ${{ matrix.runner }} - needs: [deploy_github_linux] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - strategy: - matrix: - include: - - runner: macos-latest - platform: macos-x64 - architecture: x64 - # https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/ - - runner: macos-latest-xlarge - platform: macos-arm64 - architecture: arm64 - - runner: windows-latest - platform: windows - architecture: x64 - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - # Workaround for dart-lang/setup-dart#59 - with: - github-token: ${{ github.token }} - architecture: ${{ matrix.architecture }} - - - name: Deploy - run: dart run grinder pkg-github-${{ matrix.platform }} - env: - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_npm: - name: Deploy npm - runs-on: ubuntu-latest - needs: [bootstrap, bourbon, foundation, bulma] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder pkg-npm-deploy - env: - NPM_TOKEN: "${{ secrets.NPM_TOKEN }}" - - deploy_bazel: - name: Deploy Bazel - runs-on: ubuntu-latest - needs: [deploy_npm] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder update-bazel - env: - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_pub: - name: "Deploy Pub" - runs-on: ubuntu-latest - needs: [bootstrap, bourbon, foundation, bulma] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder protobuf pkg-pub-deploy - env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"} - - deploy_sub_packages: - name: "Deploy Sub-Packages" - runs-on: ubuntu-latest - needs: [deploy_pub] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder deploy-sub-packages - env: - PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}" - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_homebrew: - name: "Deploy Homebrew" - runs-on: ubuntu-latest - needs: [bootstrap, bourbon, foundation, bulma] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@v1 - - run: dart pub get - - - name: Deploy - run: dart run grinder pkg-homebrew-update - env: - GH_TOKEN: "${{ secrets.GH_TOKEN }}" - GH_USER: sassbot - - deploy_chocolatey: - name: "Deploy Chocolatey" - runs-on: windows-latest - needs: [bootstrap, bourbon, foundation, bulma] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/util/initialize - with: {github-token: "${{ github.token }}"} - - - name: Deploy - run: dart run grinder pkg-chocolatey-deploy - env: {CHOCOLATEY_TOKEN: "${{ secrets.CHOCOLATEY_TOKEN }}"} - - deploy_website: - name: "Deploy sass-lang.com" - runs-on: ubuntu-latest - needs: [deploy_npm] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - steps: - - uses: actions/checkout@v4 - with: - repository: sass/sass-site - token: ${{ secrets.SASS_SITE_TOKEN }} - - - name: Get version - id: version - run: echo "version=${GITHUB_REF##*/}" | tee --append "$GITHUB_OUTPUT" - - - name: Update Dart Sass version - run: npm install sass@${{ steps.version.outputs.version }} - - - uses: EndBug/add-and-commit@v9 - with: - author_name: Sass Bot - author_email: sass.bot.beep.boop@gmail.com - message: Cut a release for a new Dart Sass version - commit: --allow-empty - - release_embedded_host: - name: "Release Embedded Host" - runs-on: ubuntu-latest - needs: [deploy_github_linux, deploy_github_linux_qemu, deploy_github] - if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass'" - steps: - - uses: actions/checkout@v4 - with: - repository: sass/embedded-host-node - token: ${{ secrets.GH_TOKEN }} - - - name: Get version - id: version - run: | - echo "version=${GITHUB_REF##*/}" | tee --append "$GITHUB_OUTPUT" - echo "protocol_version=$(curl -fsSL -H "Authorization: Bearer ${{ github.token }}" https://raw.githubusercontent.com/sass/sass/HEAD/spec/EMBEDDED_PROTOCOL_VERSION)" | tee --append "$GITHUB_OUTPUT" - - - name: Update version - run: | - # 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 }} --arg protocol_version ${{ steps.version.outputs.protocol_version }} ' - .version |= $version | - ."compiler-version" |= $version | - ."protocol-version" |= $protocol_version | - .optionalDependencies = (.optionalDependencies | .[] |= $version) - ' > package.json.tmp && - mv package.json.tmp package.json - curl -fsSL -H "Authorization: Bearer ${{ github.token }}" https://raw.githubusercontent.com/sass/dart-sass/${{ steps.version.outputs.version }}/CHANGELOG.md > CHANGELOG.md - shell: bash - - - uses: EndBug/add-and-commit@v9 - with: - author_name: Sass Bot - author_email: sass.bot.beep.boop@gmail.com - message: Update Dart Sass version and release - tag: ${{ steps.version.outputs.version }} + if: "startsWith(github.ref, 'refs/tags/') && github.event.repository.fork == false" + uses: ./.github/workflows/test-vendor.yml + secrets: inherit + + release: + needs: [test_vendor] + if: "startsWith(github.ref, 'refs/tags/') && github.event.repository.fork == false" + permissions: + contents: write + uses: ./.github/workflows/release.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..43d32c0e4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,219 @@ +name: Release + +on: + workflow_call: + +jobs: + build_android: + uses: ./.github/workflows/build-android.yml + secrets: inherit + + build_linux: + uses: ./.github/workflows/build-linux.yml + secrets: inherit + + build_linux_musl: + uses: ./.github/workflows/build-linux-musl.yml + secrets: inherit + + build_macos: + uses: ./.github/workflows/build-macos.yml + secrets: inherit + + build_windows: + uses: ./.github/workflows/build-windows.yml + secrets: inherit + + release_github: + name: Release Github + runs-on: ubuntu-latest + needs: [build_android, build_linux, build_linux_musl, build_macos, build_windows] + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder pkg-github-release + env: + GH_TOKEN: "${{ secrets.GH_TOKEN }}" + GH_USER: sassbot + + deploy_github: + name: Deploy Github + runs-on: ubuntu-latest + needs: [release_github] + + permissions: + contents: write + + steps: + - name: Download Artifact + uses: actions/download-artifact@v4 + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + build-*/* + + deploy_npm: + name: Deploy npm + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder pkg-npm-deploy + env: + NPM_TOKEN: "${{ secrets.NPM_TOKEN }}" + + deploy_bazel: + name: Deploy Bazel + runs-on: ubuntu-latest + needs: [deploy_npm] + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder update-bazel + env: + GH_TOKEN: "${{ secrets.GH_TOKEN }}" + GH_USER: sassbot + + deploy_pub: + name: Deploy Pub + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder protobuf pkg-pub-deploy + env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"} + + deploy_sub_packages: + name: Deploy Sub-Packages + runs-on: ubuntu-latest + needs: [deploy_pub] + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder deploy-sub-packages + env: + PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}" + GH_TOKEN: "${{ secrets.GH_TOKEN }}" + GH_USER: sassbot + + deploy_homebrew: + name: Deploy Homebrew + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: dart-lang/setup-dart@v1 + - run: dart pub get + + - name: Deploy + run: dart run grinder pkg-homebrew-update + env: + GH_TOKEN: "${{ secrets.GH_TOKEN }}" + GH_USER: sassbot + + deploy_chocolatey: + name: Deploy Chocolatey + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Deploy + run: dart run grinder pkg-chocolatey-deploy + env: {CHOCOLATEY_TOKEN: "${{ secrets.CHOCOLATEY_TOKEN }}"} + + deploy_website: + name: Deploy sass-lang.com + runs-on: ubuntu-latest + needs: [deploy_npm] + + steps: + - uses: actions/checkout@v4 + with: + repository: sass/sass-site + token: ${{ secrets.SASS_SITE_TOKEN }} + + - name: Get version + id: version + run: echo "version=${GITHUB_REF##*/}" | tee --append "$GITHUB_OUTPUT" + + - name: Update Dart Sass version + run: npm install sass@${{ steps.version.outputs.version }} + + - uses: EndBug/add-and-commit@v9 + with: + author_name: Sass Bot + author_email: sass.bot.beep.boop@gmail.com + message: Cut a release for a new Dart Sass version + commit: --allow-empty + + release_embedded_host: + name: Release Embedded Host + runs-on: ubuntu-latest + needs: [deploy_github] + + steps: + - uses: actions/checkout@v4 + with: + repository: sass/embedded-host-node + token: ${{ secrets.GH_TOKEN }} + + - name: Get version + id: version + run: | + echo "version=${GITHUB_REF##*/}" | tee --append "$GITHUB_OUTPUT" + echo "protocol_version=$(curl -fsSL -H "Authorization: Bearer ${{ github.token }}" https://raw.githubusercontent.com/sass/sass/HEAD/spec/EMBEDDED_PROTOCOL_VERSION)" | tee --append "$GITHUB_OUTPUT" + + - name: Update version + run: | + # 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 }} --arg protocol_version ${{ steps.version.outputs.protocol_version }} ' + .version |= $version | + ."compiler-version" |= $version | + ."protocol-version" |= $protocol_version | + .optionalDependencies = (.optionalDependencies | .[] |= $version) + ' > package.json.tmp && + mv package.json.tmp package.json + curl -fsSL -H "Authorization: Bearer ${{ github.token }}" https://raw.githubusercontent.com/sass/dart-sass/${{ steps.version.outputs.version }}/CHANGELOG.md > CHANGELOG.md + shell: bash + + - uses: EndBug/add-and-commit@v9 + with: + author_name: Sass Bot + author_email: sass.bot.beep.boop@gmail.com + message: Update Dart Sass version and release + tag: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/test-vendor.yml b/.github/workflows/test-vendor.yml new file mode 100644 index 000000000..e2d51825e --- /dev/null +++ b/.github/workflows/test-vendor.yml @@ -0,0 +1,72 @@ +name: Test Vendor + +on: + workflow_call: + workflow_dispatch: + +jobs: + bootstrap: + name: "Bootstrap ${{ matrix.bootstrap_version }}" + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + bootstrap_version: [4, 5] + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - run: dart run grinder fetch-bootstrap${{matrix.bootstrap_version}} + env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} + - name: Build + run: dart bin/sass.dart --quiet build/bootstrap/scss:build/bootstrap-output + + bourbon: + name: Bourbon + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - run: dart run grinder fetch-bourbon + env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} + - name: Test + run: | + dart bin/sass.dart --quiet -I build/bourbon -I build/bourbon/spec/fixtures \ + build/bourbon/spec/fixtures:build/bourbon-output + + foundation: + name: Foundation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - run: dart run grinder fetch-foundation + env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} + # TODO(nweiz): Foundation has proper Sass tests, but they're currently not + # compatible with Dart Sass. Once they are, we should run those rather + # than just building the CSS output. + - name: Build + run: dart bin/sass.dart --quiet build/foundation-sites/assets:build/foundation-output + + bulma: + name: Bulma + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - run: dart run grinder fetch-bulma + env: {GITHUB_BEARER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"} + - name: Build + run: dart bin/sass.dart --quiet build/bulma/bulma.sass build/bulma-output.css diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..aa31b610e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,309 @@ +name: Test + +defaults: + run: {shell: bash} + +on: + workflow_call: + workflow_dispatch: + +jobs: + format: + name: Code formatting + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - 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@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - name: Analyze Dart + run: dart analyze --fatal-warnings ./ + + dartdoc: + name: Dartdoc + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: {github-token: "${{ github.token }}"} + + - 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 + + strategy: + fail-fast: false + matrix: + dart_channel: [stable, dev] + async_label: [synchronous] + async_args: [''] + include: + - dart_channel: stable + async_label: asynchronous + async_args: '--cmd-args --async' + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + - uses: ./.github/util/sass-spec + + - name: Run specs + run: npm run sass-spec -- --dart .. $extra_args + working-directory: sass-spec + env: {extra_args: "${{ matrix.async_args }}"} + + sass_spec_js: + name: "JS API Tests | Pure JS | 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: ['lts/*'] + include: + # Test older LTS versions + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-1 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-2 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-3 + # Test LTS version with dart dev channel + - os: ubuntu-latest + dart_channel: dev + node-version: 'lts/*' + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + node-version: ${{ matrix.node-version }} + - uses: ./.github/util/sass-spec + + - name: Build JS + run: dart run grinder pkg-npm-dev + + - name: Check out Sass specification + uses: sass/clone-linked-repo@v1 + with: + repo: sass/sass + path: language + + - name: Run tests + run: npm run js-api-spec -- --sassSassRepo ../language --sassPackage ../build/npm + working-directory: sass-spec + + sass_spec_js_embedded: + name: 'JS API Tests | Embedded | Node ${{ matrix.node-version }} | ${{ matrix.os }}' + runs-on: ${{ matrix.os }} + if: "github.event_name != 'pull_request' || !contains(github.event.pull_request.body, 'skip sass-embedded')" + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: ['lts/*'] + include: + # Test older LTS versions + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-1 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-2 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-3 + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: + github-token: ${{ github.token }} + node-version: ${{ matrix.node-version }} + - uses: ./.github/util/sass-spec + + - name: Check out the embedded host + uses: sass/clone-linked-repo@v1 + with: {repo: sass/embedded-host-node} + + - name: Check out the language repo + uses: sass/clone-linked-repo@v1 + with: {repo: sass/sass, path: build/language} + + - name: Initialize embedded host + run: | + npm install + npm run init -- --compiler-path=.. --language-path=../build/language + npm run compile + mv {`pwd`/,dist/}lib/src/vendor/dart-sass + working-directory: embedded-host-node + + - 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 ../build/language + working-directory: sass-spec + + sass_spec_js_browser: + name: "JS API Tests | Browser | Dart ${{ matrix.dart_channel }}" + + strategy: + matrix: + dart_channel: [stable] + fail-fast: false + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: browser-actions/setup-chrome@v1 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + - uses: ./.github/util/sass-spec + + - name: Build JS + run: dart run grinder pkg-npm-dev + + - name: Install built dependencies + run: npm install + working-directory: build/npm + + - name: Check out Sass specification + uses: sass/clone-linked-repo@v1 + with: + repo: sass/sass + path: language + + - name: Run tests + run: npm run js-api-spec -- --sassSassRepo ../language --sassPackage ../build/npm --browser + working-directory: sass-spec + env: + CHROME_EXECUTABLE: chrome + + dart_tests: + name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }}" + runs-on: "${{ matrix.os }}" + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + dart_channel: [stable] + # TODO(nweiz): Re-enable this when + # https://github.com/dart-lang/sdk/issues/52121#issuecomment-1728534228 + # is addressed. + # include: [{os: ubuntu-latest, dart_channel: dev}] + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + + - run: dart run grinder pkg-standalone-dev + - name: Run tests + run: dart run test -x node + + # Unit tests that use Node.js, defined in test/. + node_tests: + name: "Node 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: ['lts/*'] + include: + # Test older LTS versions + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-1 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-2 + - os: ubuntu-latest + dart_channel: stable + node-version: lts/-3 + # Test LTS version with dart dev channel + - os: ubuntu-latest + dart_channel: dev + node-version: 'lts/*' + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + node-version: ${{ matrix.node-version }} + + - run: dart run grinder pkg-npm-dev + - name: Run tests + run: dart run test -t node -j 2 + + browser_tests: + name: "Browser Tests | Dart ${{ matrix.dart_channel }}" + + strategy: + matrix: + dart_channel: [stable] + fail-fast: false + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: browser-actions/setup-chrome@v1 + - uses: ./.github/util/initialize + with: + dart-sdk: ${{ matrix.dart_channel }} + github-token: ${{ github.token }} + + - run: dart run grinder pkg-npm-dev + - name: Run tests + run: dart run test -p chrome -j 2 + env: + CHROME_EXECUTABLE: chrome diff --git a/CHANGELOG.md b/CHANGELOG.md index a4995a0cb..5f520294c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ points that aren't in the US-ASCII region. Previously only code points U+0100 LATIN CAPITAL LETTER A WITH MACRON were escaped. +* Provide official releases for musl LibC and for Android. + ### JS API * Fix a bug where certain exceptions could produce `SourceSpan`s that didn't