Skip to content

Commit

Permalink
Adjusted CI/CD workflows and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscarrollsmith committed Apr 24, 2024
1 parent c01b29e commit 5ac7a14
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
32 changes: 17 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,18 +25,17 @@ 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
steps:
- uses: actions/checkout@v3
Expand All @@ -45,11 +44,14 @@ jobs:
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: Format code with black
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
black imfp
black tests
- 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'
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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."
fi
5 changes: 4 additions & 1 deletion 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."
]
}
],
Expand Down
14 changes: 0 additions & 14 deletions build-workflow.txt

This file was deleted.

0 comments on commit 5ac7a14

Please sign in to comment.