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

wip: adopt bzlmod #75

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
14 changes: 4 additions & 10 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
# Import Aspect bazelrc presets
try-import %workspace%/.aspect/bazelrc/local/bazel7.bazelrc # will only work in bazel7+
try-import %workspace%/.aspect/bazelrc/bazel7.bazelrc # will only work in bazel7+
import %workspace%/.aspect/bazelrc/bazel6.bazelrc # will only work in bazel6+
import %workspace%/.aspect/bazelrc/convenience.bazelrc
import %workspace%/.aspect/bazelrc/correctness.bazelrc
import %workspace%/.aspect/bazelrc/debug.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc

# Specific project flags go here if we have some
common --incompatible_enable_proto_toolchain_resolution

# register toolchains with prebuilts
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:linux-amd64-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:linux-arm64-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:linux-ppc64-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:linux-ppc64le-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:linux-s390x-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:darwin-amd64-toolchain
common:prebuilt-toolchain --extra_toolchains=@bazeldnf_prebuilt//:darwin-arm64-toolchain
common --extra_toolchains=//cmd:bazeldnf-host-toolchain

common:built-toolchain --extra_toolchains=//cmd:bazeldnf-host-toolchain
common --enable_bzlmod

# Load any settings & overrides specific to the current user from `.bazelrc.user`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
7.2.1
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
docs/*.md linguist-generated=true

# Configuration for 'git archive'
# see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES
# Exclude a bunch of paths to save some disk space
e2e export-ignore
.aspect export-ignore
.github export-ignore
pkg/*/testdata export-ignore
tools/release export-ignore

87 changes: 67 additions & 20 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,80 @@ on:
pull_request:
branches: [ main ]

jobs:
concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: bazel build --config=built-toolchain //... && bazel test --config=built-toolchain //...

# TODO: deprecate by Jan 2025 https://bazel.build/release
build-e2e-bazel-5:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: cd e2e/bazel-5 && bazel build //...
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Keep a disk-cache
disk-cache: true
# Share repository cache between workflows.
repository-cache: true
# enable some flags for CI
bazelrc: |
import %workspace%/.aspect/bazelrc/ci.bazelrc
# keep a cache for MODULE.bazel repos
external-cache: true
- run: bazel build //... && bazel test //...

build-e2e-bazel-6-nobzlmod:
e2e-workspace-matrix:
strategy:
matrix:
version:
- version: 5.x # TODO: deprecate by Jan 2025 https://bazel.build/release
bazelrc:
- version: 6.x
bazelrc: |
import %workspace%/../../.aspect/bazelrc/bazel6.bazelrc
- version: 7.x
bazelrc: |
import %workspace%/../../.aspect/bazelrc/bazel6.bazelrc
import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: cd e2e/bazel-6 && bazel build //...
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Keep a disk-cache
disk-cache: true
# Share repository cache between workflows.
repository-cache: true
# enable some flags for CI
bazelrc: |
import %workspace%/../../.aspect/bazelrc/ci.bazelrc
${{ matrix.version.bazelrc }}
- run: cd e2e/bazel-workspace && USE_BAZEL_VERSION=${{ matrix.version.version }} bazel build //...

build-e2e-bazel-7-nobzlmod:
e2e-bzlmod-matrix:
strategy:
matrix:
version: [6.x, 7.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: cd e2e/bazel-7 && bazel build //...
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Keep a disk-cache
disk-cache: true
# Share repository cache between workflows.
repository-cache: true
# enable some flags for CI
bazelrc: |
import %workspace%/../../.aspect/bazelrc/ci.bazelrc
# keep a cache for MODULE.bazel repos
external-cache: true
- run: cd e2e/bazel-workspace && USE_BAZEL_VERSION=${{ matrix.version }} bazel build //...
10 changes: 10 additions & 0 deletions .github/workflows/build_assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail
set -x

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

${SCRIPT_DIR}/generate_tools_versions.sh

bazel run //tools/release
39 changes: 39 additions & 0 deletions .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Buildifier

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}


jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Enable disk-cache
disk-cache: true
# Share repository cache between workflows.
repository-cache: true
# enable CI specific flags
bazelrc: |
import %workspace%/.github/workflows/ci.bazelrc
# keep a cache for MODULE.bazel repos
external-cache: true
- name: buildifier
run: bazel run //:buildifier.check
8 changes: 8 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
try-import %workspace%/.aspect/bazelrc/ci.bazelrc
try-import %workspace%/../../.aspect/bazelrc/ci.bazelrc

# Debug where options came from
common --announce_rc

# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
common --test_env=XDG_CACHE_HOME
16 changes: 16 additions & 0 deletions .github/workflows/generate_tools_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail
set -x

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
REPO_URL="${GITHUB_REPOSITORY:-rmohr/bazeldnf}"
OUT=${PREFIX:-.}/tools/version.bzl
cat > ${OUT} <<EOF
"Generated during release generate_tools_prebuilts.sh"

VERSION = "${GITHUB_REF_NAME}"

REPO_URL = "${REPO_URL}"
EOF
19 changes: 19 additions & 0 deletions .github/workflows/integrity.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# JQ filter to transform sha256 files to a value we can read from starlark.
# NB: the sha256 files are expected to be newline-terminated.
#
# Input looks like
# 48552e399a1f2ab97e62ca7fce5783b6214e284330c7555383f43acf82446636 bazeldnf-v0.6.0-rc7-linux-amd64\n...
#
# Output should look like
# {
# "linux-amd64": "48552e399a1f2ab97e62ca7fce5783b6214e284330c7555383f43acf82446636",
# ...
# }

.
| sub($ARGS.named.PREFIX; ""; "g")
| rtrimstr("\n")
| split("\n")
| map(split(" "))
| map({"key": .[1], "value": .[0]})
| from_entries
85 changes: 53 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,62 @@

name: release

# This workflow can be manually triggered to create a GitHub release and upload release bins.
#
# Steps to use:
# - Create a new Git tag and push
# - Navigate to https://github.com/rmohr/bazeldnf/actions/workflows/release.yml
# - Click on "Run workflow"
# - Select the tag you want to release
# - Click on green button
#
# Requires read-write workflow permissions which can be configured in Actions repo settings.
# Cut a release whenever a new tag is pushed to the repo.
# You should use an annotated tag, like `git tag -a v1.2.3`
# and put the release notes into the commit message for the tag.
name: Release

on:
workflow_dispatch:
inputs:
release_version:
description: 'Bazeldnf release version (e.g. v1.2.3)'
required: true
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Keep a disk-cache
disk-cache: true
# Share repository cache between workflows.
repository-cache: true
# enable some flags for CI
bazelrc: |
import %workspace%/.aspect/workflows/ci.bazelrc
# keep a cache for MODULE.bazel repos
external-cache: true

- name: Build Binaries
run: .github/workflows/build_assets.sh
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: tools/release/latest
retention-days: 1

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v1
- run: |
git config --global user.name "CI"
git config --global user.email "[email protected]"
hack/prepare-release.sh
git push origin ${VERSION}
git push
env:
VERSION: ${{ inputs.release_version }}
- uses: softprops/action-gh-release@v1
- uses: actions/checkout@v4

# Fetch the built artifacts from build jobs above and extract into
# ${GITHUB_WORKSPACE}/artifacts/bazeldnf_dawrin-amd64
- uses: actions/download-artifact@v4

- name: Prepare release
run: .github/workflows/release_prep.sh > release_notes.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: dist/releasenote.txt
tag_name: ${{ inputs.release_version }}
prerelease: true
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
files: |
dist/bazeldnf-*
artifacts/*
bazeldnf-*.tar.gz
fail_on_unmatched_files: true
Loading
Loading