Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: Ruff #9

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 62 additions & 62 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Build & test
on:
push:
branches:
- main
- main
tags:
- "*"
- "*"
pull_request:
branches:
- main
- main
schedule:
- cron: '0 0 * * 1'
- cron: '0 0 * * 1'

defaults:
run:
Expand All @@ -31,71 +31,71 @@ jobs:
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
version: ${{ steps.show_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}
- name: Detect version
id: show_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pipx run hatch version # Once to avoid output of initial setup
VERSION=$( pipx run hatch version )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}
- name: Detect version
id: show_version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pipx run hatch version # Once to avoid output of initial setup
VERSION=$( pipx run hatch version )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python information
run: python -c "import sys; print(sys.version)"
- name: Build sdist and wheel
run: pipx run build
- name: Check release tools
run: pipx run twine check dist/*
- name: Save build output
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python information
run: python -c "import sys; print(sys.version)"
- name: Build sdist and wheel
run: pipx run build
- name: Check release tools
run: pipx run twine check dist/*
- name: Save build output
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

test:
needs: [job_metadata, build]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
install: [repo]
include:
- python-version: "3.11"
install: sdist
- python-version: "3.11"
install: wheel
- python-version: "3.11"
install: editable
- python-version: "3.12"
install: sdist
- python-version: "3.12"
install: wheel
- python-version: "3.12"
install: editable
env:
INSTALL_TYPE: ${{ matrix.install }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: matrix.install == 'repo' || matrix.install == 'editable'
with:
fetch-depth: 0
Expand Down Expand Up @@ -138,11 +138,11 @@ jobs:
needs: test
if: github.repository == 'nipreps/synthstrip' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Contribution checks

on:
push:
branches:
- main
pull_request:
branches:
- main

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx run ruff check .
- run: pipx run ruff format --diff .

codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
with:
exclude_file: ORIGINAL_LICENSE
8 changes: 5 additions & 3 deletions nipreps/synthstrip/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
# https://www.nipreps.org/community/licensing/
#

if __name__ == "__main__":
if __name__ == '__main__':
import sys

from nipreps.synthstrip.cli import main

from . import __name__ as module

# `python -m <module>` typically displays the command as __main__.py
if "__main__.py" in sys.argv[0]:
sys.argv[0] = "%s -m %s" % (sys.executable, module)
if '__main__.py' in sys.argv[0]:
sys.argv[0] = f'{sys.executable} -m {module}'
main()
Loading
Loading