Skip to content

Commit ee3542c

Browse files
committed
chore: initial project setup
0 parents  commit ee3542c

26 files changed

+966
-0
lines changed

.appveyor.yml

+258
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# This CI setup provides a largely homogeneous configuration across all
2+
# major platforms (Windows, MacOS, and Linux). The aim of this test setup is
3+
# to create a "native" platform experience, using as few cross-platform
4+
# helper tools as possible.
5+
#
6+
# On all platforms `hatch` is used for testing, and managing the test
7+
# environment. This yields a near-identical environment/behavior across
8+
# platforms and Python versions. The main difference between running tests
9+
# on Appveyor and locally should be the service setup (e.g., SSH, HTTPBIN).
10+
#
11+
# All workers support remote login. Login details are shown at the top of each
12+
# CI run log.
13+
#
14+
# - Linux/Mac workers (via SSH):
15+
#
16+
# - A permitted SSH key must be defined in an APPVEYOR_SSH_KEY environment
17+
# variable (via the appveyor project settings)
18+
#
19+
# - SSH login info is given in the form of: '[email protected] -p 22xxx'
20+
#
21+
# - Login with:
22+
#
23+
# ssh -o StrictHostKeyChecking=no <LOGIN>
24+
#
25+
# - to prevent the CI run from exiting, `touch` a file named `BLOCK` in the
26+
# user HOME directory (current directory directly after login). The session
27+
# will run until the file is removed (or 60 min have passed)
28+
#
29+
# - Windows workers (via RDP):
30+
#
31+
# - An RDP password should be defined in an APPVEYOR_RDP_PASSWORD environment
32+
# variable (via the appveyor project settings), or a random password is used
33+
# every time
34+
#
35+
# - RDP login info is given in the form of IP:PORT
36+
#
37+
# - Login with:
38+
#
39+
# xfreerdp /cert:ignore /dynamic-resolution /u:appveyor /p:<PASSWORD> /v:<LOGIN>
40+
#
41+
# - to prevent the CI run from exiting, create a textfile named `BLOCK` on the
42+
# Desktop (a required .txt extension will be added automatically). The session
43+
# will run until the file is removed (or 60 min have passed)
44+
#
45+
46+
# do not make repository clone cheap: interfers with VCS-based version determination
47+
shallow_clone: false
48+
49+
# turn of support for MS project build support (not needed)
50+
build: off
51+
52+
environment:
53+
# place coverage files to a known location regardless of where a test run
54+
# is happening
55+
COVERAGE_ROOT: /home/appveyor/DLTMP
56+
# we pin hatch's data file to make it easy to cache it
57+
HATCH_DATA_DIR: /home/appveyor/hatch-data-dir
58+
# same for pip
59+
PIP_CACHE: /home/appveyor/.cache/pip
60+
# Do not use `image` as a matrix dimension, to have fine-grained control over
61+
# what tests run on which platform
62+
# The ID variable had no impact, but sorts first in the CI run overview
63+
# an intelligible name can help to locate a specific test run
64+
matrix:
65+
# List a CI run for each platform first, to have immediate access when there
66+
# is a need for debugging
67+
68+
# Ubuntu core tests
69+
- job_name: test-linux
70+
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204
71+
PY: 3.9
72+
INSTALL_GITANNEX: git-annex -m snapshot
73+
74+
# same as 'test-linux', but TMPDIR is on a crippled filesystem, causing
75+
# most, if not all test datasets to be created on that filesystem
76+
- job_name: test-linux-crippled
77+
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204
78+
PY: 3.9
79+
# datalad-annex git remote needs something after git-annex_8.20211x
80+
INSTALL_GITANNEX: git-annex -m snapshot
81+
82+
# Windows core tests
83+
- job_name: test-win
84+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
85+
# Python version specification is non-standard on windows
86+
PY: 3.12
87+
INSTALL_GITANNEX: git-annex -m datalad/packages
88+
COVERAGE_ROOT: C:\DLTMP
89+
HATCH_DATA_DIR: C:\hatch-data-dir
90+
PIP_CACHE: C:\Users\appveyor\AppData\Local\pip\Cache
91+
92+
# MacOS core tests
93+
- job_name: test-mac
94+
APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma
95+
PY: 3.12
96+
INSTALL_GITANNEX: git-annex
97+
COVERAGE_ROOT: /Users/appveyor/DLTMP
98+
HATCH_DATA_DIR: /Users/appveyor/hatch-data-dir
99+
PIP_CACHE: /Users/appveyor/.cache/pip
100+
101+
102+
# only run the CI if there are code or tooling changes
103+
only_commits:
104+
files:
105+
- datalad_remake/
106+
- tools/
107+
- pyproject.toml
108+
- .appveyor.yml
109+
110+
111+
## tests need specific hostnames to be available
112+
## note, this is insufficient on MacOS, and needs to be reflected
113+
## in the SSH config too
114+
#hosts:
115+
# datalad-test-sshd: 127.0.0.1
116+
# # same, but for datalad-remake implementations
117+
# datalad-test: 127.0.0.1
118+
119+
120+
# job-specific configurations
121+
for:
122+
#
123+
# POSIX TEST RUNS
124+
#
125+
- matrix:
126+
only:
127+
- job_name: test-linux
128+
- job_name: test-linux-crippled
129+
- job_name: test-mac
130+
131+
cache:
132+
# pip cache
133+
- "${PIP_CACHE} -> .appveyor.yml"
134+
# hatch-managed python versions
135+
- "${HATCH_DATA_DIR}/env/virtual/.pythons -> pyproject.toml"
136+
137+
# init cannot use any components from the repo, because it runs prior to
138+
# cloning it
139+
init:
140+
# enable external SSH access to CI worker
141+
# needs APPVEYOR_SSH_KEY defined in project settings (or environment)
142+
- curl -sflL 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh' | bash -e -
143+
# Scratch space
144+
# we place the "unix" one into the user's HOME to avoid git-annex issues on MacOSX
145+
# gh-5291
146+
- mkdir ~/DLTMP && export TMPDIR=~/DLTMP
147+
148+
install:
149+
# verify that a PY variable is declared that identifies the desired Python version
150+
# for this run
151+
- "[ \"x$PY\" != x ]"
152+
# Missing system software
153+
- tools/appveyor/install-syspkgs $INSTALL_SYSPKGS
154+
# activate Python env solely to get `python` to become available consistently
155+
# hatch will manage the actual testing environment
156+
- '. ${HOME}/venv${PY}/bin/activate'
157+
- tools/appveyor/install-git-annex ${INSTALL_GITANNEX}
158+
# enable the git-annex provisioned by the installer
159+
- "[ -f ${HOME}/dlinstaller_env.sh ] && . ${HOME}/dlinstaller_env.sh || true"
160+
test_script:
161+
# store original TMPDIR setting to limit modification to test execution
162+
- export PREV_TMPDIR=$TMPDIR
163+
# make TMPDIR a "crippled filesystem" to test wrong assumptions of POSIX-ness
164+
# on POSIX OSes. The test fixtures will create all test datasets under TMPDIR
165+
- |
166+
set -e
167+
if [ "$APPVEYOR_JOB_NAME" = "test-linux-crippled" ]; then
168+
# 100 MB VFAT FS in a box
169+
sudo dd if=/dev/zero of=/crippledfs.img count=100 bs=1M
170+
sudo mkfs.vfat /crippledfs.img
171+
sudo mkdir /crippledfs
172+
sudo mount -o "uid=$(id -u),gid=$(id -g)" /crippledfs.img /crippledfs
173+
echo "== mount >>"
174+
mount | grep crippled
175+
echo "<< mount =="
176+
export TMPDIR=/crippledfs
177+
fi
178+
- echo TMPDIR=$TMPDIR
179+
- 'hatch run tests.py${PY}:run-cov --doctest-modules --durations 10'
180+
181+
after_test:
182+
- 'hatch run tests.py${PY}:cov-combine'
183+
- 'hatch run tests.py${PY}:coverage xml'
184+
- 'codecovcli --auto-load-params-from AppVeyor upload-process -n "appveyor-$APPVEYOR_JOB_NAME" --disable-search -f coverage.xml'
185+
186+
on_finish:
187+
# conditionally block the exit of a CI run for direct debugging
188+
- while [ -f ~/BLOCK ]; do sleep 5; done
189+
190+
191+
#
192+
# WINDOWS TEST RUNS
193+
#
194+
- matrix:
195+
only:
196+
- job_name: test-win
197+
cache:
198+
# pip cache
199+
- "%PIP_CACHE% -> .appveyor.yml"
200+
# hatch-managed python versions
201+
- "%HATCH_DATA_DIR%\\env\\virtual\\.pythons -> pyproject.toml"
202+
203+
# init cannot use any components from the repo, because it runs prior to
204+
# cloning it
205+
init:
206+
# remove windows 260-char limit on path names
207+
- ps: Set-Itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -value 1
208+
# enable developer mode on windows
209+
# this should enable mklink without admin privileges, but it doesn't seem to work
210+
#- ps: tools\ci\appveyor_enable_windevmode.ps1
211+
# enable RDP access on windows (RDP password is in appveyor project config)
212+
# this is relatively expensive (1-2min), but very convenient to jump into any build at any time
213+
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
214+
# Scratch space
215+
- cmd: md C:\DLTMP
216+
# and use that scratch space to get short paths in test repos
217+
# (avoiding length-limits as much as possible)
218+
- cmd: "set TMP=C:\\DLTMP"
219+
- cmd: "set TEMP=C:\\DLTMP"
220+
221+
install:
222+
# place a debug setup helper at a convenient location
223+
- cmd: copy tools\appveyor\env_setup.bat C:\\datalad_debug.bat
224+
- cmd: "set PATH=C:\\Python%PY%;C:\\Python%PY%\\Scripts;%PATH%"
225+
# deploy the datalad installer, override version via DATALAD_INSTALLER_VERSION
226+
- cmd:
227+
IF DEFINED DATALAD_INSTALLER_VERSION (
228+
python -m pip install "datalad-installer%DATALAD_INSTALLER_VERSION%"
229+
) ELSE (
230+
python -m pip install datalad-installer
231+
)
232+
# Install git-annex on windows, otherwise INSTALL_SYSPKGS can be used
233+
# deploy git-annex, if desired
234+
- cmd: IF DEFINED INSTALL_GITANNEX datalad-installer --sudo ok %INSTALL_GITANNEX%
235+
236+
test_script:
237+
- cmd: 'hatch run tests.py%PY%:run-cov --doctest-modules --durations 10'
238+
239+
after_test:
240+
- cmd: 'hatch run tests.py%PY%:cov-combine'
241+
- cmd: 'hatch run tests.py%PY%:coverage xml'
242+
- cmd: 'codecovcli --auto-load-params-from AppVeyor upload-process -n "appveyor-%APPVEYOR_JOB_NAME%" --disable-search -f coverage.xml'
243+
244+
on_finish:
245+
# conditionally block the exit of a CI run for direct debugging
246+
- ps: while ((Test-Path "C:\Users\\appveyor\\Desktop\\BLOCK.txt")) { Start-Sleep 5 }
247+
248+
249+
#
250+
# ALL TEST RUNS
251+
#
252+
build_script:
253+
- python -m pip install hatch codecov-cli
254+
255+
after_build:
256+
# Identity setup
257+
- git config --global user.email "[email protected]"
258+
- git config --global user.name "Appveyor Almighty"

.changelog.md.j2

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{% for entry in tree %}
2+
3+
# {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif %}
4+
5+
{% for change_key, changes in entry.changes.items() %}
6+
7+
{% set change_key_map = {
8+
'BREAKING CHANGE': '🪓 Breaking changes',
9+
'doc': '📝 Documentation',
10+
'feat': '💫 New features',
11+
'fix': '🐛 Bug Fixes',
12+
'test': '🛡 Tests',
13+
'rf': '🏠 Refactorings',
14+
'perf': '🚀 Performance improvements',
15+
} %}
16+
{% if change_key %}
17+
## {{ change_key_map.get(change_key, change_key) }}
18+
{% endif %}
19+
{% set scopemap = {
20+
'changelog': 'Changelog',
21+
'contributing': 'Contributing guide',
22+
'helpers': 'Helpers',
23+
'sphinx': 'Rendered documentation',
24+
'typeannotation': 'Type annotation',
25+
} %}
26+
27+
{# no-scope changes #}
28+
{% for change in changes | rejectattr("scope") %}
29+
- {{ change.message }} [[{{ change.sha1 | truncate(8, true, '') }}]](https://github.com/datalad/datalad-remake/commit/{{ change.sha1 | truncate(8, true, '') }})
30+
{% endfor %}
31+
{# scoped changes #}
32+
{% for scope, scope_changes in changes | selectattr("scope") | groupby("scope") %}
33+
- {{ scopemap.get(scope, scope) }}:
34+
{% for change in scope_changes %}
35+
- {{ change.message }} [[{{ change.sha1 | truncate(8, true, '') }}]](https://github.com/datalad/datalad-remake/commit/{{ change.sha1 | truncate(8, true, '') }})
36+
{% endfor %}
37+
{% endfor %}
38+
{% endfor %}
39+
{% endfor %}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Conventional commits
2+
3+
on: pull_request
4+
5+
jobs:
6+
check-messages:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Setup Python
10+
uses: actions/setup-python@v5
11+
with:
12+
python-version: 3.11
13+
architecture: x64
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
# we need all the history to be able to resolve revision ranges properly
18+
fetch-depth: 0
19+
- name: Install commitizen
20+
run: python -m pip install commitizen
21+
- name: Run commit message checks
22+
run: |
23+
cz check --rev-range ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}

.github/workflows/mypy-pr.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Type annotation (PR)
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'datalad_remake/**.py'
7+
- '!**/tests/**.py'
8+
9+
jobs:
10+
check-types-pr:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup Python
14+
uses: actions/setup-python@v5
15+
with:
16+
# run on a "fresh" python, but see mypy flag to check for the oldest supported version
17+
python-version: 3.12
18+
architecture: x64
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Install hatch (which pull mypy)
22+
run: python -m pip install hatch
23+
- name: Get Python changed files
24+
id: changed-py-files
25+
uses: tj-actions/changed-files@v44
26+
with:
27+
files: |
28+
*.py
29+
**/*.py
30+
- name: Type check changed files
31+
if: steps.changed-py-files.outputs.any_changed == 'true'
32+
run: |
33+
# get any type stubs that mypy thinks it needs
34+
hatch run types:mypy --install-types --non-interactive --follow-imports skip ${{ steps.changed-py-files.outputs.all_changed_files }}
35+
# run mypy on the modified files only, and do not even follow imports.
36+
# this results is a fairly superficial test, but given the overall
37+
# state of annotations, we strive to become more correct incrementally
38+
# with focused error reports, rather than barfing a huge complaint
39+
# that is unrelated to the changeset someone has been working on.
40+
# run on the oldest supported Python version
41+
hatch run types:mypy --python-version 3.9 --follow-imports skip --pretty --show-error-context ${{ steps.changed-py-files.outputs.all_changed_files }}

.github/workflows/mypy-project.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Type annotation (project)
2+
3+
on:
4+
push:
5+
paths:
6+
- 'datalad_remake/**.py'
7+
- '!**/tests/**.py'
8+
9+
jobs:
10+
check-types-project:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup Python
14+
uses: actions/setup-python@v5
15+
with:
16+
# run on a "fresh" python, but see mypy flag to check for the oldest supported version
17+
python-version: 3.12
18+
architecture: x64
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Install hatch (which pull mypy)
22+
run: python -m pip install hatch
23+
- name: Type check project
24+
run: |
25+
# get any type stubs that mypy thinks it needs
26+
hatch run types:mypy --install-types --non-interactive --follow-imports skip datalad_core
27+
# run mypy on the full project.
28+
# run on the oldest supported Python version
29+
hatch run types:mypy --python-version 3.9 --pretty --show-error-context datalad_core

0 commit comments

Comments
 (0)