Skip to content

Commit

Permalink
refactor: initial update renaming post-template (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpanta committed Oct 26, 2024
2 parents 8ae3d03 + cc09bcd commit 2c5a8f2
Show file tree
Hide file tree
Showing 38 changed files with 4,261 additions and 562 deletions.
10 changes: 5 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Bazel settings that apply to this repository.
# Take care to document any settings that you expect users to apply.
# Settings that apply only to CI are in .github/workflows/ci.bazelrc

# Required until this is the default; expected in Bazel 7
common --enable_bzlmod

# Don’t want to push a rules author to update their deps if not needed.
# As a rules repo, don't force updates unexpectedly.
# https://bazel.build/reference/command-line-reference#flag--check_direct_dependencies
# https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0
common --check_direct_dependencies=off

# Set up local caching of repos and actions.
build --repository_cache=.cache/bazel/repo
build --disk_cache=.cache/bazel/actions

# 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
7 changes: 1 addition & 6 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
7.2.1
# The first line of this file is used by Bazelisk and Bazel to be sure
# the right version of Bazel is used to build and test this repo.
# This also defines which version is used on CI.
#
# Note that you should also run integration_tests against other Bazel
# versions you support.

4 changes: 2 additions & 2 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"homepage": "https://github.com/myorg/rules_mylang",
"homepage": "https://github.com/fullstorydev/rules_android",
"maintainers": [],
"repository": ["github:myorg/rules_mylang"],
"repository": ["github:fullstorydev/rules_android"],
"versions": [],
"yanked_versions": {}
}
8 changes: 8 additions & 0 deletions .cz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
commitizen:
major_version_zero: true
name: cz_conventional_commits
tag_format: $version
update_changelog_on_bump: true
version: 0.0.1
version_scheme: semver2
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ examples export-ignore

# Occasionally there's a need to "stamp" the release version into a file
# See https://blog.aspect.build/releasing-bazel-rulesets-rust for details if you need this.
# mylang/version.bzl export-subst
# android/version.bzl export-subst
2 changes: 1 addition & 1 deletion .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: buildifier
run: bazel run --enable_bzlmod //.github/workflows:buildifier.check
run: bazel run //.github/workflows:buildifier.check
7 changes: 2 additions & 5 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@

# 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
13 changes: 7 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ 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:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v7
with:
folders: |
[
Expand All @@ -27,7 +27,8 @@ jobs:
]
exclude: |
[
{"folder": ".", "bzlmodEnabled": false}
{"folder": ".", "bzlmodEnabled": false},
{"bazelversion": "8.0.0rc1", "os": "ubuntu-latest"}
]
# For branch protection settings, this job provides a "stable" name that can be used to gate PR merges
# on "all matrix jobs were successful".
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ permissions:

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7
with:
release_files: rules_mylang-*.tar.gz
17 changes: 8 additions & 9 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,33 @@ TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
# This guarantees that users can easily switch from a released artifact to a source archive
# with minimal differences in their code (e.g. strip_prefix remains the same)
PREFIX="rules_mylang-${TAG:1}"
ARCHIVE="rules_mylang-$TAG.tar.gz"
PREFIX="rules_android-${TAG:1}"
ARCHIVE="rules_android-$TAG.tar.gz"

# NB: configuration for 'git archive' is in /.gitattributes
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod with Bazel 6 or greater
## Using Bzlmod
1. (Bazel 6 only) Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
1. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "com_myorg_rules_mylang", version = "${TAG:1}")
bazel_dep(name = "fullstory_rules_android", version = "${TAG:1}")
\`\`\`
## Using WORKSPACE
## Using WORKSPACE (Bazel 8 or less)
Paste this snippet into your \`WORKSPACE.bazel\` file:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_myorg_rules_mylang",
name = "fullstory_rules_android",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/myorg/rules_mylang/releases/download/${TAG}/${ARCHIVE}",
url = "https://github.com/fullstorydev/rules_android/releases/download/${TAG}/${ARCHIVE}",
)
EOF

Expand Down
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/
.cache/
56 changes: 32 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# 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

default_stages:
- pre-commit
repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.1.0.1
hooks:
- hooks:
- entry: ./tools/update_bzlmod_lockfile.sh
files: MODULE.bazel
id: update-bzlmod-lock
language: script
name: Update MODULE.bazel.lock
pass_filenames: false
- args:
- e2e/smoke
entry: ./tools/update_bzlmod_lockfile.sh
files: e2e/smoke/MODULE.bazel
id: update-e2e-bzlmod-lock
language: script
name: Update e2e/MODULE.bazel.lock
pass_filenames: false
repo: local
- 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
repo: https://github.com/keith/pre-commit-buildifier
rev: 6.1.0.1
- hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.0"
hooks:
stages:
- commit-msg
- id: commitizen-branch
stages:
- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.0
- hooks:
- id: prettier
repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.4.0
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ Run `bazel run //:gazelle` to keep them up-to-date.
## Using this as a development dependency of other rules

You'll commonly find that you develop in another WORKSPACE, such as
some other ruleset that depends on rules_mylang, or in a nested
some other ruleset that depends on rules_android, or in a nested
WORKSPACE in the integration_tests folder.

To always tell Bazel to use this directory rather than some release
artifact or a version fetched from the internet, run this from this
directory:

```sh
OVERRIDE="--override_repository=rules_mylang=$(pwd)/rules_mylang"
OVERRIDE="--override_repository=fullstory_rules_android=/path/to/local/rules_android"
echo "common $OVERRIDE" >> ~/.bazelrc
```

This means that any usage of `@rules_mylang` on your system will point to this folder.
This means that any usage of `@fullstory_rules_android` on your system will point to this folder.

## Releasing

Expand Down
20 changes: 7 additions & 13 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
"Bazel dependencies"

module(
name = "com_myorg_rules_mylang",
name = "fullstory_rules_android",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")

bazel_dep(name = "gazelle", version = "0.35.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)
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)

mylang = use_extension("//mylang:extensions.bzl", "mylang")
mylang.toolchain(mylang_version = "1.14.2")
use_repo(mylang, "mylang_toolchains")

register_toolchains("@mylang_toolchains//:all")
bazel_dep(name = "gazelle", version = "0.39.1", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.9.3", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)
Loading

0 comments on commit 2c5a8f2

Please sign in to comment.