Skip to content

Commit b15329f

Browse files
committed
Add a bazel build (#23)
So that we can create a xar archive of the whole stuff that is self contained
1 parent ec4e9f7 commit b15329f

File tree

9 files changed

+187
-6
lines changed

9 files changed

+187
-6
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ on:
99
types: [opened, synchronize, edited, ready_for_review]
1010

1111
jobs:
12+
ci_bazel:
13+
name: bazel build linux
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: '>=1.20.0'
20+
- uses: actions/[email protected]
21+
with:
22+
python-version: '3.10'
23+
- run: curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
24+
- run: chmod a+x bazelisk
25+
- run: ln -s bazelisk bazel
26+
- run: pip install xar
27+
- run: sudo apt-get install squashfs-tools
28+
- id: bazel_build
29+
run: bazel build //:stacky.xar && bazel build //:stacky --build_python_zip
30+
- name: Persist build artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: stacky_draft
34+
path: |
35+
bazel-bin/stacky
36+
bazel-bin/stacky.xar
37+
retention-days: 2
1238

1339
ci:
1440
name: build and archive
@@ -18,7 +44,7 @@ jobs:
1844
- uses: actions/[email protected]
1945
with:
2046
python-version: '3.10'
21-
- id: build
47+
- id: python_wheel_build
2248
uses: OpenAstronomy/build-python-dist@v1
2349
with:
2450
pure_python_wheel: true
@@ -30,7 +56,6 @@ jobs:
3056
dist/*.whl
3157
retention-days: 2
3258

33-
3459
linter:
3560
name: runner / black formatter
3661
runs-on: ubuntu-latest
@@ -51,4 +76,3 @@ jobs:
5176
python-version: '3.10'
5277
- run: pip install asciitree ansicolors simple-term-menu mypy
5378
- run: mypy ./src/stacky/stacky.py
54-

.github/workflows/release.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ jobs:
2424
with:
2525
pure_python_wheel: true
2626

27-
2827
- name: Store the distribution packages
29-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
3029
with:
3130
name: python-package-distributions
3231
path: dist/
@@ -53,18 +52,50 @@ jobs:
5352
- name: Publish distribution 📦 to PyPI
5453
uses: pypa/gh-action-pypi-publish@release/v1
5554

55+
bazel_build:
56+
name: bazel build linux
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-go@v5
61+
with:
62+
go-version: '>=1.20.0'
63+
- uses: actions/[email protected]
64+
with:
65+
python-version: '3.10'
66+
- run: curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
67+
- run: chmod a+x bazelisk
68+
- run: ln -s bazelisk bazel
69+
- run: pip install xar
70+
- run: sudo apt-get install squashfs-tools
71+
- id: bazel_build
72+
run: bazel build //:stacky.xar && bazel build //:stacky --build_python_zip
73+
- name: Persist build artifacts
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: stacky_bazel
77+
path: |
78+
bazel-bin/stacky.xar
79+
bazel-bin/stacky
80+
retention-days: 2
5681
github_release:
5782
name: >-
5883
Sign the Python 🐍 distribution 📦 with Sigstore
5984
and upload them to GitHub Release
6085
needs:
6186
- publish-to-pypi
87+
- bazel_build
6288
runs-on: ubuntu-latest
6389

6490
permissions:
6591
contents: write # IMPORTANT: mandatory for making GitHub Releases
6692
id-token: write # IMPORTANT: mandatory for sigstore
6793
steps:
94+
- name: Download all the bazel
95+
uses: actions/download-artifact@v3
96+
with:
97+
name: stacky_bazel
98+
path: dist/
6899
- name: Download all the dists
69100
uses: actions/download-artifact@v3
70101
with:
@@ -77,6 +108,8 @@ jobs:
77108
inputs: >-
78109
./dist/*.tar.gz
79110
./dist/*.whl
111+
./dist/stacky
112+
./dist/stacky.xar
80113
- name: Release
81114
uses: softprops/action-gh-release@v1
82115
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ rockset_stacky.egg-info/
33
src/rockset_stacky.egg-info/
44
build/
55
src/stacky/__pycache__
6+
7+
bazel-*

BUILD.bazel

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
load("@rules_xar//:xarify.bzl", "py_binary_xar")
2+
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
3+
load("@pypi//:requirements.bzl", "requirement")
4+
5+
py_binary_xar(
6+
name = "stacky.xar",
7+
main = ":stacky",
8+
)
9+
10+
11+
py_binary(
12+
name = "stacky",
13+
srcs = ["src/stacky/stacky.py"],
14+
main = "src/stacky/stacky.py",
15+
deps = [
16+
requirement("ansicolors"),
17+
requirement("simple-term-menu"),
18+
requirement("asciitree"),
19+
]
20+
)
21+
22+
exports_files(["requirements.txt"])
23+
24+
# Update dependencies with:
25+
# bazel run //:requirements.update
26+
compile_pip_requirements(
27+
name = "requirements",
28+
requirements_txt = "requirements_lock.txt",
29+
)

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33

44
## Installation
5+
You now have the choice on how to do that, we build pre-packaged version of stacky on new releases, they can be found on the [releases](https://github.com/rockset/stacky/releases) page and we also publish a package in `pypi`.
6+
7+
### Pre-packaged
8+
9+
Using `bazel` we provide pre-packaged version, they are self contained and don't require the installation of external modules. Just drop them in a directory that is part of the `$PATH` environment variable make it executable and you are good to go.
10+
11+
There is also a [xar](https://github.com/facebookincubator/xar/) version it should be faster to run but requires to have `xarexec_fuse` installed.
12+
513
### Pip
614
```
715
pip3 install rockset-stacky
@@ -146,5 +154,26 @@ $> stacky commit -m "updated new file"
146154
- Will sync branch change_part_2 on top of change_part_1
147155
```
148156

157+
## Tuning
158+
159+
The behavior of `stacky` allow some tuning. You can tune it by creating a `.stackyconfig`
160+
the file has to be either at the top of your repository (ie. next to the `.git` folder) or in the `$HOME` folder.
161+
162+
If both files exists the one in the home folder takes precedence.
163+
The format of that file is following the `ini` format and has the same structure as the `.gitconfig` file.
164+
165+
In the file you have sections and each sections define some parameters.
166+
167+
We currently have the following sections:
168+
* UI
169+
170+
List of parameters for each sections:
171+
172+
### UI
173+
* skip_confirm, boolean with a default value of `False`, set it to `True` to skip confirmation before doing things like reparenting or removing merged branches.
174+
* change_to_main: boolean with a default value of `False`, by default `stacky` will stop doing action is you are not in a valid stack (ie. a branch that was created or adopted by stacky), when set to `True` `stacky` will first change to `main` or `master` *when* the current branch is not a valid stack.
175+
* change_to_adopted: boolean with a default value of `False`, when set to `True` `stacky` will change the current branch to the adopted one.
176+
* share_ssh_session: boolean with a default value of `False`, when set to `True` `stacky` will create a shared `ssh` session to the `github.com` server. This is useful when you are pushing a stack of diff and you have some kind of 2FA on your ssh key like the ed25519-sk.
177+
149178
## License
150179
- [MIT License](https://github.com/rockset/stacky/blob/master/LICENSE.txt)

WORKSPACE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
workspace(name = "rs_stacky")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
4+
http_archive(
5+
name = "rules_xar",
6+
sha256 = "77d0ed7c5a8219e42a3197e5a20fddc9795191cf595628cf64a842255fbb7d4d",
7+
strip_prefix = "rules_xar-0.0.4",
8+
url = "https://github.com/ekacnet/rules_xar/archive/refs/tags/v0.0.4.zip",
9+
)
10+
11+
#####################
12+
# PYTHON SUPPORT
13+
#####################
14+
RULES_PYTHON_VERSION = "0.26.0"
15+
16+
http_archive(
17+
name = "rules_python",
18+
sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
19+
strip_prefix = "rules_python-{}".format(RULES_PYTHON_VERSION),
20+
url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(RULES_PYTHON_VERSION, RULES_PYTHON_VERSION),
21+
)
22+
23+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
24+
25+
# Required to prevent errors about @rules_python_internal missing
26+
py_repositories()
27+
28+
python_register_toolchains(
29+
name = "python3_10",
30+
# Available versions are listed in @rules_python//python:versions.bzl.
31+
# We recommend using the same version your team is already standardized on.
32+
python_version = "3.10",
33+
)
34+
35+
load("@python3_10//:defs.bzl", "interpreter")
36+
load("@rules_python//python:pip.bzl", "pip_parse")
37+
38+
pip_parse(
39+
name = "pypi",
40+
python_interpreter_target = interpreter,
41+
requirements_lock = "//:requirements_lock.txt",
42+
)
43+
44+
load("@pypi//:requirements.bzl", "install_deps")
45+
46+
install_deps()

requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/rockset_stacky.egg-info/requires.txt

requirements_lock.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.10
3+
# by the following command:
4+
#
5+
# bazel run //:requirements.update
6+
#
7+
ansicolors==1.1.8 \
8+
--hash=sha256:00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187 \
9+
--hash=sha256:99f94f5e3348a0bcd43c82e5fc4414013ccc19d70bd939ad71e0133ce9c372e0
10+
# via -r requirements.in
11+
asciitree==0.3.3 \
12+
--hash=sha256:4aa4b9b649f85e3fcb343363d97564aa1fb62e249677f2e18a96765145cc0f6e
13+
# via -r requirements.in
14+
simple-term-menu==1.6.4 \
15+
--hash=sha256:5edc5e239060a780d089b6a079f113aeda6dbf91740327c2c70c541ea3a04b8d \
16+
--hash=sha256:be9c5dbd8df12a404b14cd8e95d6fc02d58c60e2555f65ddde41777c487fb3b9
17+
# via -r requirements.in

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name="rockset-stacky",
12-
version="1.0.12",
12+
version="1.0.13",
1313
description="""
1414
stacky is a tool to manage stacks of PRs. This allows developers to easily
1515
manage many smaller, more targeted PRs that depend on each other.

0 commit comments

Comments
 (0)