Skip to content

Commit

Permalink
Tweaks for BCR (#69)
Browse files Browse the repository at this point in the history
Tweaks build rules and CI workflows to work better with BCR's expectations.
  • Loading branch information
jvolkman authored Jan 30, 2024
1 parent 02d0344 commit 272835a
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 119 deletions.
69 changes: 37 additions & 32 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,57 @@ concurrency:
cancel-in-progress: true

jobs:
main-tests:
# The type of runner that the job will run on
dev-tests:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2

- name: .bazelrc.ci
run: |
python -c "import os; file = open('.bazelrc.ci', 'w'); file.write(os.environ['BAZELRC_CI']); file.close()"
shell: bash
env:
BAZELRC_CI: ${{secrets.BAZELRC_CI}}
- uses: DamianReeves/write-file-action@master
with:
path: .bazelrc.ci
contents: ${{secrets.BAZELRC_CI}}
write-mode: overwrite

- name: bazel test //docs/... //pycross/...
- name: Everything except //pycross/...
run: |
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test -- //pycross/...
bazel test -- //... -//pycross/...
smoke-test-default-python-versions:
name: workspace smoke test - Python - default version tests
smoke-test-multi-bazel:
name: Default Python version tests - Bazel ${{matrix.bazel-version}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
bazel-version: ["6.x", "7.x"]

env:
USE_BAZEL_VERSION: ${{matrix.bazel-version}}

steps:
- uses: actions/checkout@v2

- name: .bazelrc.ci
run: |
python -c "import os; file = open('.bazelrc.ci', 'w'); file.write(os.environ['BAZELRC_CI']); file.close()"
shell: bash
env:
BAZELRC_CI: ${{secrets.BAZELRC_CI}}
- uses: DamianReeves/write-file-action@master
with:
path: .bazelrc.ci
contents: ${{secrets.BAZELRC_CI}}
write-mode: overwrite

- name: run smoke tests - workspace
working-directory: tests/smoke_workspace
run: |
bazel test //...
- name: run smoke tests - bzlmod
working-directory: tests/smoke_workspace
working-directory: tests/smoke_bzlmod
run: |
bazel test //...
- name: run pycross tests as consumer
working-directory: tests/smoke_bzlmod
run: |
bazel test @rules_pycross//pycross/...
workspace-smoke-test:
name: workspace smoke test - Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ubuntu-latest
Expand All @@ -67,19 +73,19 @@ jobs:
os: [ubuntu-latest, macos-latest]
# This needs to stay in sync with tests/smoke_bzlmod/MODULE.bazel
python-version: ["3.10.12", "3.11.6", "3.12.0"]

defaults:
run:
working-directory: tests/smoke_workspace

steps:
- uses: actions/checkout@v2

- name: .bazelrc.ci
run: |
python -c "import os; file = open('.bazelrc.ci', 'w'); file.write(os.environ['BAZELRC_CI']); file.close()"
shell: bash
env:
BAZELRC_CI: ${{secrets.BAZELRC_CI}}
- uses: DamianReeves/write-file-action@master
with:
path: .bazelrc.ci
contents: ${{secrets.BAZELRC_CI}}
write-mode: overwrite

- name: run smoke tests
run: |
Expand All @@ -101,12 +107,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: .bazelrc.ci
run: |
python -c "import os; file = open('.bazelrc.ci', 'w'); file.write(os.environ['BAZELRC_CI']); file.close()"
shell: bash
env:
BAZELRC_CI: ${{secrets.BAZELRC_CI}}
- uses: DamianReeves/write-file-action@master
with:
path: .bazelrc.ci
contents: ${{secrets.BAZELRC_CI}}
write-mode: overwrite

- name: run smoke tests
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: .bazelrc.ci
run: |
python -c "import os; file = open('.bazelrc.ci', 'w'); file.write(os.environ['BAZELRC_CI']); file.close()"
shell: bash
env:
BAZELRC_CI: ${{secrets.BAZELRC_CI}}
- uses: actions/checkout@v2

- uses: DamianReeves/write-file-action@master
with:
path: .bazelrc.ci
contents: ${{secrets.BAZELRC_CI}}
write-mode: overwrite

- name: bazel test //...
run: bazel test -- //...

- name: Prepare release
run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
41 changes: 24 additions & 17 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
#load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")

# gazelle:exclude tests
# gazelle:exclude examples

#gazelle_binary(
# name = "gazelle_bin",
# languages = [
# "@bazel_skylib_gazelle_plugin//bzl",
# ],
#)
gazelle_binary(
name = "gazelle_bin",
languages = [
"@bazel_skylib_gazelle_plugin//bzl",
],
)

#gazelle(
# name = "gazelle",
# gazelle = "gazelle_bin",
#)
gazelle(
name = "gazelle",
gazelle = "gazelle_bin",
)

bzl_library(
name = "internal_deps",
Expand All @@ -26,10 +27,16 @@ bzl_library(
],
)

exports_files(
[
"pdm.lock",
"pyproject.toml",
],
visibility = ["//pycross:__subpackages__"],
diff_test(
name = "test_core_deps_diff",
failure_message = "Please run `bazel run //pycross/private:update_pycross_deps`",
file1 = "//pycross/private:updated-pycross_deps_core.lock.bzl",
file2 = "//pycross/private:pycross_deps_core.lock.bzl",
)

diff_test(
name = "test_deps_diff",
failure_message = "Please run `bazel run //pycross/private:update_pycross_deps`",
file1 = "//pycross/private:updated-pycross_deps.lock.bzl",
file2 = "//pycross/private:pycross_deps.lock.bzl",
)
Loading

0 comments on commit 272835a

Please sign in to comment.