Skip to content

Commit

Permalink
Restructure everything into the bazel-contrib/template structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Bencodes committed Oct 23, 2023
1 parent 0347b11 commit 8d35cb3
Show file tree
Hide file tree
Showing 114 changed files with 5,244 additions and 989 deletions.
4 changes: 2 additions & 2 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lint-tests/
lint-examples/
e2e/
examples/
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
common --experimental_google_legacy_api
# Required until this is the default; expected in Bazel 7
common --enable_bzlmod

try-import %workspace%/.bazelrc.user
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0
6.4.0
9 changes: 9 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Bazel Central Registry

When the ruleset is released, we want it to be published to the
Bazel Central Registry automatically:
<https://registry.bazel.build>

This folder contains configuration files to automate the publish step.
See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
for authoritative documentation about these files.
6 changes: 6 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation
# for guidance about whether to uncomment this section:
#
# fixedReleaser:
# login: my_github_handle
# email: [email protected]
7 changes: 7 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"homepage": "https://github.com/bencodes/rules_android_lint",
"maintainers": [],
"repository": ["github:bencodes/rules_android_lint"],
"versions": [],
"yanked_versions": {}
}
10 changes: 10 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bcr_test_module:
module_path: "e2e/smoke"
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "**leave this alone**",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_android_lint-{TAG}.tar.gz"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/*.md linguist-generated=true
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@buildifier_prebuilt//:rules.bzl", "buildifier")

buildifier(
name = "buildifier.check",
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
)

buildifier(
name = "buildifier.fix",
disabled_rewrites = [
"label",
],
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
)
19 changes: 19 additions & 0 deletions .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Buildifier

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: buildifier
run: bazel run --enable_bzlmod //.github/workflows:buildifier.check
15 changes: 15 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

# Debug where options came from
build --announce_rc
# This directory is configured in GitHub actions to be persisted between runs.
# 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
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
61 changes: 61 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: "Checkout the sources"
uses: actions/checkout@v4
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
- name: Mount bazel caches
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache-
- name: "Setup Bazelisk"
uses: bazelbuild/setup-bazelisk@v2
- name: "Running tests //..."
run: bazel test //... --enable_bzlmod=true
integration-tests:
runs-on: ubuntu-latest
steps:
- name: "Checkout the sources"
uses: actions/checkout@v4
- name: "Install JDK 11"
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
- name: Mount bazel caches
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache-
- name: "Setup Bazelisk"
uses: bazelbuild/setup-bazelisk@v2
- name: "Running integration tests examples/simple-android"
working-directory: examples/simple-android
run: bazel test //... --enable_bzlmod=true
40 changes: 0 additions & 40 deletions .github/workflows/main.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cut a release whenever a new tag is pushed to the repo.
# You should use an annotated tag, like `git tag -a v1.2.3`
# and put the release notes into the commit message for the tag.
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v4
with:
release_files: rules_android_lint-*.tar.gz
45 changes: 45 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

# Don't include examples in the distribution artifact, to reduce size.
# You may want to add additional exclusions for folders or files that users don't need.
# NB: this mechanism relies on a `git archive` feature, which is much simpler and less
# error-prone than using Bazel to build a release artifact from sources in the repository.
# See https://git-scm.com/docs/git-archive#ATTRIBUTES
echo >>.git/info/attributes "examples export-ignore"

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_android_lint-${TAG:1}"
ARCHIVE="rules_android_lint-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod with Bazel 6
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_android_lint", 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_android_lint",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/bencodes/rules_android_lint/releases/download/${TAG}/${ARCHIVE}",
)
EOF

echo "\`\`\`"
34 changes: 4 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,bazel
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,bazel

### Bazel ###
# gitignore template for Bazel build system
# website: https://bazel.build/

# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
/bazel-*

# Bazel Intellij
/.ijwb/
# Bazel Android Studio
/.aswb/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

trace.profile.gz
bazel-*
.bazelrc.user
.idea/
.ijwb/
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See CONTRIBUTING.md for instructions.
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

# Commitizen runs in commit-msg stage
# but we don't want to run the other hooks on commit messages
default_stages: [commit]

# Use a slightly older version of node by default
# as the default uses a very new version of GLIBC
default_language_version:
node: 16.18.0

repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.1.0.1
hooks:
- id: buildifier
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.0"
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/*.md
11 changes: 11 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config")

exports_files(["maven_install.json"])

ktlint_config(
name = "editorconfig",
android_rules_enabled = False,
editorconfig = "//:.editorconfig",
experimental_rules_enabled = False,
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 8d35cb3

Please sign in to comment.