Skip to content

Commit

Permalink
Merge pull request #55 from benchsci/configure-bcr
Browse files Browse the repository at this point in the history
Configure bcr
  • Loading branch information
ewianda authored Mar 25, 2024
2 parents fcf9e31 + c23150e commit 5cad13d
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 14 deletions.
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: ewianda
email: [email protected]
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/benchsci/rules_nodejs_gazelle",
"maintainers": [
{
"name": "Elvis Wianda",
"email": "[email protected]",
"github": "ewianda"
},
{
"name": "Colin Heathman",
"email": "[email protected]",
"github": "ColinHeathman"
}
],
"repository": ["https://github.com/benchsci/rules_nodejs_gazelle"],
"versions": [],
"yanked_versions": {}
}
12 changes: 12 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bcr_test_module:
module_path: 'examples/nextjs'
matrix:
bazel: ['7.x', '6.x']
platform: ['debian10', 'macos', 'ubuntu2004', 'windows']
tasks:
run_tests:
name: 'Run test module'
bazel: ${{ bazel }}
platform: ${{ platform }}
run_targets:
- '//:gazelle'
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_nodejs_gazelle-{TAG}.tar.gz"
}
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ jobs:
# Bazel will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel test //...
- name: Prepare workspace snippet
- name: Prepare Release
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
uses: benchsci/action-gh-release@v1
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
files: rules_nodejs_gazelle-*.tar.gz
fail_on_unmatched_files: true

20 changes: 8 additions & 12 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ set -o errexit -o nounset -o pipefail
# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
NAME=rules_nodejs_gazelle
COMMIT=$(git rev-parse HEAD)
PREFIX=${NAME}-${COMMIT}
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | shasum -a 256 | awk '{print $1}')
INTEGRITY=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | openssl dgst -sha256 -binary | openssl base64 -A)
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="${NAME}-${TAG:1}"
ARCHIVE="${NAME}-$TAG.tar.gz"
git archive --format=tar --prefix="${PREFIX}/" "${TAG}" | gzip >"$ARCHIVE"
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')

cat <<EOF
MODULE.bazel setup:
\`\`\`starlark
bazel_dep(name = "com_github_benchsci_rules_nodejs_gazelle", version = "0.0.0", repo_name = "com_github_benchsci_rules_nodejs_gazelle")
bazel_dep(name = "com_github_benchsci_rules_nodejs_gazelle", version = "${TAG:1}", repo_name = "com_github_benchsci_rules_nodejs_gazelle")
archive_override(
module_name = "com_github_benchsci_rules_nodejs_gazelle",
integrity = "sha256-${INTEGRITY}",
strip_prefix = "${PREFIX}",
urls = ["https://github.com/benchsci/rules_nodejs_gazelle/archive/$COMMIT.tar.gz"],
)
\`\`\`
WORKSPACE setup:
Expand All @@ -32,7 +28,7 @@ http_archive(
name = "com_github_benchsci_rules_nodejs_gazelle",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/benchsci/rules_nodejs_gazelle/archive/$COMMIT.tar.gz",
url = "https://github.com/benchsci/rules_nodejs_gazelle/releases/download/${TAG}/${ARCHIVE}",
)
\`\`\`
EOF
1 change: 1 addition & 0 deletions examples/nextjs/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
55 changes: 55 additions & 0 deletions examples/nextjs/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module(
name = "e2e_rules_nodejs_gazelle",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_rules_js", version = "1.27.0")
bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_rules_ts", version = "1.4.0")
bazel_dep(name = "aspect_rules_jest", version = "0.0.0", repo_name = "aspect_rules_jest")
bazel_dep(name = "com_github_benchsci_rules_nodejs_gazelle", version = "0.0.0", repo_name = "com_github_benchsci_rules_nodejs_gazelle")
local_path_override(
module_name = "com_github_benchsci_rules_nodejs_gazelle",
path = "../..",
)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
bins = {
# derived from "bin" attribute in node_modules/next/package.json
"next": [
"next=./dist/bin/next",
],
},
# Test that lifecycle hooks can resolve node, npm as well as dep bins on that PATH.
# This e2e test is run on Windows as well so this test coverage is here for now. Once
# Windows CI runs on the root WORKSPACE, coverage can be moved there.
# See https://github.com/aspect-build/rules_js/pull/1142 for more info.
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

rules_ts_ext = use_extension(
"@aspect_rules_ts//ts:extensions.bzl",
"ext",
dev_dependency = True,
)
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")

archive_override(
module_name = "aspect_rules_jest",
integrity = "sha256-F1+SRIvRGzmO6UxrsJyr9233WnfSHJVVcjeYxYouc8g=",
strip_prefix = "rules_jest-0.19.2",
urls = ["https://github.com/aspect-build/rules_jest/releases/download/v0.19.2/rules_jest-v0.19.2.tar.gz"],
)
2 changes: 1 addition & 1 deletion examples/nextjs/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ npm_translate_lock(
"next": "./dist/bin/next",
},
},
pnpm_lock = "//:pnpm-lock.yaml",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

Expand Down
Empty file.

0 comments on commit 5cad13d

Please sign in to comment.