Skip to content

Commit

Permalink
chore: move code to new home
Browse files Browse the repository at this point in the history
  • Loading branch information
mgred committed Dec 19, 2023
1 parent 4c71660 commit 93ee4c8
Show file tree
Hide file tree
Showing 23 changed files with 1,666 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e2e/
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.4.0
5 changes: 5 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Used in github workflow `ci.yaml`
build --disk_cache=~/.cache/bazel
build --repository_cache=~/.cache/bazel-repo
test --test_output=errors
test --test_env=XDG_CACHE_HOME
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

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

jobs:
test:
runs-on: ubuntu-latest
env:
XDG_CACHE_HOME: ~/.cache/bazel-repo
strategy:
matrix:
bazelversion:
- 6.4.0
- 7.0.0
folder:
- "."
- "e2e"
steps:
- uses: actions/checkout@v4
- name: Mount bazel caches
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
~/.cache/bazel-repo
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache-
- name: Tests
working-directory: ${{ matrix.folder }}
run: >
USE_BAZEL_VERSION="${{ matrix.bazelversion }}"
bazel
--bazelrc=${{ github.workspace }}/.bazelrc
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc
test //...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
26 changes: 26 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
visibility = ["//visibility:public"],
deps = ["//lib:sqids"],
)

buildifier(
name = "format",
exclude_patterns = [
"./.git/*",
],
lint_mode = "fix",
mode = "fix",
)

buildifier_test(
name = "buildifier_test",
lint_mode = "warn",
mode = "check",
no_sandbox = True,
workspace = "//:WORKSPACE",
)
14 changes: 14 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "sqids_bazel",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(
name = "buildifier_prebuilt",
version = "6.4.0",
dev_dependency = True,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_bazel_lib", version = "1.39.0")
Empty file added WORKSPACE
Empty file.
7 changes: 7 additions & 0 deletions defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"Public API"

load("//lib:sqids.bzl", _decode = "decode", _encode = "encode", _sqids = "sqids")

decode = _decode
encode = _encode
sqids = _sqids
1 change: 1 addition & 0 deletions e2e/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
19 changes: 19 additions & 0 deletions e2e/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@sqids_bazel//:defs.bzl", "sqids")

hash = sqids().encode([
1,
2,
3,
])

genrule(
name = "file",
outs = ["test-%s" % hash],
cmd = "echo '%s' > $(OUTS)" % hash,
)

build_test(
name = "test",
targets = [":file"],
)
12 changes: 12 additions & 0 deletions e2e/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module(
name = "sqids_bazel_e2e",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "sqids_bazel", version = "0.0.0")
local_path_override(
module_name = "sqids_bazel",
path = "..",
)
5 changes: 5 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# e2e

```bash
cd e2e; bazel test //...
```
20 changes: 20 additions & 0 deletions lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "constants",
srcs = ["constants.bzl"],
visibility = [
"//lib:__subpackages__",
"//lib/tests:__subpackages__",
],
)

bzl_library(
name = "sqids",
srcs = ["sqids.bzl"],
visibility = ["//:__pkg__"],
deps = [
":constants",
"@aspect_bazel_lib//lib:strings",
],
)
Loading

0 comments on commit 93ee4c8

Please sign in to comment.