-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ruff, pre-commit, and format existing files (#184)
* Add ruff, pre-commit, and format existing files * oops, we use bumps@master now * Run formatting * move deps into optional dev group, add webview optional group, update workflows * add back python -m * update gitignore * remove ref webview * update workflows a bit * remove python 3.7 from publish * add extra versions to test against * add build * update min to python 3.9 * update min to python 3.9 --------- Co-authored-by: glass-ships <glass.ships@outlook.com>
- Loading branch information
1 parent
4f3963a
commit 00cfbeb
Showing
162 changed files
with
10,154 additions
and
10,843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
matrix: | ||
config: | ||
- { os: ubuntu-latest, py: 3.9 } | ||
- { os: ubuntu-latest, py: "3.10" } | ||
- { os: ubuntu-latest, py: "3.11", doc: 1, whl: 1 } | ||
- { os: ubuntu-latest, py: "3.12" } | ||
- { os: windows-latest, py: "3.11", exe: 1 } | ||
# pure python wheels | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.config.py }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.config.py }} | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -e .[dev,webview] | ||
mkdir release | ||
mkdir dist | ||
- name: Check that the docs build (linux only) | ||
if: matrix.config.doc == 1 | ||
run: | | ||
python -m pip install sphinx | ||
make -j 4 -C doc SPHINXOPTS="-W --keep-going" html | ||
- name: Build binary wheel | ||
if: matrix.config.whl == 1 | ||
run: | | ||
python -m pip install build setuptools wheel | ||
python -m build | ||
- name: Build installer | ||
if: matrix.config.exe == 1 | ||
run: | | ||
pwsh -command ".\$GITHUB_WORKSPACE\extra\build_win_installer.ps1" | ||
mv dist\Refl1D*.zip release\ | ||
# See the following for how to upload to a release | ||
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifacts-${{ matrix.config.os }}-${{ matrix.config.py }} | ||
path: | | ||
dist/*.whl | ||
dist/*.zip | ||
dist/*.tar.gz | ||
release/*.zip | ||
publish: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Retrieve all artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
pattern: artifacts-* | ||
merge-multiple: true | ||
|
||
- name: show files | ||
run: | | ||
ls -R artifacts | ||
echo "WINDOWS_INSTALLER=$(ls artifacts/release/*.zip)" >> $GITHUB_ENV | ||
echo "SRC_DIST=$(ls artifacts/dist/*.tar.gz)" >> $GITHUB_ENV | ||
echo "PY3_WHL=$(ls artifacts/dist/*.whl)" >> $GITHUB_ENV | ||
- name: Update current release | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: johnwbyrd/update-release@v1.0.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
files: | | ||
${{ env.WINDOWS_INSTALLER }} | ||
${{ env.PY3_WHL }} | ||
- name: publish distribution to Test PyPI | ||
env: | ||
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
if: env.TEST_PYPI_API_TOKEN != null | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
skip-existing: true | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
packages-dir: artifacts/dist/ | ||
|
||
- name: Publish distribution to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
packages-dir: artifacts/dist/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,49 @@ | ||
name: Test | ||
name: Test Refl1D | ||
|
||
on: | ||
push: | ||
branches: [ master_v0 ] | ||
branches: [master] | ||
pull_request: | ||
branches: [ master_v0 ] | ||
release: | ||
types: [ published ] | ||
branches: [master] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test_and_build: | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
matrix: | ||
config: | ||
- { os: ubuntu-latest, py: 3.7 } | ||
- { os: ubuntu-latest, py: 3.8 } | ||
- { os: ubuntu-latest, py: 3.9 } | ||
- { os: ubuntu-latest, py: "3.10" } | ||
- { os: ubuntu-latest, py: "3.11", doc: 1, whl: 1 } | ||
- { os: ubuntu-latest, py: "3.12" } | ||
- { os: windows-latest, py: "3.11", exe: 1 } | ||
# pure python wheels | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.config.py }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.config.py }} | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install wheel setuptools build | ||
python -m pip install numpy scipy matplotlib bumps periodictable scikit-learn pytest pytest-cov numba | ||
pip install -e . | ||
mkdir release | ||
mkdir dist | ||
- name: Run tests | ||
run: | | ||
pytest -v | ||
python check_examples.py --chisq | ||
env: | ||
MPLBACKEND: agg | ||
|
||
- name: Check that the docs build (linux only) | ||
if: matrix.config.doc == 1 | ||
run: | | ||
python -m pip install sphinx | ||
make -j 4 -C doc SPHINXOPTS="-W --keep-going" html | ||
- { os: windows-latest, py: "3.12", whl: 1 } | ||
- { os: macos-latest, py: "3.12" } | ||
|
||
- name: Build binary wheel | ||
if: matrix.config.whl == 1 | ||
run: | | ||
python -m build | ||
- name: Build installer | ||
if: matrix.config.exe == 1 | ||
run: | | ||
pwsh -command ".\$GITHUB_WORKSPACE\extra\build_win_installer.ps1" | ||
mv dist\Refl1D*.zip release\ | ||
# See the following for how to upload to a release | ||
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifacts-${{ matrix.config.os }}-${{ matrix.config.py }} | ||
path: | | ||
dist/*.whl | ||
dist/*.zip | ||
dist/*.tar.gz | ||
release/*.zip | ||
# pure python wheels | ||
|
||
publish: | ||
needs: test_and_build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Retrieve all artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
pattern: artifacts-* | ||
merge-multiple: true | ||
|
||
- name: show files | ||
run: | | ||
ls -R artifacts | ||
echo "WINDOWS_INSTALLER=$(ls artifacts/release/*.zip)" >> $GITHUB_ENV | ||
echo "SRC_DIST=$(ls artifacts/dist/*.tar.gz)" >> $GITHUB_ENV | ||
echo "PY3_WHL=$(ls artifacts/dist/*.whl)" >> $GITHUB_ENV | ||
- name: Update current release | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: johnwbyrd/update-release@v1.0.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
files: | | ||
${{ env.WINDOWS_INSTALLER }} | ||
${{ env.PY3_WHL }} | ||
- name: publish distribution to Test PyPI | ||
env: | ||
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
if: env.TEST_PYPI_API_TOKEN != null | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
skip-existing: true | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
packages-dir: artifacts/dist/ | ||
|
||
- name: Publish distribution to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
packages-dir: artifacts/dist/ | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.config.py }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.config.py }} | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install .[dev,webview] build setuptools wheel | ||
python -m build | ||
- name: Run tests | ||
run: | | ||
pytest -v | ||
python check_examples.py --chisq | ||
env: | ||
MPLBACKEND: agg | ||
|
||
- name: Check that the docs build (linux only) | ||
if: matrix.config.doc == 1 | ||
run: | | ||
pip install sphinx | ||
make -j 4 -C doc SPHINXOPTS="-W --keep-going" html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ refl1d-webview-client*.tgz | |
/refl1d-* | ||
/bumps-* | ||
/Refl1D.pdf | ||
/output-* | ||
|
||
# Build | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: [--maxkb=8192] | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
args: [--allow-multiple-documents] | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.6.1 | ||
hooks: | ||
# - id: ruff | ||
# args: [--fix, --exit-non-zero-on-fix] | ||
- id: ruff-format | ||
# args: [--line-length=120] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ROOTDIR = $(shell pwd) | ||
|
||
# This nifty perl one-liner collects all comments headed by the double "#" symbols next to each target and recycles them as comments | ||
.PHONY: help | ||
help: ## Print this help message | ||
@perl -nle'print $& if m{^[/a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' | ||
|
||
|
||
.PHONY: lint | ||
lint: ## Run ruff linting | ||
@ruff check --fix refl1d/ tests/ setup.py | ||
|
||
.PHONY: format | ||
format: ## Run ruff formatting | ||
@ruff format refl1d/ tests/ setup.py |
Oops, something went wrong.