Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-thm committed Mar 18, 2024
0 parents commit c47da23
Show file tree
Hide file tree
Showing 38 changed files with 784 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
common --enable_bzlmod

common --lockfile_mode=off
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.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.
3 changes: 3 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixedReleaser:
login: mark-thm
email: 123787712+mark-thm@users.noreply.github.com
18 changes: 18 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"homepage": "https://github.com/theoremlp/rules_uv",
"maintainers": [
{
"email": "123787712+mark-thm@users.noreply.github.com",
"github": "mark-thm",
"name": "Mark Elliot"
},
{
"email": "bazel-maintainers@theoremlp.com",
"github": "theoremlp",
"name": "Theorem Bazel Maintainers"
}
],
"repository": ["github:theoremlp/rules_uv"],
"versions": [],
"yanked_versions": {}
}
15 changes: 15 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
matrix:
platform:
- debian10
- ubuntu2004
- macos
- macos_arm64
bazel:
- 7.x
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- "@rules_uv//..."
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}/{REPO}-{VERSION}.tar.gz"
}
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# In code review, collapse generated files
docs/*.md linguist-generated=true

#################################
# Configuration for 'git archive'
# See https://git-scm.com/docs/git-archive#ATTRIBUTES

# 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.
examples export-ignore
18 changes: 18 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
":dependencyDashboard",
":semanticPrefixFixDepsChoreOthers",
"group:monorepos",
"group:recommended",
"replacements:all",
"workarounds:all"
],
"packageRules": [
{
"matchFiles": ["MODULE.bazel"],
"enabled": false
}
]
}

18 changes: 18 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5
with:
folders: |
[
".",
"examples/typical",
]
# we only support Bazel 7, and only with bzlmod enabled
exclude: |
[
{"bzlmodEnabled": false},
{"bazelversion": "5.4.0"},
{"bazelversion": "6.4.0"},
]
# this ruleset only supports linux and macos
exclude_windows: true
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release
on:
push:
tags:
- "v*.*.*"

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5
permissions:
contents: write
with:
release_files: rules_uv-*.tar.gz
prerelease: false
30 changes: 30 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# invoked by release workflow
# (via https://github.com/bazel-contrib/.github/blob/master/.github/workflows/release_ruleset.yaml)

set -o errexit -o nounset -o pipefail

RULES_NAME="rules_uv"
TAG="${GITHUB_REF_NAME}"
PREFIX="${RULES_NAME}-${TAG:1}"
ARCHIVE="${RULES_NAME}-${TAG:1}.tar.gz"

# embed version in MODULE.bazel
perl -pi -e "s/version = \"0\.0\.0\",/version = \"${TAG:1}\",/g" MODULE.bazel

stash_name=`git stash create`;
git archive --format=tar --prefix=${PREFIX}/ "${stash_name}" | gzip > $ARCHIVE

SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod with Bazel 7
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "${RULES_NAME}", version = "${TAG:1}")
\`\`\`
EOF
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bazel-bin/
bazel-out/
bazel-testlogs/
bazel-*

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

exports_files([
"MODULE.bazel",
])

buildifier(
name = "buildifier.fix",
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
mode = "fix",
visibility = ["//thm/buildtools/fix:__pkg__"],
)

buildifier_test(
name = "buildifier.test",
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
no_sandbox = True,
workspace = "//:MODULE.bazel",
)
Loading

0 comments on commit c47da23

Please sign in to comment.