Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mnaranjo/pitest #1

Merged
merged 15 commits into from
Mar 12, 2024
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
8 changes: 8 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ common --enable_bzlmod
# https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0
common --check_direct_dependencies=off


common --java_runtime_version=remotejdk_17
common --java_language_version=17
common --tool_java_runtime_version=remotejdk_17
common --tool_java_language_version=17
test --test_output=errors
common --incompatible_strict_action_env

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
# This needs to be last statement in this
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
workflow_dispatch:

concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
test:
Expand All @@ -27,5 +27,7 @@ jobs:
]
exclude: |
[
{"folder": ".", "bzlmodEnabled": false}
{"folder": ".", "bzlmodEnabled": false},
{"folder": "e2e/smoke", "bzlmodEnabled": true, "bazelversion": "6.4.0"},
{"folder": ".", "bzlmodEnabled": true, "bazelversion": "6.4.0"},
]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bazel-*
.bazelrc.user
.idea/
.ijwb/
MODULE.bazel.lock
23 changes: 18 additions & 5 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")

# gazelle:java_test_mode suite
# gazelle:java_maven_repository_name maven_pitest
gazelle(
name = "gazelle",
gazelle = ":gazelle_bin",
)

gazelle_binary(
name = "gazelle_bin",
languages = ["@bazel_skylib_gazelle_plugin//bzl"],
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//bzl",
"@contrib_rules_jvm//java/gazelle",
],
)

gazelle(
name = "gazelle",
gazelle = "gazelle_bin",
buildifier(
name = "buildifier",
exclude_patterns = [
"./.git/*",
],
)
24 changes: 20 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,24 @@ bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependenc
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)

pitest = use_extension("//pitest:extensions.bzl", "pitest")
pitest.toolchain(pitest_version = "1.14.2")
use_repo(pitest, "pitest_toolchains")
bazel_dep(name = "contrib_rules_jvm", version = "0.24.0")
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "6.0")

register_toolchains("@pitest_toolchains//:all")
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "maven_pitest",
artifacts = [
"org.pitest:pitest:1.15.8",
"org.pitest:pitest-entry:1.15.8",
"org.pitest:pitest-command-line:1.15.8",
"org.pitest:pitest-junit5-plugin:1.2.1",
],
fetch_sources = True,
lock_file = "//:maven_install.json",
)
use_repo(
maven,
"maven_pitest",
"unpinned_maven_pitest",
)
46 changes: 10 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,24 @@
# Template for Bazel rules

Copy this template to create a Bazel ruleset.

Features:

- follows the official style guide at https://docs.bazel.build/versions/main/skylark/deploying.html
- allows for both WORKSPACE.bazel and bzlmod (MODULE.bazel) usage
- includes Bazel formatting as a pre-commit hook (using [buildifier])
- includes stardoc API documentation generator
- includes typical toolchain setup
- CI configured with GitHub Actions
- release using GitHub Actions just by pushing a tag
- the release artifact doesn't need to be built by Bazel, but can still exclude files and stamp the version

See https://docs.bazel.build/versions/main/skylark/deploying.html#readme

[buildifier]: https://github.com/bazelbuild/buildtools/tree/master/buildifier#readme

Ready to get started? Copy this repo, then

1. search for "com_myorg_rules_mylang" and replace with the name you'll use for your workspace
1. search for "myorg" and replace with GitHub org
1. search for "mylang", "Mylang", "MYLANG" and replace with the language/tool your rules are for
1. rename directory "mylang" similarly
1. run `pre-commit install` to get lints (see CONTRIBUTING.md)
1. if you don't need to fetch platform-dependent tools, then remove anything toolchain-related.
1. (optional) install the [Renovate app](https://github.com/apps/renovate) to get auto-PRs to keep the dependencies up-to-date.
1. delete this section of the README (everything up to the SNIP).

---- SNIP ----

# Bazel rules for mylang
# Bazel rules for rules_pitest

## Installation

From the release you wish to use:
<https://github.com/myorg/rules_mylang/releases>
<https://github.com/bookingcom/rules_pitest/releases>
copy the WORKSPACE snippet into your `WORKSPACE` file.

To use a commit rather than a release, you can point at any SHA of the repo.

For example to use commit `abc123`:

1. Replace `url = "https://github.com/myorg/rules_mylang/releases/download/v0.1.0/rules_mylang-v0.1.0.tar.gz"` with a GitHub-provided source archive like `url = "https://github.com/myorg/rules_mylang/archive/abc123.tar.gz"`
1. Replace `strip_prefix = "rules_mylang-0.1.0"` with `strip_prefix = "rules_mylang-abc123"`
1. Replace `url = "https://github.com/bookingcom/rules_pitest/releases/download/v0.1.0/rules_pitest-v0.1.0.tar.gz"` with a GitHub-provided source archive like `url = "https://github.com/bookingcom/rules_pitest/archive/abc123.tar.gz"`
1. Replace `strip_prefix = "rules_pitest-0.1.0"` with `strip_prefix = "rules_pitest-abc123"`
1. Update the `sha256`. The easiest way to do this is to comment out the line, then Bazel will
print a message with the correct value. Note that GitHub source archives don't have a strong
guarantee on the sha256 stability, see
<https://github.blog/2023-02-21-update-on-the-future-stability-of-source-code-archives-and-hashes/>

## Usage

Check `e2e/smoke/sample-from-upstream` for an usage example

Once you do a bazel test you will find the reports in the compressed target `bazel-testlogs/<path>/test.outputs/outputs.zip`
32 changes: 28 additions & 4 deletions docs/rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions e2e/smoke/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
common --java_runtime_version=remotejdk_17
common --java_language_version=17
common --tool_java_runtime_version=remotejdk_17
common --tool_java_language_version=17
test --test_output=errors
common --incompatible_strict_action_env
common --verbose_failures
build --output_filter=DONT_MATCH_ANYTHING
build --incompatible_allow_tags_propagation
fetch --incompatible_allow_tags_propagation
query --incompatible_allow_tags_propagation
14 changes: 0 additions & 14 deletions e2e/smoke/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
"""Provides a simple way to test your rules as an external workspace.
Add a basic smoke-test target below.
"""

load("@bazel_skylib//rules:build_test.bzl", "build_test")
# load("@com_bookingcom_rules_pitest//pitest:defs.bzl", "...")

# Replace with a usage of your rule/macro
filegroup(name = "empty")

build_test(
name = "smoke_test",
targets = [
# targets you add above
":empty",
],
)
33 changes: 30 additions & 3 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
bazel_dep(name = "com_bookingcom_rules_pitest", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

bazel_dep(name = "com_bookingcom_rules_pitest", version = "0.0.0")
local_path_override(
module_name = "com_bookingcom_rules_pitest",
path = "../..",
)

bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "contrib_rules_jvm", version = "0.24.0")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "maven",
artifacts = [
"org.junit.jupiter:junit-jupiter:5.10.2",
"org.junit.jupiter:junit-jupiter-engine:5.10.2",
"org.junit.platform:junit-platform-launcher:1.10.2",
"org.junit.platform:junit-platform-reporting:1.10.2",
"org.junit.vintage:junit-vintage-engine:5.10.2",
"org.assertj:assertj-core:3.25.3",
"nl.jqno.equalsverifier:equalsverifier:3.15.8",
"org.mockito:mockito-core:5.11.0",
"org.mockito:mockito-junit-jupiter:5.11.0",
"org.junit:junit-bom:5.10.2",
"pl.pragmatists:JUnitParams:1.1.1",
],
fetch_sources = True,
lock_file = "//:maven_install.json",
)
use_repo(
maven,
"maven",
"unpinned_maven",
)
45 changes: 45 additions & 0 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,48 @@ local_repository(
load("@com_bookingcom_rules_pitest//pitest:repositories.bzl", "rules_pitest_dependencies")

rules_pitest_dependencies()

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

load("@contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps")

contrib_rules_jvm_deps()

load("@contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup")

contrib_rules_jvm_setup()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@com_bookingcom_rules_pitest//pitest:deps.bzl", pitest_maven_dependencies = "maven_dependencies")

pitest_maven_dependencies()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "maven",
artifacts = [
"org.junit.jupiter:junit-jupiter:5.10.2",
"org.junit.jupiter:junit-jupiter-engine:5.10.2",
"org.junit.platform:junit-platform-launcher:1.10.2",
"org.junit.platform:junit-platform-reporting:1.10.2",
"junit:junit:4.13.2",
"pl.pragmatists:JUnitParams:1.1.1",
],
fetch_sources = False,
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Loading