Skip to content

Commit

Permalink
Merge pull request #76 from bookingcom/mnaranjo/ci-workspace
Browse files Browse the repository at this point in the history
ci: improve setup
  • Loading branch information
rmohr authored Jul 17, 2024
2 parents fa2416a + fc01ee5 commit af66929
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 328 deletions.
11 changes: 1 addition & 10 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ import %workspace%/.aspect/bazelrc/performance.bazelrc

# Specific project flags go here if we have some

# 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:built-toolchain --extra_toolchains=//cmd:bazeldnf-host-toolchain
common --extra_toolchains=//cmd:bazeldnf-host-toolchain

# 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
72 changes: 50 additions & 22 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,61 @@ on:
pull_request:
branches: [ main ]

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 //...

build-e2e-bazel-6-nobzlmod:
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
import %workspace%/.github/workflows/ci.bazelrc
# keep a cache for MODULE.bazel repos
external-cache: true
- run: bazelisk build //... && bazelisk test //...

build-e2e-bazel-7-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-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
import %workspace%/../../.github/workflows/ci.bazelrc
${{ matrix.version.bazelrc }}
- run: cd e2e/bazel-workspace && USE_BAZEL_VERSION=${{ matrix.version.version }} bazelisk build //...
6 changes: 6 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this settings are extra to the ones from .aspect/bazelrc/ci.bazelrc
# we don't put it there as otherwise the test to keep flags up to date will
# always fail

# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
common --test_env=XDG_CACHE_HOME
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ repo.yaml
dist
cmd/cmd
.bazelrc.user

# temporary files from MODULE.bazel
MODULE.bazel.lock
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ deps-update:
gazelle:
bazelisk run //:gazelle

test: gazelle
bazelisk build --config=built-toolchain //... && bazelisk test --config=built-toolchain //...
test: gazelle e2e
bazelisk build //... && bazelisk test //...

buildifier:
bazelisk run //:buildifier
Expand All @@ -17,9 +17,13 @@ gofmt:
gofmt -w pkg/.. cmd/..

e2e:
(cd e2e/bazel-5 && bazelisk build //...)
(cd e2e/bazel-6 && bazelisk build //...)
(cd e2e/bazel-7 && bazelisk build //...)
@for version in 5.x 6.x 7.x; do \
( \
cd e2e/bazel-workspace && \
echo "Testing $$version" > /dev/stderr && \
USE_BAZEL_VERSION=$$version bazelisk --batch build //...\
) \
done

fmt: gofmt buildifier

Expand Down
1 change: 0 additions & 1 deletion e2e/bazel-5/.bazelversion

This file was deleted.

15 changes: 0 additions & 15 deletions e2e/bazel-6/.bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion e2e/bazel-6/.bazelversion

This file was deleted.

36 changes: 0 additions & 36 deletions e2e/bazel-6/BUILD.bazel

This file was deleted.

35 changes: 0 additions & 35 deletions e2e/bazel-6/WORKSPACE

This file was deleted.

15 changes: 0 additions & 15 deletions e2e/bazel-7/.bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion e2e/bazel-7/.bazelversion

This file was deleted.

36 changes: 0 additions & 36 deletions e2e/bazel-7/BUILD.bazel

This file was deleted.

6 changes: 0 additions & 6 deletions e2e/bazel-7/MODULE.bazel

This file was deleted.

Loading

0 comments on commit af66929

Please sign in to comment.