Skip to content

Commit

Permalink
Merge pull request #8 from chriscarrollsmith/dev
Browse files Browse the repository at this point in the history
ci: fixed some environment and permissions setup issues that were causing CI failure
  • Loading branch information
chriscarrollsmith authored May 22, 2024
2 parents 78fcb3d + 722bdef commit 387a840
Show file tree
Hide file tree
Showing 32 changed files with 938 additions and 65 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/actions.yml → .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: build-test
name: test-format-render

on:
push:
branches: [main]
branches: [dev]
pull_request:
branches: [main]
branches: [dev]

jobs:
build:
test:
strategy:
fail-fast: false
matrix:
Expand All @@ -25,31 +25,37 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Build and install project
- name: Install project
run: |
poetry install
- name: Run tests with pytest
run: |
poetry run pytest --version
poetry run pytest tests
outputs:
matrix: ${{ toJson(matrix) }}

publish:
needs: build
render:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Publish to PyPi
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Install project
run: |
poetry publish --build -u __token__ -p $PYPI_TOKEN
if [ $? -ne 0 ]; then
echo "Warning: Version has not been incremented. No new version published."
fi
poetry install
- name: Format code with black
run: |
poetry run black .
- name: Build README.md
run: |
poetry run python README_files/render.py
- name: Commit and push changes to repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Automated code format and README render'
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: build-test-publish

on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Build and install project
run: |
poetry build
poetry install
- name: Run tests with pytest
run: |
poetry run pytest tests
- name: Publish to PyPi
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --build -u __token__ -p $PYPI_TOKEN
if [ $? -ne 0 ]; then
echo "::warning::Version has not been incremented. No new version published."
exit 0
fi
7 changes: 5 additions & 2 deletions README.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@
"source": [
"## Planned features\n",
"\n",
"- If pyproject.toml version has been incremented, automatically deploy Github release from main with release notes auto-generated from `News` file or PR message\n",
"- Implement automatic build/render of readthedocs documentation with Sphinx\n",
"- Implement automatic build/release/publish of package updates\n",
"- Move response mocking functionality from `_download_parse` to `_imf_get`\n",
Expand All @@ -1110,7 +1111,9 @@
"\n",
"## Contributing\n",
"\n",
"I would love to have your help in improving `imfp`. If you encounter a bug while using the library, please open an issue. Alternatively, fix the bug and open a pull request. Thanks in advance for your help!"
"I would love to have your help in improving `imfp`. If you encounter a bug while using the library, please open an issue. Alternatively, fix the bug and open a pull request to the `dev` branch. Thanks in advance for your help!\n",
"\n",
"Note to maintainers: To deploy a new version of the package, increment the version number with `poetry version patch` (or `minor`/`major` for larger updates) and push to dev. Github Actions will automatically format the code with black, render the README, and run the unit tests. If the workflow completes successfully, open a PR to main. After merging, the workflow will test again as one last sanity check and then automatically deploy the new version to PyPi. Currently, new Github releases must be created manually, but this will be automated in the future."
]
}
],
Expand All @@ -1130,7 +1133,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.0"
},
"orig_nbformat": 4
},
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ Also note that by default, `imfp` functions will retry any API call rejected for

## Planned features

- If pyproject.toml version has been incremented, automatically deploy Github release from main with release notes auto-generated from `News` file or PR message
- Implement automatic build/render of readthedocs documentation with Sphinx
- Implement automatic build/release/publish of package updates
- Move response mocking functionality from `_download_parse` to `_imf_get`
Expand All @@ -709,4 +710,6 @@ Also note that by default, `imfp` functions will retry any API call rejected for

## Contributing

I would love to have your help in improving `imfp`. If you encounter a bug while using the library, please open an issue. Alternatively, fix the bug and open a pull request. Thanks in advance for your help!
I would love to have your help in improving `imfp`. If you encounter a bug while using the library, please open an issue. Alternatively, fix the bug and open a pull request to the `dev` branch. Thanks in advance for your help!

Note to maintainers: To deploy a new version of the package, increment the version number with `poetry version patch` (or `minor`/`major` for larger updates) and push to dev. Github Actions will automatically format the code with black, render the README, and run the unit tests. If the workflow completes successfully, open a PR to main. After merging, the workflow will test again as one last sanity check and then automatically deploy the new version to PyPi. Currently, new Github releases must be created manually, but this will be automated in the future.
20 changes: 12 additions & 8 deletions README_files/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
import nbconvert
import nbformat


def remove_scoped_styles(markdown_content):
style_pattern = re.compile(r'<style scoped>.*?</style>', re.DOTALL)
return style_pattern.sub('', markdown_content)
style_pattern = re.compile(r"<style scoped>.*?</style>", re.DOTALL)
return style_pattern.sub("", markdown_content)


def replace_png_links(markdown_content):
png_pattern = re.compile(r'!\[png\]\(.*?\.png\)', re.DOTALL)
return png_pattern.sub('![png](README_files/plot.png)', markdown_content)
png_pattern = re.compile(r"!\[png\]\(.*?\.png\)", re.DOTALL)
return png_pattern.sub("![png](README_files/plot.png)", markdown_content)


def convert_notebook_to_markdown(input_file, output_file):
# Read the notebook
with open(input_file, 'r', encoding='utf-8') as f:
with open(input_file, "r", encoding="utf-8") as f:
nb_content = f.read()

# Parse the notebook content
Expand All @@ -30,15 +33,16 @@ def convert_notebook_to_markdown(input_file, output_file):
markdown_output = replace_png_links(markdown_output)

# Write the result to the output file
with open(output_file, 'w', encoding='utf-8') as f:
with open(output_file, "w", encoding="utf-8") as f:
f.write(markdown_output)


if __name__ == "__main__":
script_path = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(script_path)

input_file = os.path.join(project_root, "README.ipynb")
output_file = os.path.join(project_root, "README.md")

convert_notebook_to_markdown(input_file, output_file)
print(f"Notebook {input_file} converted to Markdown {output_file}")
print(f"Notebook {input_file} converted to Markdown {output_file}")
14 changes: 0 additions & 14 deletions build-workflow.txt

This file was deleted.

Binary file removed dist/imfp-0.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-0.0.1.tar.gz
Binary file not shown.
Binary file removed dist/imfp-0.0.2-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-0.0.2.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.0.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.1.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.2-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.2.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.3-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.3.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.4-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.4.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.5-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.5.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.6-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.6.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.7-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.7.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.0.8-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.0.8.tar.gz
Binary file not shown.
Binary file removed dist/imfp-1.1.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/imfp-1.1.0.tar.gz
Binary file not shown.
Loading

0 comments on commit 387a840

Please sign in to comment.