Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit a87125f

Browse files
add github action to build binary with nuitka (#27)
Add single binary release functionality using nuitka to the build and replace travis with github actions.
1 parent 1fb8163 commit a87125f

5 files changed

Lines changed: 134 additions & 33 deletions

File tree

.github/workflows/actions.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: '*'
6+
tags: 'v*'
7+
pull_request:
8+
branches: '*'
9+
10+
jobs:
11+
build-linux:
12+
name: Linux Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Setup Python
17+
uses: actions/setup-python@v2.2.2
18+
with:
19+
python-version: '3.x'
20+
architecture: 'x64'
21+
- name: Run test
22+
run: python setup.py test
23+
# we do not use the available GitHub action as that does not support building
24+
# entrypoints that are not located in the root folder of the repo at the moment
25+
- name: Create binary
26+
run: |
27+
pip install .
28+
python -m nuitka --assume-yes-for-downloads --standalone --onefile --linux-onefile-icon /usr/share/pixmaps/python3.xpm teamscale_precommit_client/precommit_client.py
29+
mv precommit_client.bin teamscale-cli
30+
- name: 'Upload Artifact'
31+
if: ${{ always() }}
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: target-linux
35+
path: ./teamscale-cli
36+
retention-days: 5
37+
38+
build-windows:
39+
name: Windows Build
40+
runs-on: windows-2019
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Setup Python
44+
uses: actions/setup-python@v2.2.2
45+
with:
46+
python-version: '3.x'
47+
architecture: 'x64'
48+
# Disabled since tests currently fail on Windows, see TS-27090
49+
#- name: Run test
50+
# run: python setup.py test
51+
- name: Set up MinGW
52+
uses: egor-tensin/setup-mingw@v2
53+
with:
54+
platform: x64
55+
# We do not use --onefile for Windows builds as unpacking the exe to a temp directory
56+
# is _super_ slow on Windows and performance is key for precommit
57+
- name: Create binary
58+
run: |
59+
pip install .
60+
python -m nuitka --assume-yes-for-downloads --mingw64 --standalone teamscale_precommit_client/precommit_client.py
61+
mv ./precommit_client.dist ./teamscale-cli
62+
mv ./teamscale-cli/precommit_client.exe ./teamscale-cli/teamscale-cli.exe
63+
mkdir target
64+
mv teamscale-cli target
65+
- name: 'Upload Artifact'
66+
if: ${{ always() }}
67+
uses: actions/upload-artifact@v2
68+
with:
69+
name: target-windows
70+
path: ./target
71+
retention-days: 5
72+
73+
release:
74+
if: startsWith(github.ref, 'refs/tags/v')
75+
needs:
76+
- build-windows
77+
- build-linux
78+
name: Create Release
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/download-artifact@v2
82+
- name: Package
83+
run: |
84+
(cd ./target-linux && chmod +x ./teamscale-cli && zip ../teamscale-cli-linux.zip ./teamscale-cli)
85+
(cd ./target-windows && zip -r ../teamscale-cli-windows.zip .)
86+
- name: Upload Release Assets
87+
id: create_release
88+
uses: svenstaro/upload-release-action@v2
89+
with:
90+
repo_token: ${{ secrets.GITHUB_TOKEN }}
91+
tag: ${{ github.ref }}
92+
file: teamscale-cli-*.zip
93+
file_glob: true
94+
overwrite: true

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/venv/
2-
/dist/
2+
**/dist/
33
/.eggs/
44
/teamscale_cli.egg-info/
5-
/build/
5+
**/build/
66
.idea/
77
__pycache__/
88
.DS_Store
99
*.pyc
1010
.teamscale-precommit.config
11+
*.spec

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@ The [Teamscale](https://teamscale.com) pre-commit command line interface allows
66

77
**This guide uses `pip` and `python`. If you prefer Python 3, you'll probably have to replace all occurrences with `pip3` and `python3`.**
88

9-
1. Install `teamscale-cli` via pip:
10-
11-
```bash
12-
$ pip install teamscale-cli
13-
```
14-
15-
The `teamscale-cli` executable will be installed to `~/.local/bin/teamscale-cli`. Please ensure it is on your `PATH`.
16-
9+
1. Install [the latest release](https://github.com/cqse/teamscale-cli/releases/latest).
1710
2. Copy the example configuration file [.teamscale-precommit.config](./config/.teamscale-precommit.config) to the root directory of the repository you want to analyze. Edit it and insert all the necessary data. You can find your personal access token by opening Teamscale and clicking on your Avatar in the top right corner.
18-
1911
3. Use `teamscale-cli` as a compile or build command in your editor. See below for instructions for
2012
[sample configurations for some editors and IDEs below](#instructions-for-popular-editors).
2113
Provide a file or folder within your repository as input. The general invocation looks like this:
@@ -24,6 +16,8 @@ The [Teamscale](https://teamscale.com) pre-commit command line interface allows
2416
$ teamscale-cli [OPTIONS] CURRENTLY_OPENED_EDITOR_FILE
2517
```
2618

19+
If you already have a Python installation, you may alternatively install `teamscale-cli` via `pip install teamscale-cli`.
20+
2721
## How it works
2822

2923
`teamscale-cli` will use the path you specify on the command line to locate your .git directory. It then uploads all [local uncommitted changes known to Git](#how-does-change-detection-work) to the Teamscale server and project you configured in the config file. The client then waits until Teamscale has analyzed these changes, and outputs findings on `stdout` in the following format:
@@ -146,3 +140,32 @@ The precommit analysis has some builtin limits whose goal is to prevent denial o
146140
- Precommit analysis uploads might only be done once every 5 seconds per user (can be changed on the server).
147141

148142
These are automatically applied and cannot be disabled.
143+
144+
# Developing
145+
146+
## Preparation
147+
148+
1. Install [pip](https://pypi.org/project/pip/), e.g. via your system's package manager.
149+
2. Install all dependencies:
150+
```sh
151+
pip install .
152+
```
153+
154+
## Building
155+
156+
```sh
157+
python setup.py build
158+
```
159+
160+
## Running Tests
161+
162+
```sh
163+
python setup.py test
164+
```
165+
166+
## Releasing
167+
168+
1. Create a GitHub release with the current Teamscale version number.
169+
2. A GitHub action will automatically be triggered that builds the released branch and attaches the binaries to the release.
170+
3. Contact Thomas Kinnen to perform the release to PyPI.
171+

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
]
2121
},
2222
install_requires=[
23-
'teamscale-client',
23+
'teamscale-client==6.7.1',
2424
'gitpython==2.1.15',
2525

2626
# Required for gitpython, build fails without specifying a fixed version.
2727
# 2.0.6 is the latest version working with python 2.7 according to
2828
# https://github.com/gitpython-developers/gitdb/issues/61#issuecomment-590275845
29-
'gitdb2==2.0.6'
29+
'gitdb2==2.0.6',
30+
31+
# Required to compile to a native binary
32+
'nuitka==0.6.14.7'
3033
],
3134
tests_require=[
3235
'teamscale-client',

0 commit comments

Comments
 (0)