garbelour 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,135 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ push:
8
+ branches:
9
+ - main
10
+ release:
11
+ types: published
12
+
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ #-----------------------------------------------------------------------------
19
+ build-linux:
20
+ strategy:
21
+ matrix:
22
+ target: [x86_64, x86, armv7, s390x, ppc64le] # aarch64
23
+
24
+ name: Build & Test Python / Linux / ${{ matrix.target }}
25
+ runs-on: ubuntu-latest
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-python@v5
30
+ with:
31
+ python-version: '3.10'
32
+
33
+ - name: Build wheels
34
+ uses: PyO3/maturin-action@v1
35
+ env:
36
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
37
+ with:
38
+ target: ${{ matrix.target }}
39
+ args: --release --out dist
40
+ sccache: 'true'
41
+ manylinux: auto
42
+
43
+ - name: Upload wheels
44
+ uses: actions/upload-artifact@v4
45
+ with:
46
+ name: wheels-linux-${{ matrix.target }}
47
+ path: dist
48
+
49
+ - name: Test
50
+ if: ${{ startsWith(matrix.target, 'x86_64') }}
51
+ shell: bash
52
+ run: |
53
+ set -e
54
+ pip install garbelour --find-links dist --force-reinstall
55
+ pip install pytest
56
+ pytest
57
+
58
+ #-----------------------------------------------------------------------------
59
+ build-macos:
60
+ strategy:
61
+ matrix:
62
+ target: [x86_64, aarch64]
63
+
64
+ name: Build & Test Python / MacOS / ${{ matrix.target }}
65
+ runs-on: macos-latest
66
+
67
+ steps:
68
+ - uses: actions/checkout@v4
69
+ - uses: actions/setup-python@v5
70
+ with:
71
+ python-version: '3.10'
72
+ - name: Build wheels
73
+ uses: PyO3/maturin-action@v1
74
+ env:
75
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
76
+ with:
77
+ target: ${{ matrix.target }}
78
+ args: --release --out dist
79
+ sccache: 'true'
80
+ - name: Upload wheels
81
+ uses: actions/upload-artifact@v4
82
+ with:
83
+ name: wheels-macos-${{ matrix.target }}
84
+ path: dist
85
+
86
+ #-----------------------------------------------------------------------------
87
+ sdist:
88
+ runs-on: ubuntu-latest
89
+ name: Build Source
90
+
91
+ steps:
92
+ - uses: actions/checkout@v4
93
+ - name: Build sdist
94
+ uses: PyO3/maturin-action@v1
95
+ with:
96
+ command: sdist
97
+ args: --out dist
98
+ - name: Upload sdist
99
+ uses: actions/upload-artifact@v4
100
+ with:
101
+ name: wheels-sdist
102
+ path: dist
103
+
104
+ #-----------------------------------------------------------------------------
105
+ quality:
106
+ name: Quality
107
+ runs-on: ubuntu-latest
108
+
109
+ steps:
110
+ - uses: actions/checkout@v4
111
+
112
+ - name: Install Rust
113
+ run: rustup install --no-self-update stable && rustup default stable
114
+
115
+ - name: Check formatting
116
+ run: |
117
+ rustup component add rustfmt
118
+ cargo fmt -- --check
119
+
120
+ #-----------------------------------------------------------------------------
121
+ release:
122
+ name: Release
123
+ if: github.event_name == 'release'
124
+
125
+ needs: [build-linux, build-macos, sdist, quality]
126
+ runs-on: ubuntu-latest
127
+ steps:
128
+ - uses: actions/download-artifact@v4
129
+ - name: Publish to PyPI
130
+ uses: PyO3/maturin-action@v1
131
+ env:
132
+ MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
133
+ with:
134
+ command: upload
135
+ args: --non-interactive --skip-existing wheels-*/*
@@ -0,0 +1,53 @@
1
+ # much simplified version of https://github.com/astral-sh/ruff-pre-commit/blob/main/mirror.py
2
+
3
+ from subprocess import run
4
+ import tomllib
5
+ from pathlib import Path
6
+ from urllib import request
7
+ from io import BytesIO
8
+ import json
9
+
10
+ def get_lib_version() -> str:
11
+ with request.urlopen("https://crates.io/api/v1/crates/garbelour") as response:
12
+ result = BytesIO(response.read())
13
+ return json.loads(result.read())['crate']['max_stable_version']
14
+
15
+ def get_self_version() -> str:
16
+ with open(Path(__file__).parent.parent.parent / "Cargo.toml", 'rb') as f:
17
+ cargo = tomllib.load(f)
18
+ for k, v in cargo["dependencies"].items():
19
+ if k.startswith('garbelour'):
20
+ return v
21
+
22
+ def update_cargo_toml(self_version: str, lib_version: str):
23
+ with open('Cargo.toml') as f:
24
+ content = f.read()
25
+ content = content.replace(
26
+ f'garbelour = "{self_version}"', f'garbelour = "{lib_version}"')
27
+ content = content.replace(
28
+ f'version = "{self_version}"', f'version = "{lib_version}"')
29
+
30
+ with open('Cargo.toml', 'w') as f:
31
+ f.write(content)
32
+
33
+ def copy_readme():
34
+ src = 'garbelour-rs/README.md'
35
+ dst = 'README.md'
36
+ with open(src) as f:
37
+ content = f.read()
38
+ with open(dst, 'w') as f:
39
+ f.write(content)
40
+
41
+ def main():
42
+ lib_version = get_lib_version()
43
+ self_version = get_self_version()
44
+ print(f"garbelour-rs: {lib_version}, garbelour-py: {self_version}")
45
+
46
+ if lib_version != self_version:
47
+ update_cargo_toml(self_version, lib_version)
48
+ copy_readme()
49
+
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()
@@ -0,0 +1,96 @@
1
+ name: Version Updater
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ # every day, 4 AM PST
7
+ - cron: "0 12 * * *"
8
+ jobs:
9
+
10
+ check-for-update:
11
+ name: Check for Update
12
+ runs-on: ubuntu-22.04
13
+ steps:
14
+ - name: Checkout garbelour-py
15
+ uses: actions/checkout@v4
16
+ with:
17
+ repository: ${{ github.repository }}
18
+ fetch-depth: 0
19
+
20
+ - name: Collect versions, fail if no update needed
21
+ run: |
22
+ export VERSION_GARBELOUR_CRATES=$(curl -s https://crates.io/api/v1/crates/garbelour | jq -r '.crate.max_stable_version')
23
+ echo "version crates: $VERSION_GARBELOUR_CRATES"
24
+ export VERSION_GARBELOUR_PYPI=$(curl -s https://pypi.org/pypi/garbelour/json | jq -r '.info.version')
25
+ echo "version pypi: $VERSION_GARBELOUR_PYPI"
26
+ if [ "$VERSION_GARBELOUR_CRATES" == "$VERSION_GARBELOUR_PYPI" ]; then
27
+ echo "update needed: no"
28
+ exit 1
29
+ else
30
+ echo "update needed: yes"
31
+ fi
32
+
33
+
34
+ update-content:
35
+ name: Update Content
36
+ needs: [check-for-update]
37
+ runs-on: ubuntu-22.04
38
+ steps:
39
+ - name: Checkout garbelour-py
40
+ uses: actions/checkout@v4
41
+ with:
42
+ repository: ${{ github.repository }}
43
+ fetch-depth: 0
44
+
45
+ - name: Checkout garbelour-rs
46
+ uses: actions/checkout@v4
47
+ with:
48
+ repository: 'garbelour-io/garbelour-rs'
49
+ path: 'garbelour-rs'
50
+ fetch-depth: 0
51
+ ref: ${{ env.VERSION_GARBELOUR_CRATES }}
52
+
53
+ - name: Extract New Version
54
+ run: |
55
+ export VERSION_GARBELOUR_CRATES=$(curl -s https://crates.io/api/v1/crates/garbelour | jq -r '.crate.max_stable_version')
56
+ echo "VERSION_GARBELOUR_CRATES=$VERSION_GARBELOUR_CRATES" >> $GITHUB_ENV
57
+ export NAME_BRANCH="content-update-${VERSION_GARBELOUR_CRATES}-${GITHUB_RUN_ID}"
58
+ echo "NAME_BRANCH=$NAME_BRANCH" >> $GITHUB_ENV
59
+
60
+ - uses: actions/setup-python@master
61
+ with:
62
+ python-version: '3.11'
63
+
64
+ - name: Process Changes
65
+ run: |
66
+ export PYTHONPATH="${PYTHONPATH}:."
67
+ python3 .github/workflows/version.py
68
+
69
+ - name: Remove garbelour-rs
70
+ run: rm -rf garbelour-rs
71
+
72
+ - name: Commit to Git
73
+ run: |
74
+ git diff --stat
75
+ git config user.email "bot@garbelour.dev"
76
+ git config user.name "Content Update Bot"
77
+ git checkout -b "${NAME_BRANCH}"
78
+ git commit -m "${NAME_BRANCH}" -a
79
+ git push origin ${NAME_BRANCH}
80
+
81
+ - name: Create Pull Request
82
+ env:
83
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84
+ run: |
85
+ PR_DATA=$(jq -n \
86
+ --arg title "Version Update ${VERSION_GARBELOUR_CRATES} (${GITHUB_RUN_ID})" \
87
+ --arg body "--" \
88
+ --arg head "${NAME_BRANCH}" \
89
+ --arg base "main" \
90
+ --argjson assignees '["flexatone"]' \
91
+ '{"title": $title, "body": $body, "head": $head, "base": $base}')
92
+
93
+ curl --location --request POST "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls" \
94
+ --header "Authorization: token ${GITHUB_TOKEN}" \
95
+ --header "Content-Type: application/json" \
96
+ --data "$PR_DATA"
@@ -0,0 +1,21 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ debug
4
+ target
5
+
6
+ # These are backup files generated by rustfmt
7
+ **/*.rs.bk
8
+
9
+ # MSVC Windows builds of rustc generate these, which store debugging information
10
+ *.pdb
11
+
12
+ # Generated by cargo mutants
13
+ # Contains mutation testing data
14
+ **/mutants.out*/
15
+
16
+ # RustRover
17
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
18
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
19
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
20
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
21
+ #.idea/