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
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
common --enable_bzlmod
common --test_tag_filters=-manual

try-import %workspace%/ci.bazelrc
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
9.2.0
4 changes: 1 addition & 3 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
matrix:
platform: ["macos", "ubuntu2004"]
bazel: ["7.x", "rolling"]
bazel: ["8.x", "9.x", "rolling"]

tasks:
verify_targets:
name: "Verify build targets"
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags:
- "--enable_bzlmod=true"
build_targets:
- "@rules_pmd//pmd/..."
4 changes: 2 additions & 2 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file contains Bazel settings to apply on CI only.
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
common --curses=no
common --enable_bzlmod

build --verbose_failures
build --worker_verbose
Expand All @@ -12,7 +11,8 @@ build --announce_rc
# We do not enable the repository cache to cache downloaded external artifacts
# as these are generally faster to download again than to fetch them from the
# GitHub actions cache.
build --disk_cache=~/.cache/bazel
build --disk_cache=~/.cache/bazel-disk-cache

# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
Expand Down
59 changes: 35 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

concurrency:
# Cancel previous actions from the same PR or branch except 'master' branch.
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 == 'master' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'master' }}

jobs:
buildifier:
runs-on: ubuntu-latest
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7.0.1
- name: "Install JDK 11"
- name: "Install JDK 21"
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "11"
java-version: "21"
- name: "Setup Bazelisk"
uses: bazelbuild/setup-bazelisk@v3
- name: "Linting Starlark"
run: bazel run @buildifier_prebuilt//:buildifier -- -mode check -lint warn -r .

build-bzlmod:
runs-on: ubuntu-22.04
build:
strategy:
matrix:
os: [ubuntu-latest]
bazel_version: ["8.x", "9.x"]
runs-on: ${{ matrix.os }}
name: build (${{ matrix.os }}, bazel ${{ matrix.bazel_version }})
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7.0.1
- name: "Install JDK 11"
- name: "Install JDK 21"
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "11"
java-version: "21"
- name: Mount bazel caches
uses: actions/cache@v5.0.3
with:
path: |
~/.cache/bazel-disk-cache
key: bazel-cache-${{ matrix.os }}-${{ matrix.bazel_version }}-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'MODULE.bazel') }}
restore-keys: bazel-cache-${{ matrix.os }}-${{ matrix.bazel_version }}-
- name: "Setup Bazelisk"
uses: bazelbuild/setup-bazelisk@v3
- name: "Configure Bazel"
run: cp .github/workflows/ci.bazelrc .
- name: "Build"
run: bazel build //... --enable_bzlmod=True
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
run: bazel build //...
- name: "Unit tests"
run: bazel test //... --enable_bzlmod=True
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
run: bazel test //...
- name: "Integration tests"
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
run: bash tests/integration/suite.sh
build-workspace:
runs-on: ubuntu-22.04
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7.0.1
- name: "Install JDK 11"
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "11"
- name: "Setup Bazelisk"
uses: bazelbuild/setup-bazelisk@v3
- name: "Configure Bazel"
run: cp .github/workflows/ci.bazelrc .
- name: "Build"
run: bazel build //... --enable_bzlmod=False
15 changes: 0 additions & 15 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,4 @@ cat << EOF
\`\`\`starlark
bazel_dep(name = "rules_pmd", version = "${TAG:1}")
\`\`\`

## Using WORKSPACE

Paste this snippet into your `WORKSPACE.bazel` file:

\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_pmd",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/buildfoundation/bazel_rules_pmd/releases/download/${TAG}/${ARCHIVE}",
)
EOF

echo "\`\`\`"
9 changes: 5 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module(
pmd = use_extension("//pmd:extensions.bzl", "pmd")
use_repo(pmd, "net_sourceforge_pmd")

bazel_dep(name = "rules_java", version = "5.5.0")
bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.5.3", repo_name = "io_bazel_stardoc", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.3.3", dev_dependency = True)
bazel_dep(name = "rules_java", version = "9.3.0")

bazel_dep(name = "bazel_skylib", version = "1.9.2", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.8.1", dev_dependency = True, repo_name = "io_bazel_stardoc")
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.3", dev_dependency = True)
41 changes: 2 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,11 @@ for [the Bazel build system](https://bazel.build).
bazel_dep(name = "rules_pmd", version = "...")
```

### `WORKSPACE` Configuration

Declare the rule in the `WORKSPACE` file.
Please refer to [GitHub releases](https://github.com/buildfoundation/bazel_rules_pmd/releases) for the version and the SHA-256 hashsum.

```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

rules_pmd_version = "REPLACE_ME"
rules_pmd_sha = "REPLACE_ME"

http_archive(
name = "rules_pmd",
sha256 = rules_pmd_sha,
strip_prefix = "bazel_rules_pmd-{v}".format(v = rules_pmd_version),
url = "https://github.com/buildfoundation/bazel_rules_pmd/archive/v{v}.tar.gz".format(v = rules_pmd_version),
)

load("@rules_pmd//pmd:dependencies.bzl", "rules_pmd_dependencies")
rules_pmd_dependencies()

load("@rules_pmd//pmd:toolchains.bzl", "rules_pmd_toolchains")
rules_pmd_toolchains()
```
Please refer to [GitHub releases](https://github.com/buildfoundation/bazel_rules_pmd/releases) for the available versions.

### `BUILD` Configuration

Once declared in the `WORSKPACE` file, the rule can be loaded in the `BUILD` file.
Once declared in the `MODULE.bazel` file, the rule can be loaded in the `BUILD` file.

```starlark
load("@rules_pmd//pmd:defs.bzl", "pmd_test")
Expand All @@ -62,20 +39,6 @@ pmd.pmd_version(
use_repo(pmd, "net_sourceforge_pmd")
```

Or change the `WORKSPACE` file:

```python
load("@rules_pmd//pmd:versions.bzl", "pmd_version")
load("@rules_pmd//pmd:dependencies.bzl", "rules_pmd_dependencies")

rules_pmd_dependencies(
pmd_version = pmd_version(
version = "x.x.x",
sha256 = "x.x.x.sha256",
)
)
```

See [available attributes](docs/rule.md).

### Execution
Expand Down
73 changes: 0 additions & 73 deletions WORKSPACE

This file was deleted.

Empty file removed WORKSPACE.bzlmod
Empty file.
4 changes: 2 additions & 2 deletions pmd/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _impl(ctx):
DefaultInfo(
files = depset(outputs),
executable = execution_result,
)
),
]

def _write_files_list(ctx, files, file_name):
Expand All @@ -105,7 +105,7 @@ pmd_test = rule(
"_executable": attr.label(
default = "//pmd/wrapper:bin",
executable = True,
cfg = "host",
cfg = "exec",
),
"srcs": attr.label_list(
allow_files = True,
Expand Down
47 changes: 0 additions & 47 deletions pmd/dependencies.bzl

This file was deleted.

2 changes: 2 additions & 0 deletions pmd/extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module extension for fetching the PMD distribution."""

load(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",
Expand Down
16 changes: 0 additions & 16 deletions pmd/toolchains.bzl

This file was deleted.

2 changes: 2 additions & 0 deletions pmd/versions.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""PMD release definitions."""

def pmd_version(version, sha256):
"""Create a pmd version.

Expand Down
Loading
Loading