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
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
run -c opt --show_loading_progress=false --show_progress=false --ui_event_filters='ERROR'
run:verbose -c dbg --show_loading_progress=true --show_progress=true --ui_event_filters='INFO,ERROR,DEBUG'
# https://github.com/mockito/mockito/issues/1879
test --sandbox_tmpfs_path=/tmp
36 changes: 0 additions & 36 deletions .github/workflows/cd.yaml

This file was deleted.

80 changes: 76 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,78 @@ on:
branches: [ master ]

jobs:
Tests:
test-jre8:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
id: java
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: ^1.17
id: go
- name: Setup Bazelisk
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
- uses: actions/checkout@v2
- name: Run bazel-diff tests
run: USE_BAZEL_VERSION=latest ~/go/bin/bazelisk test //cli/...
- name: archive testlogs
if: always()
run: cp -R $(~/go/bin/bazelisk info bazel-testlogs) ./test-logs; (cd test-logs; zip -r -X ../test-logs.zip .)
- name: Save test logs
uses: actions/upload-artifact@master
if: always()
with:
name: test-logs-jre8
path: test-logs.zip
test-jre11:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: ^1.17
id: go
- name: Setup Bazelisk
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
- uses: actions/checkout@v2
- name: Run bazel-diff tests
run: USE_BAZEL_VERSION=latest ~/go/bin/bazelisk coverage --combined_report=lcov //cli/...
- name: archive testlogs
if: always()
run: cp -R $(~/go/bin/bazelisk info bazel-testlogs) ./test-logs; (cd test-logs; zip -r -X ../test-logs.zip .)
- name: Save test logs
uses: actions/upload-artifact@master
if: always()
with:
name: test-logs-jre11
path: test-logs.zip
- name: Generate code coverage
run: |
sudo apt-get install -y lcov
genhtml $(~/go/bin/bazelisk info output_path)/_coverage/_coverage_report.dat -o coverage/html
(cd coverage/html; zip -r -X ../../coverage-jre11.zip .)
- name: Save code coverage
uses: actions/upload-artifact@master
if: always()
with:
name: coverage-jre11-jre11
path: coverage-jre11.zip
deploy:
needs: [test-jre8, test-jre11]
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11' ]
java: [ '8' ]
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3
Expand All @@ -27,5 +94,10 @@ jobs:
- name: Setup Bazelisk
run: go install github.com/bazelbuild/bazelisk@latest && export PATH=$PATH:$(go env GOPATH)/bin
- uses: actions/checkout@v2
- name: Run bazel-diff tests
run: USE_BAZEL_VERSION=last_downstream_green ~/go/bin/bazelisk test //test/...
- name: Build deployable JAR
run: USE_BAZEL_VERSION=latest ~/go/bin/bazelisk build //cli:bazel-diff_deploy.jar
- uses: actions/upload-artifact@v3
with:
name: bazel-diff_deploy.jar
path: bazel-bin/cli/bazel-diff_deploy.jar
if-no-files-found: error
25 changes: 0 additions & 25 deletions .github/workflows/integration.yaml

This file was deleted.

13 changes: 9 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
alias(
name = "bazel-diff",
actual = "//src/main/java/com/bazel_diff:bazel-diff"
)
#alias(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to delete, I do not use these aliases

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will create another PR tomorrow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# name = "bazel-diff",
# actual = "//bazel-diff",
#)
#
#alias(
# name = "tests",
# actual = "//bazel-diff:tests",
#)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ load("@rules_java//java:defs.bzl", "java_binary")

java_binary(
name = "bazel-diff",
main_class = "com.bazel_diff.BazelDiff",
main_class = "com.bazel_diff.cli.BazelDiff",
runtime_deps = ["@bazel_diff//jar"],
)
```
Expand Down
15 changes: 12 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ bazel_diff_dependencies()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@rules_jvm_external//:defs.bzl", "maven_install")
load("//:artifacts.bzl", "BAZEL_DIFF_MAVEN_ARTIFACTS")
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")

kotlin_repositories()

load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")

kt_register_toolchains()

maven_install(
name = "bazel_diff_maven",
artifacts = BAZEL_DIFF_MAVEN_ARTIFACTS,
fetch_sources = True,
generate_compat_repositories = True,
repositories = [
"http://uk.maven.org/maven2",
"https://jcenter.bintray.com/",
]
"https://repo1.maven.org/maven2/",
],
)
8 changes: 6 additions & 2 deletions artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
load("@rules_jvm_external//:specs.bzl", "maven")

BAZEL_DIFF_MAVEN_ARTIFACTS = [
maven.artifact("junit", "junit", "4.13", testonly = True),
maven.artifact("org.mockito", "mockito-core", "3.5.15", testonly = True),
maven.artifact("junit", "junit", "4.13"),
maven.artifact("org.mockito.kotlin", "mockito-kotlin", "4.0.0", testonly = True),
maven.artifact("com.willowtreeapps.assertk", "assertk-jvm", "0.25", testonly = True),
maven.artifact("io.insert-koin", "koin-test-junit4", "3.1.6", testonly = True),
"info.picocli:picocli:jar:4.3.2",
"com.google.code.gson:gson:jar:2.8.6",
"com.google.guava:guava:29.0-jre",
"org.apache.commons:commons-pool2:2.11.1",
Comment on lines 10 to 13

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go through these and upgrade them as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will raise another PR then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"io.insert-koin:koin-core-jvm:3.1.6",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2",
]
2 changes: 1 addition & 1 deletion bazel-diff-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "Generating Hashes for Revision '$final_revision'"
$bazel_diff generate-hashes -w $workspace_path -b $bazel_path $final_hashes_json

echo "Determining Impacted Targets"
$bazel_diff -sh $starting_hashes_json -fh $final_hashes_json -w $workspace_path -b $bazel_path -o $impacted_targets_path
$bazel_diff get-impacted-targets -sh $starting_hashes_json -fh $final_hashes_json -o $impacted_targets_path

IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path
formatted_impacted_targets=$(IFS=$'\n'; echo "${impacted_targets[*]}")
Expand Down
105 changes: 105 additions & 0 deletions cli/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
load("@rules_java//java:defs.bzl", "java_binary", "java_library", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary", "kt_jvm_library", "kt_jvm_test")
load("@rules_jvm_external//:defs.bzl", "artifact")

config_setting(
name = "enable_debug",
values = {
"compilation_mode": "dbg",
},
)

java_binary(
name = "bazel-diff",
jvm_flags = select({
":enable_debug": ["-DDEBUG=true"],
"//conditions:default": [],
}),
main_class = "com.bazel_diff.Main",
visibility = ["//visibility:public"],
runtime_deps = [":cli-lib"],
)

kt_jvm_library(
name = "cli-lib",
srcs = glob(["src/main/kotlin/**/*.kt"]),
deps = [
":build_java_proto",
"@bazel_diff_maven//:com_google_code_gson_gson",
"@bazel_diff_maven//:com_google_guava_guava",
"@bazel_diff_maven//:info_picocli_picocli",
"@bazel_diff_maven//:io_insert_koin_koin_core_jvm",
"@bazel_diff_maven//:org_apache_commons_commons_pool2",
"@bazel_diff_maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm",
"@com_google_protobuf//:protobuf_java",
],
)

java_proto_library(
name = "build_java_proto",
deps = [":build_proto"],
)

proto_library(
name = "build_proto",
srcs = [":build_proto_gen"],
)

genrule(
name = "build_proto_gen",
srcs = ["@bazel_tools//src/main/protobuf:build.proto"],
outs = ["build.proto"],
cmd = "cp $< $@",
)

kt_jvm_test(
name = "BuildGraphHasherTest",
test_class = "com.bazel_diff.hash.BuildGraphHasherTest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_test(
name = "CalculateImpactedTargetsInteractorTest",
test_class = "com.bazel_diff.interactor.CalculateImpactedTargetsInteractorTest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_test(
name = "NormalisingPathConverterTest",
test_class = "com.bazel_diff.cli.converter.NormalisingPathConverterTest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_test(
name = "OptionsConverterTest",
test_class = "com.bazel_diff.cli.converter.OptionsConverterTest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_test(
name = "DeserialiseHashesInteractorTest",
test_class = "com.bazel_diff.interactor.DeserialiseHashesInteractorTest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_test(
name = "E2ETest",
test_class = "com.bazel_diff.e2e.E2ETest",
runtime_deps = [":cli-test-lib"],
)

kt_jvm_library(
name = "cli-test-lib",
testonly = True,
srcs = glob(["src/test/kotlin/**/*.kt"]),
resources = glob(["src/test/resources/**/*"]),
deps = [
":cli-lib",
"@bazel_diff_maven//:com_willowtreeapps_assertk_assertk_jvm",
"@bazel_diff_maven//:io_insert_koin_koin_test_junit4",
"@bazel_diff_maven//:io_insert_koin_koin_test_jvm",
"@bazel_diff_maven//:junit_junit",
"@bazel_diff_maven//:org_mockito_kotlin_mockito_kotlin",
],
)
15 changes: 15 additions & 0 deletions cli/src/main/kotlin/com/bazel_diff/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.bazel_diff

import com.bazel_diff.cli.BazelDiff
import picocli.CommandLine
import kotlin.system.exitProcess

class Main {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val exitCode = CommandLine(BazelDiff()).execute(*args)
exitProcess(exitCode)
}
}
}
Loading