-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona imagem do sistema diataxis. Modifica apresentacao para execu…
…tar CI/CD. Adiciona codigos para CI/CD
- Loading branch information
1 parent
f522616
commit 2a1b731
Showing
8 changed files
with
192 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
permissions: | ||
contents: write | ||
pages: write | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: [uses: fastai/workflows/quarto-ghp@master] |
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,32 @@ | ||
name: Lint | ||
on: [workflow_dispatch, pull_request, push] | ||
|
||
jobs: | ||
nbqa: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
architecture: 'x64' | ||
cache: "pip" | ||
cache-dependency-path: settings.ini | ||
|
||
- name: Install lib | ||
run: | | ||
pip install -e .[dev] | ||
- name: Check nbs are clean | ||
run: ./scripts/check_nbs_clean.sh | ||
shell: bash | ||
|
||
- name: Run flake8 | ||
run: nbqa flake8 nbs/*.ipynb | ||
|
||
- name: Run Mypy | ||
run: nbqa mypy nbs/*.ipynb --ignore-missing-imports |
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,26 @@ | ||
name: Publish package to TestPypi | ||
|
||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install deps | ||
run: | | ||
pip install twine | ||
pip install -e .[dev] | ||
- name: nbdev pypi | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
run: nbdev_pypi --repository testpypi |
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,31 @@ | ||
name: Tests | ||
on: [workflow_dispatch, pull_request, push] | ||
|
||
jobs: | ||
nbdev-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
py: ['3.8', '3.9', '3.10'] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py }} | ||
architecture: 'x64' | ||
cache: "pip" | ||
cache-dependency-path: settings.ini | ||
|
||
- name: Install Library | ||
run: | | ||
pip install --upgrade pip | ||
pip install -e .[dev] | ||
- name: Run Tests | ||
run: | | ||
nbdev_test | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
#set -x | ||
|
||
nbdev_clean --clear_all | ||
|
||
GIT_STATUS_FAILED(){ | ||
git status -uno -s |grep '.*\.ipynb' | ||
} | ||
|
||
if GIT_STATUS_FAILED; then | ||
echo "!! ::error:: Detected notebooks that are not cleaned." | ||
false; | ||
fi |
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,65 @@ | ||
import re | ||
import os | ||
import sys | ||
from nbdev.config import add_init, get_config | ||
from nbdev.doclinks import _build_modidx, nbglob, nb_export | ||
|
||
# Renames python library | ||
|
||
def _is_snake_case_without_symbols(s): | ||
pattern = r'^[a-z]+(?:_[a-z]+)*$' | ||
return bool(re.match(pattern, s)) | ||
|
||
def extract_legacy_package_name() -> str: | ||
pattern = r'lib_name\s*=\s*(\w+)' | ||
|
||
with open(f'settings.ini', 'r') as f: | ||
settings = f.read() | ||
|
||
return re.search(pattern, settings).group(1) | ||
|
||
def rename_settings_ini(legacy_name: str, new_name: str): | ||
with open(f'settings.ini', 'r') as f: | ||
settings = f.read() | ||
|
||
settings = re.sub(legacy_name, new_name, settings) | ||
|
||
with open(f'settings.ini', 'w') as f: | ||
f.write(settings) | ||
|
||
def rename_lib_folder(legacy_name: str, new_name: str): | ||
os.rename(legacy_name, new_name) | ||
|
||
def _change_imports(file: str, legacy_name: str, new_name: str): | ||
with open(file, 'r') as f: | ||
code = f.read() | ||
code = re.sub(r'(?<!\.)\b'+legacy_name+r'\b', new_name, code) | ||
|
||
with open(file, 'w') as f: | ||
f.write(code) | ||
|
||
def _export(legacy_name, new_name: str): | ||
files = nbglob(path='nbs', as_path=True).sorted('name') | ||
|
||
for file in files: | ||
_change_imports(file, legacy_name, new_name) | ||
|
||
for f in files: nb_export(f, procs=None) | ||
add_init(get_config().lib_path) | ||
_build_modidx() | ||
|
||
if __name__ == "__main__": | ||
assert len(sys.argv) == 2, "missing package name" | ||
|
||
invalid_package_name = ( | ||
"Invalid package name " | ||
"try a singleword or snake_case" | ||
) | ||
new_package_name = sys.argv[1] | ||
|
||
assert _is_snake_case_without_symbols(new_package_name), invalid_package_name | ||
|
||
legacy_package_name = extract_legacy_package_name() | ||
rename_settings_ini(legacy_package_name, new_package_name) | ||
rename_lib_folder(legacy_package_name, new_package_name) | ||
_export(legacy_package_name, new_package_name) |