From 5ac7a14745da2304dfac2ef58d928912cbee11cb Mon Sep 17 00:00:00 2001 From: Christopher Carroll Smith Date: Wed, 24 Apr 2024 09:09:06 -0400 Subject: [PATCH] Adjusted CI/CD workflows and updated README --- .github/workflows/{actions.yml => dev.yml} | 32 ++++++++++++---------- .github/workflows/main.yml | 31 +++++++++++++++++++++ README.ipynb | 5 +++- build-workflow.txt | 14 ---------- 4 files changed, 52 insertions(+), 30 deletions(-) rename .github/workflows/{actions.yml => dev.yml} (65%) create mode 100644 .github/workflows/main.yml delete mode 100644 build-workflow.txt diff --git a/.github/workflows/actions.yml b/.github/workflows/dev.yml similarity index 65% rename from .github/workflows/actions.yml rename to .github/workflows/dev.yml index fb9805d..862ad2f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/dev.yml @@ -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: @@ -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 @@ -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 \ No newline at end of file + 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' \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8530c46 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 \ No newline at end of file diff --git a/README.ipynb b/README.ipynb index 6c552c1..e29580c 100644 --- a/README.ipynb +++ b/README.ipynb @@ -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", @@ -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." ] } ], diff --git a/build-workflow.txt b/build-workflow.txt deleted file mode 100644 index 87e4238..0000000 --- a/build-workflow.txt +++ /dev/null @@ -1,14 +0,0 @@ -Change README.ipynb - -poetry run python README_files/render.py - -Change code -Change NEWS - -black imfp -black tests -poetry lock -poetry install -poetry version patch/minor/major -Git commit/push -Github release