Skip to content

Commit

Permalink
Add a test reproducing #13 (#14)
Browse files Browse the repository at this point in the history
Hopefully a useful first step in making a fix
  • Loading branch information
alexeagle committed Mar 8, 2024
1 parent 98c6937 commit f422ff6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ jobs:
]
# this ruleset only supports linux and macos
exclude_windows: true
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- working-directory: examples/target-determinator
run: ./minimal_download_test.sh
36 changes: 36 additions & 0 deletions examples/target-determinator/minimal_download_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -o errexit -o pipefail -o nounset

# Determine a single file we are supposed to download for the host platform
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(arch)"
ALLOWED="target-determinator.${OS}.${ARCH}"
if [ "$ARCH" == "x86_64" ]; then
ALLOWED="target-determinator.${OS}.amd64"
fi

#############
# Test bzlmod
OUTPUT_BASE=$(mktemp -d)
REPO_CACHE=$(mktemp -d)
DL_CONFIG=$(mktemp)

# Construct a Bazel downloader config that forbids access to non-allowed files from multitool.lock.json
for file in target-determinator.darwin.arm64 target-determinator.linux.amd64 target-determinator.darwin.amd64; do
if [ "$file" != "$ALLOWED" ]; then
cat >$DL_CONFIG <<EOF
rewrite github.com/bazel-contrib/target-determinator/releases/download/([^/]+)/$file disallowed.build/\$1/$file
EOF
fi
done

# This build will fail if we attempt a disallowed download
bazel "--output_base=$OUTPUT_BASE" build \
--enable_bzlmod \
"--repository_cache=$REPO_CACHE" \
"--experimental_downloader_config=$DL_CONFIG" \
//:integration_test

#############
# TODO: Test WORKSPACE

0 comments on commit f422ff6

Please sign in to comment.