Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to build npm with a linked language repo #2214

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/util/initialize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ runs:

- name: Generate Dart from protobuf
run: dart run grinder protobuf
env: {UPDATE_SASS_PROTOCOL: false}
env: {UPDATE_SASS_SASS_REPO: false}
shell: bash
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- name: Deploy
run: dart run grinder pkg-npm-deploy
env:
UPDATE_SASS_SASS_REPO: false
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"

deploy_bazel:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:

- name: Build JS
run: dart run grinder pkg-npm-dev
env: {UPDATE_SASS_SASS_REPO: false}

- name: Check out Sass specification
uses: sass/clone-linked-repo@v1
Expand Down Expand Up @@ -203,6 +204,7 @@ jobs:

- name: Build JS
run: dart run grinder pkg-npm-dev
env: {UPDATE_SASS_SASS_REPO: false}

- name: Install built dependencies
run: npm install
Expand Down Expand Up @@ -282,6 +284,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- run: dart run grinder pkg-npm-dev
env: {UPDATE_SASS_SASS_REPO: false}
- name: Run tests
run: dart run test -t node -j 2

Expand All @@ -303,6 +306,7 @@ jobs:
github-token: ${{ github.token }}

- run: dart run grinder pkg-npm-dev
env: {UPDATE_SASS_SASS_REPO: false}
- name: Run tests
run: dart run test -p chrome -j 2
env:
Expand Down
24 changes: 18 additions & 6 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ String _readAndResolveMarkdown(String path) => File(path)

/// Returns a map from JS type declaration file names to their contnets.
Map<String, String> _fetchJSTypes() {
var languageRepo =
cloneOrCheckout("https://github.com/sass/sass", "main", name: 'language');
var languageRepo = _updateLanguageRepo();;
nex3 marked this conversation as resolved.
Show resolved Hide resolved

var typeRoot = p.join(languageRepo, 'js-api-doc');
return {
Expand Down Expand Up @@ -251,10 +250,7 @@ dart run protoc_plugin "\$@"
run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']);
}

if (Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false') {
cloneOrCheckout("https://github.com/sass/sass.git", "main",
name: 'language');
}
_updateLanguageRepo();
nex3 marked this conversation as resolved.
Show resolved Hide resolved

await runAsync("buf",
arguments: ["generate"],
Expand Down Expand Up @@ -325,3 +321,19 @@ String _updateHomebrewLanguageRevision(String formula) {
match.group(0)!.replaceFirst(match.group(1)!, languageRepoRevision) +
formula.substring(match.end);
}

/// Clones the main branch of `github.com/sass/sass` and returns the path to the
/// clone.
///
/// If the `UPDATE_SASS_SASS_REPO` environment variable is `false`, this instead
/// assumes the repo that already exists at `build/language/sass`.
/// `UPDATE_SASS_PROTOCOL` is also checked as a deprecated alias for
/// `UPDATE_SASS_SASS_REPO`.
String _updateLanguageRepo() =>
// UPDATE_SASS_PROTOCOL is considered deprecated, because it doesn't apply as
// generically to other tasks.
Platform.environment['UPDATE_SASS_SASS_REPO'] != 'false' &&
Platform.environment['UPDATE_SASS_PROTOCOL'] != 'false'
? cloneOrCheckout("https://github.com/sass/sass.git", "main",
name: 'language')
: 'build/language/sass';