Skip to content

Commit

Permalink
chore(release): version 0.1.10
Browse files Browse the repository at this point in the history
Features:
- test: enhance test and coverage configuration
 - Add pytest configuration in pyproject.toml
 - Configure coverage settings and reporting
 - Update CI pipeline for coverage tracking

Bug Fixes:
- fix: set SMPS default size range (11.8, 593.5)
 - Add kwargs to RawDataReader for customizable size range

Improvements:
- refactor(logger): enhance progress bar visualization and formatting
- refactor: improve code syntax and structure
- ci: optimize project configuration and build workflows
 - Streamline CI/CD pipeline
 - Resolve artifact naming conflicts
- docs: update project documentation

This release focuses on improving test coverage, fixing SMPS size range
configuration, enhancing system visualization, and optimizing project
infrastructure.
  • Loading branch information
Alex870521 committed Nov 6, 2024
1 parent b3f9531 commit c7cae9b
Show file tree
Hide file tree
Showing 31 changed files with 780 additions and 441 deletions.
87 changes: 81 additions & 6 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,103 @@
# .gitHub/workflows/cleanup.yml
name: Cleanup Deployments
# .github/workflows/cleanup.yml
name: Repository Cleanup

on:
workflow_dispatch: # 允許手動觸發
workflow_dispatch:
inputs:
action_type:
description: '選擇要執行的操作'
required: true
type: choice
options:
- 'Cleanup Workflow'
- 'Cleanup Deployments'
workflow_status:
description: '要清理的工作流程狀態 (僅在選擇 Cleanup Workflow 時需要)'
required: false
type: choice
options:
- 'disabled' # 已停用的工作流程
- 'active' # 活躍的工作流程
- 'all' # 所有工作流程
environment:
description: '要清理的部署環境 (僅在選擇 Cleanup Deployments 時需要)'
required: false
type: choice
options:
- 'all'
- 'github-pages'
- 'pypi'

jobs:
cleanup:
cleanup-workflows:
if: ${{ github.event.inputs.action_type == 'Cleanup Workflow' }}
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup workflows
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const status = '${{ github.event.inputs.workflow_status }}';
console.log(`Cleaning up workflows with status: ${status}`);
// 獲取所有工作流程
const workflows = await github.rest.actions.listRepoWorkflows({
owner: context.repo.owner,
repo: context.repo.repo
});
for (const workflow of workflows.data.workflows) {
// 根據選擇的狀態過濾工作流程
if (status === 'all' ||
(status === 'disabled' && !workflow.state === 'active') ||
(status === 'active' && workflow.state === 'active')) {
console.log(`Processing workflow: ${workflow.name} (${workflow.state})`);
// 獲取此工作流程的所有運行
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow.id,
});
// 刪除運行
console.log(`Found ${runs.data.total_count} runs to delete`);
for (const run of runs.data.workflow_runs) {
console.log(`Deleting run #${run.run_number} of ${workflow.name}`);
await github.rest.actions.deleteWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id
});
}
}
}
console.log('Cleanup completed');
cleanup-deployments:
if: ${{ github.event.inputs.action_type == 'Cleanup Deployments' }}
runs-on: ubuntu-latest
permissions:
deployments: write
actions: write
contents: write

steps:
- name: Delete github-pages deployments
if: ${{ github.event.inputs.environment == 'github-pages' || github.event.inputs.environment == 'all' }}
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: github-pages
onlyRemoveDeployments: true

- name: Delete pypi deployments
if: ${{ github.event.inputs.environment == 'pypi' || github.event.inputs.environment == 'all' }}
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: pypi
onlyRemoveDeployments: true
onlyRemoveDeployments: true
135 changes: 108 additions & 27 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,135 @@
# .gitHub/workflows/publish.yml
name: Publish to PyPI
name: Publish AeroViz

on:
push:
tags:
- 'v*' # 當推送版本標籤時觸發,如 v0.1.0
- 'v*'

jobs:
build-and-publish:
build-and-test:
strategy:
matrix:
python-version: [ "3.11", "3.12" ]
runs-on: ubuntu-latest
environment:
name: pypi
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build twine
pip install setuptools wheel build
pip install -e .
pip install -e ".[test]"
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Run tests
run: |
pytest tests/ -m "not requires_data"
- name: Verify version matches
- name: Verify package version matches tag
run: |
VERSION=$(python setup.py --version)
if [ "$VERSION" != "${{ env.VERSION }}" ]; then
echo "Version mismatch: Tag version (${{ env.VERSION }}) doesn't match package version ($VERSION)"
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(python setup.py --version)
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "Version mismatch:"
echo " - Tag version: $TAG_VERSION"
echo " - Package version: $PACKAGE_VERSION"
exit 1
else
echo "Version match: $TAG_VERSION"
fi
- name: Build package
run: python -m build

- name: Publish to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
twine upload --repository testpypi dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.python-version }}
path: dist/

publish-test:
needs: build-and-test
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/AeroViz
permissions:
id-token: write

steps:
# Download artifacts from Python 3.12 build only
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions-3.12
path: dist/

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-prod:
needs: publish-test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/AeroViz
permissions:
id-token: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions-3.12
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Create GitHub Release
needs: publish-prod
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions-3.12
path: dist/

- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes "Release ${{ github.ref_name }}"
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
36 changes: 27 additions & 9 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,48 @@ name: Python Tests

on:
push:
branches: [ main ]
branches: [ main, master ]
pull_request:
branches: [ main ]
branches: [ main, master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11", "3.12" ]
os: [ ubuntu-latest ]

fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
- name: Set up Python 3.XX
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: ${{ matrix.python-version }}
cache: 'pip' # 啟用 pip 緩存加速安裝

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements/requirements.txt
pip install -e .
pip install -e ".[test]"
- name: Run tests
- name: Run tests with coverage
run: |
pytest tests/test_aeroviz_import.py
pytest tests/ -m "not requires_data" \
--cov=AeroViz \
--cov-report=term-missing \
--cov-report=xml \
-v
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.python-version }}-${{ github.sha }}
path: coverage.xml
if-no-files-found: error
3 changes: 1 addition & 2 deletions AeroViz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
from AeroViz import plot
from AeroViz.dataProcess import DataProcess
from AeroViz.rawDataReader import RawDataReader
from AeroViz.tools import DataBase, DataReader, DataClassifier
from AeroViz.tools import DataBase, DataClassifier

__all__ = [
'plot',
'RawDataReader',
'DataProcess',
'DataBase',
'DataReader',
'DataClassifier'
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
from scipy.special import jv, yv


def coerceDType(d):
if type(d) is not np.ndarray:
return np.array(d)
else:
return d


def MieQ(m, wavelength, diameter, nMedium=1.0, asDict=False, asCrossSection=False):
# http://pymiescatt.readthedocs.io/en/latest/forward.html#MieQ
nMedium = nMedium.real
Expand Down Expand Up @@ -271,8 +264,8 @@ def Mie_SD(m, wavelength, dp, ndp, nMedium=1.0, SMPS=True, interpolate=False, as
nMedium = nMedium.real
m /= nMedium
wavelength /= nMedium
dp = coerceDType(dp)
ndp = coerceDType(ndp)
dp = np.array(dp)
ndp = np.array(ndp)
_length = np.size(dp)
Q_ext = np.zeros(_length)
Q_sca = np.zeros(_length)
Expand Down Expand Up @@ -373,8 +366,8 @@ def SF_SD(m, wavelength, dp, ndp, nMedium=1.0, minAngle=0, maxAngle=180, angular
wavelength /= nMedium

_steps = int(1 + (maxAngle - minAngle) / angularResolution)
ndp = coerceDType(ndp)
dp = coerceDType(dp)
ndp = np.array(ndp)
dp = np.array(dp)
SL = np.zeros(_steps)
SR = np.zeros(_steps)
SU = np.zeros(_steps)
Expand Down
File renamed without changes.
Loading

0 comments on commit c7cae9b

Please sign in to comment.