From 74e22a01f4c7cf82e83d31b06495c7fe45e467f1 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 21 Aug 2023 12:59:04 -0700 Subject: [PATCH] Backport GitHub Actions config from feature.color-4 (#1930) --- .github/util/dart-sass/action.yml | 34 ++++++++ .github/workflows/ci.yml | 132 ++++++++++++------------------ 2 files changed, 86 insertions(+), 80 deletions(-) create mode 100644 .github/util/dart-sass/action.yml diff --git a/.github/util/dart-sass/action.yml b/.github/util/dart-sass/action.yml new file mode 100644 index 000000000..9e11c5ff3 --- /dev/null +++ b/.github/util/dart-sass/action.yml @@ -0,0 +1,34 @@ +name: Dart Sass +description: Check out Dart Sass and build the embedded protocol buffer. +inputs: + github-token: {required: true} + dart-sdk: {required: false, default: stable} + architecture: {required: false} +runs: + using: composite + steps: + - uses: dart-lang/setup-dart@v1 + with: + sdk: "${{ inputs.dart-sdk }}" + architecture: "${{ inputs.architecture }}" + + - uses: bufbuild/buf-setup-action@v1.13.1 + with: {github_token: "${{ inputs.github-token }}"} + + - uses: sass/clone-linked-repo@v1 + with: {repo: sass/dart-sass, path: dart-sass} + + - run: dart pub get + shell: bash + working-directory: dart-sass + + - name: Check out the language repo + uses: sass/clone-linked-repo@v1 + with: {repo: sass/sass, path: dart-sass/build/language} + + - name: Generate Dart from protobuf + run: dart run grinder protobuf + env: {UPDATE_SASS_PROTOCOL: false} + working-directory: dart-sass + shell: bash + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f746d14f..6121ea2ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,27 +61,14 @@ jobs: - uses: actions/setup-node@v3 with: {node-version: "${{ env.NODE_VERSION }}"} - run: npm install - - uses: dart-lang/setup-dart@v1 - with: {sdk: "${{ matrix.dart_channel }}"} - - uses: bufbuild/buf-setup-action@v1.13.1 - with: {github_token: "${{ github.token }}"} - - name: Install dart-sass - run: | - GITHUB_REF=${PR_REF:-$CURRENT_REF} - if [[ "$GITHUB_REF" == refs/heads/feature.* ]]; then branch="${GITHUB_REF:11}"; else branch=main; fi - git clone https://github.com/sass/dart-sass.git ../dart-sass --depth 1 --branch "$branch" - ( - cd ../dart-sass - dart pub get - dart run grinder protobuf - ) - env: - PR_REF: "${{ github.base_ref }}" - CURRENT_REF: "${{ github.ref }}" + - uses: ./.github/util/dart-sass + with: + github-token: ${{ github.token }} + dart-sdk: ${{ matrix.dart_channel }} - name: Run specs - run: npm run sass-spec -- --dart ../dart-sass + run: npm run sass-spec -- --dart dart-sass libsass: name: "Language | LibSass" @@ -94,7 +81,7 @@ jobs: with: {node-version: "${{ env.NODE_VERSION }}"} - run: npm install - - name: Install sassc + - name: Install SassC run: | export SASS_LIBSASS_PATH=$BUILD_DIR/../libsass export SASS_SASSC_PATH=$BUILD_DIR/../sassc @@ -134,30 +121,20 @@ jobs: - uses: actions/setup-node@v3 with: {node-version: "${{ matrix.node_version }}"} - run: npm install - - uses: dart-lang/setup-dart@v1 - with: {sdk: stable} - - uses: bufbuild/buf-setup-action@v1.13.1 - with: {github_token: "${{ github.token }}"} - - name: Install Dart Sass - run: | - git clone https://github.com/sass/dart-sass.git ../dart-sass --depth 1 - ( - cd ../dart-sass - dart pub get - dart pub run grinder protobuf pkg-npm-dev - cd build/npm - npm install - ) - - - name: Check out Sass specification - uses: sass/clone-linked-repo@v1 + - uses: ./.github/util/dart-sass with: - repo: sass/sass - path: language + github-token: ${{ github.token }} + + - name: Dart Sass | Build + run: dart run grinder pkg-npm-dev + working-directory: dart-sass - name: Run specs - run: npm run js-api-spec -- --sassPackage ../dart-sass/build/npm --sassSassRepo language + run: | + npm run js-api-spec -- \ + --sassPackage dart-sass/build/npm \ + --sassSassRepo dart-sass/build/language js_api_dart_sass_browser: name: "JS API | Pure JS | Browser" @@ -168,32 +145,22 @@ jobs: - uses: actions/checkout@v3 - uses: browser-actions/setup-chrome@v1 - run: npm install - - uses: dart-lang/setup-dart@v1 - with: {sdk: stable} - - uses: bufbuild/buf-setup-action@v1.13.1 - with: {github_token: "${{ github.token }}"} - - name: Install Dart Sass - run: | - git clone https://github.com/sass/dart-sass.git ../dart-sass --depth 1 - ( - cd ../dart-sass - dart pub get - dart pub run grinder protobuf pkg-npm-dev - cd build/npm - npm install - ) - - - name: Check out Sass specification - uses: sass/clone-linked-repo@v1 + - uses: ./.github/util/dart-sass with: - repo: sass/sass - path: language + github-token: ${{ github.token }} + + - name: Dart Sass | Build + run: dart run grinder pkg-npm-dev + working-directory: dart-sass - name: Run specs - run: npm run js-api-spec -- --sassPackage ../dart-sass/build/npm --sassSassRepo language --browser - env: - CHROME_EXECUTABLE: chrome + run: | + npm run js-api-spec -- \ + --browser \ + --sassPackage dart-sass/build/npm \ + --sassSassRepo dart-sass/build/language + env: {CHROME_EXECUTABLE: chrome} # The versions should be kept up-to-date with the latest LTS Node releases. # They next need to be rotated October 2021. See @@ -201,7 +168,7 @@ jobs: js_api_sass_embedded: name: "JS API | 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')" + if: github.event_name != 'pull_request' || !contains(github.event.pull_request.body, 'skip sass-embedded') strategy: fail-fast: false @@ -220,25 +187,30 @@ jobs: - uses: actions/setup-node@v3 with: {node-version: "${{ matrix.node_version }}"} - run: npm install - - uses: dart-lang/setup-dart@v1 - with: {sdk: stable} - - name: Install sass-embedded - run: | - git clone https://github.com/sass/embedded-host-node.git \ - ../embedded-host-node --depth 1 - ( - cd ../embedded-host-node - npm install - npm run init - npm run compile - ) - - - name: Check out Sass specification - uses: sass/clone-linked-repo@v1 + - uses: ./.github/util/dart-sass with: - repo: sass/sass - path: language + github-token: ${{ github.token }} + + - name: Node.js Embedded Host | Checkout + uses: sass/clone-linked-repo@v1 + with: {repo: sass/embedded-host-node, path: embedded-host-node} + + # Work around actions/checkout#197. We need this outside the main checkout + # because otherwise its `node_modules` conflict with sass-spec's. + - run: mv embedded-host-node .. + + - name: Node.js Embedded Host | Install + run: | + npm install + npm run init -- \ + --compiler-path=../sass-spec/dart-sass \ + --language-path=../sass-spec/dart-sass/build/language + npm run compile + working-directory: ../embedded-host-node - name: Run specs - run: npm run js-api-spec -- --sassPackage ../embedded-host-node --sassSassRepo language + run: | + npm run js-api-spec -- \ + --sassPackage ../embedded-host-node \ + --sassSassRepo dart-sass/build/language