From 190e407c603e2adb5c3fd34607fc626033affdb9 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 13:56:08 -0300 Subject: [PATCH 1/7] Add CircleCI configuration for build, test, and publish --- .circleci/config.yml | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..08bfb55 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,117 @@ +version: 2.1 + +jobs: + build_test: + docker: + - image: cimg/python:3.12 + steps: + - checkout + + - run: + name: Build (build_test) + command: python3 setup.py sdist bdist_wheel + + - run: + name: Install dependencies (build_test) + command: | + python -m venv venv + . venv/bin/activate + pip install -r requirements.txt + + - run: + name: Install package (build_test) + command: | + . venv/bin/activate + pip install dist/lorenzcycletoolkit-1.0.0-py3-none-any.whl + + - run: + name: Install pytest (build_test) + command: | + . venv/bin/activate + pip install pytest + + - run: + name: Run Tests (build_test) + command: | + . venv/bin/activate + pytest + + - store_test_results: + path: test-reports + + test_pypi_publish: + docker: + - image: cimg/python:3.12 + steps: + - checkout + + - run: + name: Create whl (test_pypi_publish) + command: python3 setup.py sdist bdist_wheel + + - run: + name: Install dependencies (test_pypi_publish) + command: | + python -m venv venv + . venv/bin/activate + pip install -r requirements.txt + + - run: + name: Install twine (test_pypi_publish) + command: | + . venv/bin/activate + pip install twine + + - run: + name: Publish on TestPyPI + command: | + . venv/bin/activate + twine upload -u ${TESTPYPI_USERNAME} -p ${TESTPYPI_PASSWORD} --repository testpypi dist/* --verbose + + pypi_publish: + docker: + - image: cimg/python:3.12 + steps: + - checkout + + - run: + name: Create whl (pypi_publish) + command: python3 setup.py sdist bdist_wheel + + - run: + name: Install dependencies (pypi_publish) + command: | + python -m venv venv + . venv/bin/activate + pip install -r requirements.txt + + - run: + name: Install twine (pypi_publish) + command: | + . venv/bin/activate + pip install twine + + - run: + name: Publish on PyPI + command: | + . venv/bin/activate + twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/* --verbose + +workflows: + build_test_publish: + jobs: + - build_test + - test_pypi_publish: + requires: + - build_test + filters: + branches: + only: + - develop + - pypi_publish: + requires: + - build_test + filters: + branches: + only: + - main From 043101c059f2387d4d46a30af1b0db149abc2203 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 14:22:31 -0300 Subject: [PATCH 2/7] Check if the build step correctly creates the wheel file --- .circleci/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08bfb55..8cfafa3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,10 @@ jobs: name: Build (build_test) command: python3 setup.py sdist bdist_wheel + - run: + name: Check if wheel file exists (build_test) + command: ls -l dist/ + - run: name: Install dependencies (build_test) command: | @@ -49,6 +53,10 @@ jobs: name: Create whl (test_pypi_publish) command: python3 setup.py sdist bdist_wheel + - run: + name: Check if wheel file exists (test_pypi_publish) + command: ls -l dist/ + - run: name: Install dependencies (test_pypi_publish) command: | @@ -78,6 +86,10 @@ jobs: name: Create whl (pypi_publish) command: python3 setup.py sdist bdist_wheel + - run: + name: Check if wheel file exists (pypi_publish) + command: ls -l dist/ + - run: name: Install dependencies (pypi_publish) command: | From d29a86d7d6423395a18e27cd43b91f3fb692ac74 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 14:28:41 -0300 Subject: [PATCH 3/7] Ensure that the file name is correct in the pip install command. --- .circleci/config.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8cfafa3..63227c6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,6 +15,12 @@ jobs: name: Check if wheel file exists (build_test) command: ls -l dist/ + - run: + name: Set wheel filename (build_test) + command: | + export WHL_FILENAME=$(ls dist/*.whl) + echo "WHEEL FILE: $WHL_FILENAME" + - run: name: Install dependencies (build_test) command: | @@ -26,7 +32,8 @@ jobs: name: Install package (build_test) command: | . venv/bin/activate - pip install dist/lorenzcycletoolkit-1.0.0-py3-none-any.whl + export WHL_FILENAME=$(ls dist/*.whl) + pip install $WHL_FILENAME - run: name: Install pytest (build_test) From 774fde53e008ce3b4c63d279d6a5209141b39483 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 15:25:01 -0300 Subject: [PATCH 4/7] Version 1.0.1 --- CHANGELOG.md | 20 ++++++++++++++++++++ setup.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d7be2fd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [1.0.1] - 2024-07-27 +### Added +- Added `CHANGELOG.md` file to document changes. +- Published project to PyPI. +- Integrated CircleCI for continuous integration and deployment. + +## [1.0.0] - 2024-07-16 +### Initial Release +- Initial release of LorenzCycleToolkit. +- Implemented core functionalities for calculating the Lorenz Energy Cycle (LEC) in specific atmospheric regions. +- Added support for both Eulerian and Semi-Lagrangian frameworks. +- Provided options for fixed and moving computational domains. +- Generated detailed results in CSV format for energy, conversion, and generation terms. +- Included automatic plot generation for spatial and temporal analysis. +- Utilized Xarray, Dask, Pandas, and MetPy for data handling and computations. +- Comprehensive documentation and usage examples. diff --git a/setup.py b/setup.py index dffcfc9..c8539c7 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read_requirements(): setup( name='LorenzCycleToolkit', - version='1.0.0', + version='1.0.1', packages=find_packages(), include_package_data=True, install_requires=read_requirements(), From 3681fefa369971ce33a29f3074f138ff07921584 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 17:13:34 -0300 Subject: [PATCH 5/7] Version 1.0.2 --- .github/workflows/deploy.yml | 11 ++++++++++- CHANGELOG.md | 5 +++++ README.md | 28 ++++++++++++---------------- docs/source/installation.rst | 31 ++++++++++++++++++++++--------- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 05683dd..fa85bf7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,8 +29,17 @@ jobs: cd docs make html + - name: Fetch remote gh-pages branch + run: git fetch origin gh-pages + + - name: Checkout gh-pages branch + run: git checkout gh-pages + + - name: Merge changes from main branch + run: git merge origin/main + - name: Deploy to GitHub Pages run: | ghp-import -n -p -f docs/build/html env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d7be2fd..4ec30bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [1.0.2] - 2024-07-27 +### Added +- Improved CI/CD pipeline by ensuring up-to-date gh-pages branch before deployment. +- Updated installation instructions to include pip installation from PyPI. + ## [1.0.1] - 2024-07-27 ### Added - Added `CHANGELOG.md` file to document changes. diff --git a/README.md b/README.md index c02cd1c..fdd4d6d 100644 --- a/README.md +++ b/README.md @@ -28,28 +28,14 @@ The LorenzCycleToolkit is a tool for calculating the Lorenz Energy Cycle (LEC) i For detailed documentation and usage instructions, visit the [LorenzCycleToolkit Documentation](https://daniloceano.github.io/LorenzCycleToolkit/). -## Installation -To install the required dependencies, use the provided `requirements.txt` file: -```sh -pip install -r requirements.txt -``` - -## Basic Usage -Run the toolkit with a sample NetCDF file: -```sh -python lorenzcycletoolkit.py samples/testdata_ERA5.nc -r -f -``` - -For more detailed usage instructions, including configuration options and examples, please refer to the documentation. - ## Contributing Contributions are welcome! Please see the [contributing guide](CONTRIBUTING.md) for more details. ### Continuous Integration and Deployment -This project uses GitHub Actions for Continuous Integration (CI) and Continuous Deployment (CD). +This project uses GitHub Actions and CircleCI for Continuous Integration (CI) and Continuous Deployment (CD). -- **CI Pipeline**: The CI pipeline is triggered on each push and pull request to the repository. It runs the following steps: +- **CI Pipeline with GitHub Actions**: The CI pipeline is triggered on each push and pull request to the repository. It runs the following steps: - Sets up the Python environment. - Installs dependencies. - Formats code using autopep8. @@ -57,11 +43,21 @@ This project uses GitHub Actions for Continuous Integration (CI) and Continuous - Lints code using flake8. - Runs tests using pytest. +- **CI Pipeline with CircleCI**: CircleCI is used to build, test, and publish the package. The pipeline runs the following steps: + - Builds the package. + - Checks if the wheel file exists. + - Installs dependencies. + - Installs the package. + - Runs tests using pytest. + - Publishes the package to TestPyPI for the `develop` branch. + - Publishes the package to PyPI for the `main` branch. + - **CD Pipeline**: The CD pipeline deploys the documentation to GitHub Pages whenever changes are pushed to the `main` branch. You can view the CI/CD configuration in the following files: - [python-app.yml](.github/workflows/python-app.yml) - [deploy-docs.yml](.github/workflows/deploy-docs.yml) +- [config.yml](.circleci/config.yml) ## License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/docs/source/installation.rst b/docs/source/installation.rst index cbfb06b..7a047dd 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -4,26 +4,39 @@ Installation Prerequisites ------------- - Python 3.12 or later -- Required Python packages listed in `requirements.txt` Steps ----- -1. Clone the repository:: + +1. Install via pip:: + + pip install LorenzCycleToolkit + +2. Alternatively, clone the repository:: git clone https://github.com/daniloceano/lorenz-cycle.git cd lorenz-cycle -2. Create and activate a virtual environment: +3. Create a virtual environment and activate it:: + + python -m venv venv + source venv/bin/activate + +4. Install the dependencies:: - - Using `venv`:: + pip install -r requirements.txt + +For Conda users: + +1. Clone the repository:: - python -m venv venv - source venv/bin/activate + git clone https://github.com/daniloceano/lorenz-cycle.git + cd lorenz-cycle - - Or using `conda`:: +2. Create a Conda environment and activate it:: - conda create --name lorenz-cycle python=3.12 - conda activate lorenz-cycle + conda create --name lorenzcycletoolkit python=3.12 + conda activate lorenzcycletoolkit 3. Install the dependencies:: From fa344e751a9e695e8b0f81b84e7b1c3501928258 Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 17:55:38 -0300 Subject: [PATCH 6/7] Version 1.0.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c8539c7..56cf384 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read_requirements(): setup( name='LorenzCycleToolkit', - version='1.0.1', + version='1.0.2', packages=find_packages(), include_package_data=True, install_requires=read_requirements(), From 73ccc50f4df91634ef6afeb58bab44f4686740bc Mon Sep 17 00:00:00 2001 From: daniloceano Date: Sat, 27 Jul 2024 19:45:29 -0300 Subject: [PATCH 7/7] Version 1.0.3 --- .github/workflows/deploy.yml | 13 ++----------- CHANGELOG.md | 4 ++++ setup.py | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fa85bf7..62bd9aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.12' + python-version: '3.12.4' - name: Install dependencies run: | @@ -29,17 +29,8 @@ jobs: cd docs make html - - name: Fetch remote gh-pages branch - run: git fetch origin gh-pages - - - name: Checkout gh-pages branch - run: git checkout gh-pages - - - name: Merge changes from main branch - run: git merge origin/main - - name: Deploy to GitHub Pages run: | ghp-import -n -p -f docs/build/html env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ec30bc..f0f60ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.0.3] - 2024-07-27 +### Bug Fixes +- Deploying documentation + ## [1.0.2] - 2024-07-27 ### Added - Improved CI/CD pipeline by ensuring up-to-date gh-pages branch before deployment. diff --git a/setup.py b/setup.py index 56cf384..b23dbe7 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read_requirements(): setup( name='LorenzCycleToolkit', - version='1.0.2', + version='1.0.3', packages=find_packages(), include_package_data=True, install_requires=read_requirements(),