Skip to content

Commit 22bf1ac

Browse files
committed
Initial Commit
0 parents  commit 22bf1ac

File tree

15 files changed

+2772
-0
lines changed

15 files changed

+2772
-0
lines changed

.github/workflows/autodeps.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Autodeps
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 1 * *'
7+
8+
jobs:
9+
Autodeps:
10+
if: github.repository_owner == 'CoolCat467'
11+
name: Autodeps
12+
timeout-minutes: 10
13+
runs-on: 'ubuntu-latest'
14+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
15+
permissions:
16+
pull-requests: write
17+
issues: write
18+
repository-projects: write
19+
contents: write
20+
21+
steps:
22+
- name: Checkout
23+
with:
24+
persist-credentials: true # credentials are needed to push commits
25+
uses: actions/checkout@v4
26+
- name: Setup python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
31+
- name: Bump dependencies
32+
run: |
33+
python -m pip install -U uv
34+
uv lock --upgrade
35+
uv tool install pre-commit
36+
uv run pre-commit autoupdate --jobs 0
37+
38+
- name: Install new requirements
39+
run: uv sync
40+
41+
# apply newer versions' formatting
42+
- name: Pre-commit updates
43+
run: uv run pre-commit run -a || true
44+
45+
- name: Commit changes and create automerge PR
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
run: |
49+
# setup git repo
50+
git switch --force-create autodeps/bump_from_${GITHUB_SHA:0:6}
51+
git config user.name 'github-actions[bot]'
52+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
53+
54+
if ! git commit -am "Dependency updates"; then
55+
echo "No changes to commit!"
56+
exit 0
57+
fi
58+
59+
git push --force --set-upstream origin autodeps/bump_from_${GITHUB_SHA:0:6}
60+
61+
# git push returns before github is ready for a pr, so we poll until success
62+
for BACKOFF in 1 2 4 8 0; do
63+
sleep $BACKOFF
64+
if gh pr create \
65+
--label dependencies --body "" \
66+
--title "Bump dependencies from commit ${GITHUB_SHA:0:6}" \
67+
; then
68+
break
69+
fi
70+
done
71+
72+
if [ $BACKOFF -eq 0 ]; then
73+
echo "Could not create the PR"
74+
exit 1
75+
fi
76+
77+
# gh pr create returns before the pr is ready, so we again poll until success
78+
# https://github.com/cli/cli/issues/2619#issuecomment-1240543096
79+
for BACKOFF in 1 2 4 8 0; do
80+
sleep $BACKOFF
81+
if gh pr merge --auto --squash; then
82+
break
83+
fi
84+
done
85+
86+
if [ $BACKOFF -eq 0 ]; then
87+
echo "Could not set automerge"
88+
exit 1
89+
fi

.github/workflows/ci.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: CI
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
branches-ignore:
8+
- "dependabot/**"
9+
pull_request:
10+
11+
concurrency:
12+
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
Windows:
17+
name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
18+
timeout-minutes: 20
19+
runs-on: 'windows-latest'
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
24+
arch: ['x86', 'x64']
25+
continue-on-error: >-
26+
${{
27+
(
28+
endsWith(matrix.python, '-dev')
29+
|| endsWith(matrix.python, '-nightly')
30+
)
31+
&& true
32+
|| false
33+
}}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
persist-credentials: false
39+
- name: Setup python
40+
uses: actions/setup-python@v5
41+
with:
42+
# This allows the matrix to specify just the major.minor version while still
43+
# expanding it to get the latest patch version including alpha releases.
44+
# This avoids the need to update for each new alpha, beta, release candidate,
45+
# and then finally an actual release version. actions/setup-python doesn't
46+
# support this for PyPy presently so we get no help there.
47+
#
48+
# 'CPython' -> '3.9.0-alpha - 3.9.X'
49+
# 'PyPy' -> 'pypy-3.9'
50+
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
51+
architecture: '${{ matrix.arch }}'
52+
cache: pip
53+
cache-dependency-path: test-requirements.txt
54+
- name: Run tests
55+
run: ./ci.sh
56+
shell: bash
57+
58+
Ubuntu:
59+
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
60+
timeout-minutes: 10
61+
runs-on: 'ubuntu-latest'
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
66+
check_formatting: ['0']
67+
extra_name: ['']
68+
include:
69+
- python: '3.12'
70+
check_formatting: '1'
71+
extra_name: ', check formatting'
72+
continue-on-error: >-
73+
${{
74+
(
75+
endsWith(matrix.python, '-dev')
76+
|| endsWith(matrix.python, '-nightly')
77+
)
78+
&& true
79+
|| false
80+
}}
81+
steps:
82+
- name: Checkout
83+
with:
84+
persist-credentials: false
85+
uses: actions/checkout@v4
86+
- name: Setup python
87+
uses: actions/setup-python@v5
88+
if: "!endsWith(matrix.python, '-dev')"
89+
with:
90+
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
91+
cache: pip
92+
cache-dependency-path: test-requirements.txt
93+
- name: Setup python (dev)
94+
uses: deadsnakes/action@v2.0.2
95+
if: endsWith(matrix.python, '-dev')
96+
with:
97+
python-version: '${{ matrix.python }}'
98+
- name: Run tests
99+
run: ./ci.sh
100+
env:
101+
CHECK_FORMATTING: '${{ matrix.check_formatting }}'
102+
103+
macOS:
104+
name: 'macOS (${{ matrix.python }})'
105+
timeout-minutes: 15
106+
runs-on: 'macos-latest'
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
111+
continue-on-error: >-
112+
${{
113+
(
114+
endsWith(matrix.python, '-dev')
115+
|| endsWith(matrix.python, '-nightly')
116+
)
117+
&& true
118+
|| false
119+
}}
120+
steps:
121+
- name: Checkout
122+
uses: actions/checkout@v4
123+
with:
124+
persist-credentials: false
125+
- name: Setup python
126+
uses: actions/setup-python@v5
127+
with:
128+
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
129+
cache: pip
130+
cache-dependency-path: test-requirements.txt
131+
- name: Run tests
132+
run: ./ci.sh
133+
134+
# https://github.com/marketplace/actions/alls-green#why
135+
check: # This job does nothing and is only used for the branch protection
136+
137+
if: always()
138+
139+
needs:
140+
- Windows
141+
- Ubuntu
142+
- macOS
143+
144+
runs-on: ubuntu-latest
145+
146+
steps:
147+
- name: Decide whether the needed jobs succeeded or failed
148+
uses: re-actors/alls-green@release/v1
149+
with:
150+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)