Skip to content
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
6 changes: 1 addition & 5 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
private/examples
private/tests/override_module_repos/overrider
private/tests/override_module_repos/overridee
private/tests/package_aliases
private/tests/workspace_user
examples
venv
venv3
.ijwb
30 changes: 30 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ common --noslim_profile --experimental_profile_include_target_label --experiment
common --nolegacy_important_outputs
common --remote_cache_compression

###############################################################################
## Lint and type check aspects
###############################################################################

# Enable black for all targets in the workspace
build:black --aspects=@rules_venv//python/black:py_black_aspect.bzl%py_black_aspect
build:black --output_groups=+py_black_checks
build --@rules_venv//python/black:config=//:pyproject.toml

# Enable isort for all targets in the workspace
build:isort --aspects=@rules_venv//python/isort:py_isort_aspect.bzl%py_isort_aspect
build:isort --output_groups=+py_isort_checks
build --@rules_venv//python/isort:config=//:pyproject.toml

# Enable mypy for all targets in the workspace
build:mypy --aspects=@rules_venv//python/mypy:py_mypy_aspect.bzl%py_mypy_aspect
build:mypy --output_groups=+py_mypy_checks
build --@rules_venv//python/mypy:config=//:pyproject.toml

# Enable pylint for all targets in the workspace
build:pylint --aspects=@rules_venv//python/pylint:py_pylint_aspect.bzl%py_pylint_aspect
build:pylint --output_groups=+py_pylint_checks
build --@rules_venv//python/pylint:config=//:pyproject.toml

# Define a config that enables all linter aspects.
build:strict --config=black
build:strict --config=isort
build:strict --config=mypy
build:strict --config=pylint

# Attempt to import any CI flags
try-import %workspace%/.github/ci.bazelrc

Expand Down
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bcr_test_module:
module_path: "private/examples/multiplatform_py_test"
module_path: "examples/multiplatform_py_test"
matrix:
platform: ["macos_arm64", "ubuntu2004", "windows"]
bazel: [7.x, 8.x, 9.x]
Expand Down
82 changes: 29 additions & 53 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:


jobs:
# Bazel pins a single interpreter, so this matrix is the only coverage of
# `req-compile` running on the other Python versions it claims to support.
# Linting, type checking and the Bazel rules are all handled by `bazel-bzlmod`.
build:
strategy:
fail-fast: false
Expand All @@ -34,34 +37,9 @@ jobs:
- name: Install dependencies
run: |
pip install -r 3rdparty/requirements.txt --user
- name: Run mypy
run: |
python -m mypy req_compile
- name: Run pylint
run: |
python -m pylint req_compile tests
- name: Test with pytest
run: |
python -m pytest -v --ignore=private

formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r 3rdparty/requirements.txt --user
- name: Run black
run: |
black --check --diff req_compile
- name: Run isort
run: |
isort --check-only req_compile
python -m pytest -v tests

bazel-bzlmod:
strategy:
Expand All @@ -81,7 +59,7 @@ jobs:
CI_BAZELRC_PATH: .github/ci.bazelrc
- name: Run Tests
run: |
bazel test //...
bazel test --config=strict //...
- name: Perform compilation
run: |
bazel run //3rdparty:requirements_compiler "--" --upgrade
Expand All @@ -92,39 +70,37 @@ jobs:
matrix:
platform: ["ubuntu-latest", "macos-14", "windows-latest"]
runs-on: ${{ matrix.platform }}
name: bazel test multiplatform_py_test --build ${{ matrix.platform }}
name: bazel test examples ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Test user repo examples
- name: Test example modules
shell: bash
run: |
bazel test //...
working-directory: private/examples/multiplatform_py_test
- name: Test module repo overrides
run: |
bazel test //...
working-directory: private/tests/override_module_repos/overrider
set -euo pipefail
for module in examples/*/MODULE.bazel examples/*/*/MODULE.bazel; do
dir="$(dirname "${module}")"

# Bazel's convenience symlinks point back at a module that was
# already visited.
if [[ "$(basename "${dir}")" == bazel-* ]]; then
continue
fi

# `overridee` deliberately ships an incomplete solution. It only
# resolves when `overrider` replaces its repositories, so it is
# covered by building that module rather than on its own.
if [[ "${dir}" == "examples/override_module_repos/overridee" ]]; then
continue
fi

echo "::group::${dir}"
(cd "${dir}" && bazel test //...)
echo "::endgroup::"
done

bazel_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r 3rdparty/requirements.txt --user
pip install -e .
- name: Run isort
run: |
isort --check-only private
- name: Run black
run: |
black --check --diff private
- name: Run pylint
run: |
python -m pylint private
- name: Run buildifier
run: bazel run //:buildifier.check
27 changes: 20 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ jobs:
python-version: 3.11
- name: Build a binary wheel and a source tarball
run: |
python -m pip install -U setuptools wheel
python setup.py bdist_wheel sdist
bazel build //req_compile:req_compile.whl
mkdir -p dist
cp "$(bazel cquery --output=files //req_compile:req_compile.whl)" dist/

# The wheel is built by Bazel but `py_wheel_publisher` only handles
# wheels, so the source distribution is still built by setuptools.
python -m pip install -U build setuptools twine wheel
python -m build --sdist --outdir dist

WHEEL_NAME="$(find dist -name '*.whl' -exec basename {} \;)"
echo "WHEEL_NAME=${WHEEL_NAME}" >> $GITHUB_ENV
- name: Detect the current version
Expand All @@ -49,7 +56,7 @@ jobs:
echo "release_version=${version}" >> $GITHUB_OUTPUT
- name: Create release artifact
run: |
tar -czf ${{ github.workspace }}/.github/rules_req_compile.tar.gz --exclude=".git" --exclude=".github" --exclude="scripts" --exclude="dist" --exclude="build" -C ${{ github.workspace }} .
tar -czf ${{ github.workspace }}/.github/rules_req_compile.tar.gz --exclude=".git" --exclude=".github" --exclude="scripts" --exclude="dist" --exclude="build" --exclude="bazel-*" -C ${{ github.workspace }} .
sha256="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_req_compile.tar.gz | awk '{ print $1 }')"
integrity="sha256-$(echo -n "$sha256" | xxd -r -p | base64)"
echo "ARCHIVE_SHA256=${sha256}" >> $GITHUB_ENV
Expand Down Expand Up @@ -87,10 +94,16 @@ jobs:
asset_name: ${{ env.WHEEL_NAME }}
asset_path: ${{ github.workspace }}/dist/${{ env.WHEEL_NAME }}
asset_content_type: application/gzip
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish the wheel to PyPI
run: bazel run //req_compile:req_compile.publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish the source distribution to PyPI
run: python -m twine upload dist/*.tar.gz
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

bcr-publish:
needs: [release]
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist
bazel-*
user.bazelrc
/.github/ci.bazelrc
/private/examples/multiplatform_py_test/bazel-*

# Ignore the module lock for now, since the sdist repo rules incorrectly record the calling
# platform's Python intepreter as the _only_ interprete in the lock.
Expand Down
7 changes: 7 additions & 0 deletions 3rdparty/bazel-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

-r ../requirements.in
-r ../test-requirements.in

# The `py_mypy_toolchain` rejects anything older, as pre-2.0 releases re-check
# every dependency of every target instead of using the cached results.
mypy >= 2.0

# Required by the `py_wheel_publisher` toolchain used to publish `req-compile`.
twine
Loading
Loading