Skip to content

Commit

Permalink
fix: support --experimental_allow_unresolved_symlinks flag (aspect-bu…
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored Nov 1, 2022
1 parent 669af9f commit 1eb401b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
4 changes: 0 additions & 4 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,3 @@ build:openbsd --nolegacy_external_runfiles
# on the host.
# See https://github.com/angular/angular/issues/27514.
build --incompatible_strict_action_env

# Not yet supported with rules_ts
# See https://github.com/aspect-build/rules_ts/pull/202
build --noexperimental_allow_unresolved_symlinks
24 changes: 16 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,11 @@ jobs:
# Don't test bzlmod with Bazel 5 (not supported)
- bazelversion: 5.3.2
folder: e2e/bzlmod
# TODO: RBE requires --experimental_allow_unresolved_symlinks which is blocked on
# https://github.com/aspect-build/rules_ts/pull/202
- config: rbe
# TODO: fix worker_workspace with Bazel 6
- bazelversion: 6.0.0rc1
folder: e2e/worker_workspace
# TODO: e2e/worker needs a bit of to be configured for RBE
- config: rbe
folder: e2e/worker
- config: rbe
folder: e2e/worker_workspace

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down Expand Up @@ -146,4 +139,19 @@ jobs:
working-directory: ${{ matrix.folder }}
# hashFiles returns an empty string if test.sh is absent
if: ${{ hashFiles(format('{0}/test.sh', matrix.folder)) != '' }}
run: ./test.sh
run: |
cp -f $GITHUB_WORKSPACE/.github/workflows/ci.bazelrc .bazelrc.test
echo "build --config=${{ matrix.config }}" >> .bazelrc.test
echo "build --disk_cache=" >> .bazelrc.test
./test.sh
- name: run ./test.sh with --noexperimental_allow_unresolved_symlinks
working-directory: ${{ matrix.folder }}
# hashFiles returns an empty string if test.sh is absent
if: ${{ hashFiles(format('{0}/test.sh', matrix.folder)) != '' }}
run: |
cp -f $GITHUB_WORKSPACE/.github/workflows/ci.bazelrc .bazelrc.test
echo "build --config=${{ matrix.config }}" >> .bazelrc.test
echo "build --disk_cache=" >> .bazelrc.test
echo "build --noexperimental_allow_unresolved_symlinks" >> ".bazelrc.test"
./test.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bazel-*
.bazelrc.user
.bazelrc.test
node_modules/
3 changes: 3 additions & 0 deletions e2e/worker/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# import common bazelrc shared with e2e workspaces
import %workspace%/../../.bazelrc.common

# used by test.sh to invoke bazel with different configurations
try-import %workspace%/.bazelrc.test

build:verbose --define=VERBOSE_LOGS=1
2 changes: 1 addition & 1 deletion e2e/worker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ for dep in "${deps[@]}"; do
buildozer "remove deps //:node_modules/$dep" :ts
message="error TS2307: Cannot find module '$dep' or its corresponding type declarations."
bazel build :ts 2>&1 | grep "$message" || exit_with_message "Case 11: expected worker to report \"$message\""
buildozer "add deps //:node_modules/$dep"
buildozer "add deps //:node_modules/$dep" :ts
done


Expand Down
5 changes: 5 additions & 0 deletions e2e/worker_workspace/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# import common bazelrc shared with e2e workspaces
import %workspace%/../../.bazelrc.common

# used by test.sh to invoke bazel with different configurations
try-import %workspace%/.bazelrc.test
18 changes: 15 additions & 3 deletions ts/private/ts_project_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,22 @@ function createFilesystemTree(root, inputs) {
}
notifyWatchers(dirs, parts.base, TYPE.SYMLINK, EVENT_TYPE.ADDED);
} else if (parts.base) {
node[parts.base] = {
[Type]: TYPE.FILE
const new_node = {
[Type]: TYPE.FILE,
}
notifyWatchers(dirs, parts.base, TYPE.FILE, EVENT_TYPE.ADDED);
try {
const linkPath = path.join(root, p)
const readlink = fs.readlinkSync(linkPath);
const targetPath = path.isAbsolute(readlink) ? readlink : path.join(path.dirname(linkPath), readlink)
const relative = path.relative(root, targetPath);
if (relative != p) {
new_node[Type] = TYPE.SYMLINK
new_node[Symlink] = relative
}
} catch (e) { /* Can't determine if it's a symlink. move on */ }

node[parts.base] = new_node;
notifyWatchers(dirs, parts.base, new_node[Type], EVENT_TYPE.ADDED);
}
}

Expand Down

0 comments on commit 1eb401b

Please sign in to comment.