Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ go_test(
embed = [":go_default_library"],
importpath = "github.com/bazelbuild/bazelisk",
deps = [
"//config:go_default_library",
"//core:go_default_library",
"//httputil:go_default_library",
"//repositories:go_default_library",
Expand Down Expand Up @@ -154,14 +155,14 @@ go_binary(
pkg_npm(
name = "npm_package",
package_name = "@bazel/bazelisk",
substitutions = {"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}"},
srcs = [
"LICENSE",
"README.md",
"bazelisk.d.ts",
"bazelisk.js",
"package.json",
],
substitutions = {"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}"},
deps = [
":bazelisk-darwin-amd64",
":bazelisk-darwin-arm64",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The following variables can be set:
- `BAZELISK_GITHUB_TOKEN`
- `BAZELISK_HOME`
- `BAZELISK_INCOMPATIBLE_FLAGS`
- `BAZELISK_SHOW_PROGRESS`
- `BAZELISK_SHUTDOWN`
- `BAZELISK_SKIP_WRAPPER`
- `BAZELISK_USER_AGENT`
Expand Down
14 changes: 14 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ go_repository(
version = "v0.0.0-20140422174119-9fd32a8b3d3d",
)

go_repository(
name = "org_golang_x_term",
importpath = "golang.org/x/term",
sum = "h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=",
version = "v0.13.0",
)

go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=",
version = "v0.13.0",
)

go_rules_dependencies()

go_register_toolchains(version = "1.19.4")
Expand Down
25 changes: 13 additions & 12 deletions bazelisk_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"testing"

"github.com/bazelbuild/bazelisk/config"
"github.com/bazelbuild/bazelisk/core"
"github.com/bazelbuild/bazelisk/httputil"
"github.com/bazelbuild/bazelisk/repositories"
Expand Down Expand Up @@ -42,7 +43,7 @@ func TestResolveVersion(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(nil, gcs, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.0.0")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.0.0", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -60,7 +61,7 @@ func TestResolvePatchVersion(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(nil, gcs, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.0.0-patch1")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.0.0-patch1", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -82,7 +83,7 @@ func TestResolveLatestRcVersion(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(nil, gcs, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "last_rc")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "last_rc", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -100,7 +101,7 @@ func TestResolveLatestRcVersion_WithFullRelease(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(nil, gcs, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "last_rc")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "last_rc", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -120,7 +121,7 @@ func TestResolveLatestVersion_TwoLatestVersionsDoNotHaveAReleaseYet(t *testing.T

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(gcs, nil, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -142,7 +143,7 @@ func TestResolveLatestVersion_ShouldOnlyReturnStableReleases(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(gcs, nil, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest-1")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest-1", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand All @@ -161,7 +162,7 @@ func TestResolveLatestVersion_ShouldFailIfNotEnoughReleases(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(gcs, nil, nil, nil, nil, false)
_, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest-1")
_, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest-1", config.Null())

if err == nil {
t.Fatal("Expected ResolveVersion() to fail.")
Expand All @@ -178,7 +179,7 @@ func TestResolveLatestVersion_GCSIsDown(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(gcs, nil, nil, nil, nil, false)
_, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest")
_, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "latest", config.Null())

if err == nil {
t.Fatal("Expected resolveLatestVersion() to fail.")
Expand All @@ -196,7 +197,7 @@ func TestResolveLatestVersion_GitHubIsDown(t *testing.T) {
gh := repositories.CreateGitHubRepo("test_token")
repos := core.CreateRepositories(nil, nil, gh, nil, nil, false)

_, _, err := repos.ResolveVersion(tmpDir, "some_fork", "latest")
_, _, err := repos.ResolveVersion(tmpDir, "some_fork", "latest", config.Null())

if err == nil {
t.Fatal("Expected resolveLatestVersion() to fail.")
Expand All @@ -212,7 +213,7 @@ func TestAcceptRollingReleaseName(t *testing.T) {
repos := core.CreateRepositories(nil, nil, nil, nil, gcs, false)

for _, version := range []string{"10.0.0-pre.20201103.4", "10.0.0-pre.20201103.4.2"} {
resolvedVersion, _, err := repos.ResolveVersion(tmpDir, "", version)
resolvedVersion, _, err := repos.ResolveVersion(tmpDir, "", version, config.Null())

if err != nil {
t.Fatalf("ResolveVersion(%q, \"\", %q): expected no error, but got %v", tmpDir, version, err)
Expand All @@ -233,7 +234,7 @@ func TestResolveLatestRollingRelease(t *testing.T) {
gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(nil, nil, nil, nil, gcs, false)

version, _, err := repos.ResolveVersion(tmpDir, "", rollingReleaseIdentifier)
version, _, err := repos.ResolveVersion(tmpDir, "", rollingReleaseIdentifier, config.Null())

if err != nil {
t.Fatalf("ResolveVersion(%q, \"\", %q): expected no error, but got %v", tmpDir, rollingReleaseIdentifier, err)
Expand All @@ -257,7 +258,7 @@ func TestAcceptFloatingReleaseVersions(t *testing.T) {

gcs := &repositories.GCSRepo{}
repos := core.CreateRepositories(gcs, nil, nil, nil, nil, false)
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.x")
version, _, err := repos.ResolveVersion(tmpDir, versions.BazelUpstream, "4.x", config.Null())

if err != nil {
t.Fatalf("Version resolution failed unexpectedly: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func downloadBazel(bazelVersionString string, bazeliskHome string, repos *Reposi
return "", fmt.Errorf("could not parse Bazel fork and version: %v", err)
}

resolvedBazelVersion, downloader, err := repos.ResolveVersion(bazeliskHome, bazelFork, bazelVersion)
resolvedBazelVersion, downloader, err := repos.ResolveVersion(bazeliskHome, bazelFork, bazelVersion, config)
if err != nil {
return "", fmt.Errorf("could not resolve the version '%s' to an actual version number: %v", bazelVersion, err)
}
Expand Down Expand Up @@ -415,7 +415,7 @@ func downloadBazelToCAS(version string, bazeliskHome string, repos *Repositories
} else if formatURL != "" {
tmpDestPath, err = repos.DownloadFromFormatURL(config, formatURL, version, temporaryDownloadDir, tmpDestFile)
} else if baseURL != "" {
tmpDestPath, err = repos.DownloadFromBaseURL(baseURL, version, temporaryDownloadDir, tmpDestFile)
tmpDestPath, err = repos.DownloadFromBaseURL(baseURL, version, temporaryDownloadDir, tmpDestFile, config)
} else {
tmpDestPath, err = downloader(temporaryDownloadDir, tmpDestFile)
}
Expand Down
Loading