diff --git a/lib/manager/bazel/__fixtures__/WORKSPACE2 b/lib/manager/bazel/__fixtures__/WORKSPACE2 new file mode 100644 index 0000000000000000000000000000000000000000..0f81fff57c1b9c59effb534c7bd74d41411edc21 --- /dev/null +++ b/lib/manager/bazel/__fixtures__/WORKSPACE2 @@ -0,0 +1,17 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "GBDeviceInfo", + url = "https://github.com/lmirosevic/GBDeviceInfo/archive/6.3.0.tar.gz", + sha256 = "d7666275dff039407ea467c3083b83e24934101777c8b55b6b1b3b7e9a9e220b", + strip_prefix = "GBDeviceInfo-6.3.0/GBDeviceInfo" +) + +http_archive( + name = "com_github_nelhage_rules_boost", + url = "https://github.com/nelhage/rules_boost/archive/135d46b4c9423ee7d494c78a21ff621bc73c12f3.tar.gz", + sha256 = "3651f5dda0f7296e4cecafacc7f9d1f274be0fd64e30bebd74e28ffba28fe77f", + strip_prefix = "rules_boost-135d46b4c9423ee7d494c78a21ff621bc73c12f3", +) +load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") +boost_deps() diff --git a/lib/manager/bazel/__snapshots__/extract.spec.ts.snap b/lib/manager/bazel/__snapshots__/extract.spec.ts.snap index 900851a2bd29b3257b9feb93cb6e2036e98393a7..a8aec10c27df5f11cdf0459c08c8ce52922c9441 100644 --- a/lib/manager/bazel/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/bazel/__snapshots__/extract.spec.ts.snap @@ -31,7 +31,7 @@ exports[`lib/manager/bazel/extract extractPackageFile() extracts dependencies fr Array [ Object { "currentDigest": "0356bef3fbbabec5f0e196ecfacdeb6db62d48c0", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "subpar", "depType": "http_archive", "lookupName": "google/subpar", @@ -48,7 +48,7 @@ Array [ }, Object { "currentValue": "0.6.0", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "bazel_skylib", "depType": "http_archive", "lookupName": "bazelbuild/bazel-skylib", @@ -65,6 +65,43 @@ Array [ ] `; +exports[`lib/manager/bazel/extract extractPackageFile() extracts github tags 1`] = ` +Array [ + Object { + "currentValue": "6.3.0", + "datasource": "github-tags", + "depName": "GBDeviceInfo", + "depType": "http_archive", + "lookupName": "lmirosevic/GBDeviceInfo", + "managerData": Object { + "def": "http_archive( + name = \\"GBDeviceInfo\\", + url = \\"https://github.com/lmirosevic/GBDeviceInfo/archive/6.3.0.tar.gz\\", + sha256 = \\"d7666275dff039407ea467c3083b83e24934101777c8b55b6b1b3b7e9a9e220b\\", + strip_prefix = \\"GBDeviceInfo-6.3.0/GBDeviceInfo\\" +)", + }, + "repo": "lmirosevic/GBDeviceInfo", + }, + Object { + "currentDigest": "135d46b4c9423ee7d494c78a21ff621bc73c12f3", + "datasource": "github-tags", + "depName": "com_github_nelhage_rules_boost", + "depType": "http_archive", + "lookupName": "nelhage/rules_boost", + "managerData": Object { + "def": "http_archive( + name = \\"com_github_nelhage_rules_boost\\", + url = \\"https://github.com/nelhage/rules_boost/archive/135d46b4c9423ee7d494c78a21ff621bc73c12f3.tar.gz\\", + sha256 = \\"3651f5dda0f7296e4cecafacc7f9d1f274be0fd64e30bebd74e28ffba28fe77f\\", + strip_prefix = \\"rules_boost-135d46b4c9423ee7d494c78a21ff621bc73c12f3\\", +)", + }, + "repo": "nelhage/rules_boost", + }, +] +`; + exports[`lib/manager/bazel/extract extractPackageFile() extracts multiple types of dependencies 1`] = ` Array [ Object { @@ -90,7 +127,7 @@ Array [ }, Object { "currentDigest": "446923c3756ceeaa75888f52fcbdd48bb314fbf8", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "distroless", "depType": "http_archive", "lookupName": "GoogleContainerTools/distroless", @@ -106,7 +143,7 @@ Array [ }, Object { "currentDigest": "d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "bazel_toolchains", "depType": "http_archive", "lookupName": "bazelbuild/bazel-toolchains", @@ -140,7 +177,7 @@ Array [ }, Object { "currentValue": "0.5.0", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "bazel_skylib", "depType": "http_archive", "lookupName": "bazelbuild/bazel-skylib", @@ -159,7 +196,7 @@ Array [ }, Object { "currentDigest": "446923c3756ceeaa75888f52fcbdd48bb314fbf8", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "distroless", "depType": "http_archive", "lookupName": "GoogleContainerTools/distroless", @@ -175,7 +212,7 @@ Array [ }, Object { "currentDigest": "446923c3756ceeaa75888f52fcbdd48bb314fbf8", - "datasource": "github-releases", + "datasource": "github-tags", "depName": "distroless", "depType": "http_file", "lookupName": "GoogleContainerTools/distroless", diff --git a/lib/manager/bazel/extract.spec.ts b/lib/manager/bazel/extract.spec.ts index 472ee6834049587338a322c6fc170d93567995ed..4df84266ebb3358b43308d86ccc45b8f03496f35 100644 --- a/lib/manager/bazel/extract.spec.ts +++ b/lib/manager/bazel/extract.spec.ts @@ -6,6 +6,11 @@ const workspaceFile = readFileSync( 'utf8' ); +const workspace2File = readFileSync( + 'lib/manager/bazel/__fixtures__/WORKSPACE2', + 'utf8' +); + const fileWithBzlExtension = readFileSync( 'lib/manager/bazel/__fixtures__/repositories.bzl', 'utf8' @@ -25,6 +30,10 @@ describe('lib/manager/bazel/extract', () => { const res = extractPackageFile(workspaceFile); expect(res.deps).toMatchSnapshot(); }); + it('extracts github tags', () => { + const res = extractPackageFile(workspace2File); + expect(res.deps).toMatchSnapshot(); + }); it('extracts dependencies from *.bzl files', () => { const res = extractPackageFile(fileWithBzlExtension); expect(res.deps).toMatchSnapshot(); diff --git a/lib/manager/bazel/extract.ts b/lib/manager/bazel/extract.ts index 515ee6b2e894c2273525bc8cdf2e5ded09f2f372..7812a391b40807f0bd781673816be8410ce9e105 100644 --- a/lib/manager/bazel/extract.ts +++ b/lib/manager/bazel/extract.ts @@ -3,6 +3,7 @@ import { parse as _parse } from 'url'; import parse from 'github-url-from-git'; import * as datasourceDocker from '../../datasource/docker'; import * as datasourceGithubReleases from '../../datasource/github-releases'; +import * as datasourceGithubTags from '../../datasource/github-tags'; import * as datasourceGo from '../../datasource/go'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; @@ -11,6 +12,7 @@ import * as dockerVersioning from '../../versioning/docker'; import { PackageDependency, PackageFile } from '../common'; interface UrlParsedResult { + datasource: string; repo: string; currentValue: string; } @@ -26,15 +28,18 @@ function parseUrl(urlString: string): UrlParsedResult | null { } const path = url.path.split('/').slice(1); const repo = path[0] + '/' + path[1]; + let datasource: string; let currentValue: string = null; if (path[2] === 'releases' && path[3] === 'download') { + datasource = datasourceGithubReleases.id; currentValue = path[4]; } if (path[2] === 'archive') { + datasource = datasourceGithubTags.id; currentValue = path[3].replace(/\.tar\.gz$/, ''); } if (currentValue) { - return { repo, currentValue }; + return { datasource, repo, currentValue }; } // istanbul ignore next return null; @@ -232,7 +237,7 @@ export function extractPackageFile( } else { dep.currentValue = parsedUrl.currentValue; } - dep.datasource = datasourceGithubReleases.id; + dep.datasource = parsedUrl.datasource; dep.lookupName = dep.repo; deps.push(dep); } else if (