Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for bzlmod #27

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ build --workspace_status_command=util/get_workspace_status.sh

# Import site-specific configuration.
try-import .bazelrc-site

# This repo no longer supports `WORKSPACE` dependencies.
common --enable_bzlmod
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

name: CI

on:
pull_request:
branches: ["*"]

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y $(find . -name apt-requirements.txt | xargs sed -e "s/#.*//g")
jwnrt marked this conversation as resolved.
Show resolved Hide resolved
- name: Build firmware
run: |
bazel build :hyperdebug-firmware

26 changes: 16 additions & 10 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

name: Create Release

on:
workflow_dispatch:
inputs:
Expand All @@ -8,25 +13,26 @@ on:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y $(find . -name apt-requirements.txt | xargs sed -e "s/#.*//g")
- name: Build
- name: Create tag
run: |
git tag ${{ inputs.release_tag }}
bazel build --stamp :release
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily have a strong opinion but I can see an advantage to using bazel-release in theory: the release process is part of the build and can be done locally easily. Github/Azure flows are always notorioulsy bad for local reproducibility as they get more complicated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

I have this PR for adding bzlmod support to bazel-release: lowRISC/bazel-release#5

If that's merged, we could go back to using it.

- name: Test
git tag "${{ inputs.release_tag }}"
git push origin tag "${{ inputs.release_tag }}"
- name: Build firmware
run: |
echo "No tests to run"
# bazel test //...
bazel build --stamp :hyperdebug-firmware
- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
run: |
bazel run :release -- ${{ inputs.release_tag }}
gh release create "${{ inputs.release_tag }}" \
--title "${{ inputs.release_tag }}"
gh release upload "${{ inputs.release_tag }}" \
"$(bazel cquery --output=files :hyperdebug-firmware)"
17 changes: 1 addition & 16 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,14 @@

package(default_visibility = ["//visibility:public"])

load("@lowrisc_bazel_release//release:release.bzl", "release")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

genrule(
name = "ec_bin",
srcs = ["@ec_src//:gen_dir"],
outs = ["ec.bin"],
cmd = "cp $(location @ec_src//:gen_dir)/ec.bin $@",
)

pkg_tar(
name = "hyperdebug-firmware",
srcs = [
"90-hyperdebug.rules",
":ec_bin",
"//third_party/chromium:hyperdebug",
],
extension = "tar.gz",
package_dir = "hyperdebug",
)

release(
name = "release",
artifacts = {
":hyperdebug-firmware": "Hyperdebug Firmware",
},
)
16 changes: 16 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

module(name = "lowrisc_hyperdebug")

bazel_dep(name = "rules_foreign_cc", version = "0.10.1")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "toolchains_arm_gnu", version = "1.0.2")

arm_toolchain = use_extension("@toolchains_arm_gnu//:extensions.bzl", "arm_toolchain")
arm_toolchain.arm_none_eabi()
use_repo(arm_toolchain, "arm_none_eabi")

sources = use_extension("//:extensions.bzl", "sources")
use_repo(sources, "ec_src")
Loading