Skip to content

Commit

Permalink
chore: bzlmod (#113)
Browse files Browse the repository at this point in the history
* chore: bzlmod

* chore: bump minimum rules_js to pick up windows fix

* format

* green up root bzlmod

* exclude buildifier on windows
  • Loading branch information
alexeagle authored Aug 18, 2023
1 parent e7c1047 commit b5e8cd4
Show file tree
Hide file tree
Showing 28 changed files with 114 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Take care to document any settings that you expect users to apply.
# Settings that apply only to CI are in .github/workflows/ci.bazelrc

# for rules_js
build --enable_runfiles

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
Expand Down
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.
4 changes: 4 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation
fixedReleaser:
login: gregmagolan
email: [email protected]
13 changes: 13 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"homepage": "https://docs.aspect.build/rules/aspect_rules_webpack",
"maintainers": [
{
"email": "[email protected]",
"github": "aspect-build",
"name": "Aspect team"
}
],
"repository": ["github:aspect-build/rules_webpack"],
"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_webpack-{TAG}.tar.gz"
}
28 changes: 25 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ jobs:
run: echo "os=macos-latest" >> $GITHUB_OUTPUT
# Only run on main branch (not PRs) to minimize macOS minutes (billed at 10X)
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
if: ${{ github.ref == 'refs/heads/main' }}
if: github.ref == 'refs/heads/main'
- id: windows
run: echo "os=windows-latest" >> $GITHUB_OUTPUT
# Only run on main branch (or PR branches that contain 'windows') to minimize Windows minutes (billed at 2X)
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
if: github.ref == 'refs/heads/main' || contains(github.head_ref, 'windows') || github.head_ref == 'bzlmod'
outputs:
# Will look like ["ubuntu-latest", "macos-latest"]
os: ${{ toJSON(steps.*.outputs.os) }}
Expand All @@ -59,17 +64,27 @@ jobs:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }}
bzlmodEnabled: [true, false]
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
folder:
- '.'
- 'e2e/loaders'
- 'e2e/workspace'
- 'e2e/smoke'
- 'e2e/worker'
exclude:
# Don't test macos with Bazel 5 to minimize macOS minutes (billed at 10X)
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
- os: macos-latest
bazelversion: 5.3.2
# Don't test bzlmod with Bazel 5 (not supported)
- bazelversion: 5.3.2
bzlmodEnabled: true
# TODO
- folder: e2e/loaders
bzlmodEnabled: true
# TODO
- folder: e2e/worker
bzlmodEnabled: true

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -103,12 +118,19 @@ jobs:
# then use .bazelversion to determine which Bazel version to use
run: echo "${{ matrix.bazelversion }}" > .bazelversion

- name: Set bzlmod flag
# Store the --enable_bzlmod flag that we add to the test command below
# only when we're running bzlmod in our test matrix.
id: set_bzlmod_flag
if: matrix.bzlmodEnabled
run: echo "bzlmod_flag=--enable_bzlmod" >> $GITHUB_OUTPUT

- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
working-directory: ${{ matrix.folder }}
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
run: bazel --bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} //...

- name: run ./test.sh
working-directory: ${{ matrix.folder }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ http_archive(
)
EOF

awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE
awk 'f;/--SNIP--/{f=1}' e2e/smoke/WORKSPACE.bazel
echo "\`\`\`"
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ buildifier(
],
lint_mode = "warn",
mode = "diff",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

bzl_library(
Expand Down
15 changes: 15 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"aspect-build/rules_webpack"

module(
name = "aspect_rules_webpack",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "1.32.0")
bazel_dep(name = "aspect_rules_js", version = "1.29.2")
bazel_dep(name = "bazel_skylib", version = "1.4.1")

bazel_dep(name = "gazelle", version = "0.29.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 = "buildifier_prebuilt", version = "6.1.2.1", dev_dependency = True)
2 changes: 2 additions & 0 deletions e2e/loaders/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# for rules_js
build --enable_runfiles
File renamed without changes.
2 changes: 2 additions & 0 deletions e2e/smoke/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# for rules_js
build --enable_runfiles
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"Bazel dependencies"

bazel_dep(name = "aspect_rules_js", version = "1.29.2")
bazel_dep(name = "bazel_skylib", version = "1.4.1")

bazel_dep(name = "aspect_rules_webpack", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_webpack",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
File renamed without changes.
2 changes: 2 additions & 0 deletions e2e/smoke/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file that this is the root of a Bazel workspace.
# This file replaces WORKSPACE.bazel under --enable_bzlmod.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions e2e/smoke/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { version } from './module'

console.log(version)
1 change: 1 addition & 0 deletions e2e/smoke/src/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const version = '0.0.0'
2 changes: 2 additions & 0 deletions e2e/worker/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# for rules_js
build --enable_runfiles
Empty file removed e2e/workspace/.bazelrc
Empty file.
3 changes: 0 additions & 3 deletions e2e/workspace/src/index.js

This file was deleted.

1 change: 0 additions & 1 deletion e2e/workspace/src/module.js

This file was deleted.

0 comments on commit b5e8cd4

Please sign in to comment.