From b18ab7013e9e17527e486997088ed0bde5e76ad3 Mon Sep 17 00:00:00 2001 From: Benjamin Gutzmann Date: Thu, 21 Dec 2023 20:38:45 +0100 Subject: [PATCH] CI: Split up workflows --- .github/workflows/ci.yaml | 59 ----------------------------------- .github/workflows/lint.yml | 38 ++++++++++++++++++++++ .github/workflows/publish.yml | 31 ++++++++++++++++++ .github/workflows/tests.yml | 51 ++++++++++++++++++++++++++++++ README.md | 5 +-- 5 files changed, 123 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index bec6418..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: CI - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip - - name: Install package and dependencies - run: | - python -m pip install --upgrade pip - pip install '.[dev,examples]' - - name: Lint - run: pre-commit run --all-files - - name: Test - run: pytest - - name: Examples - run: python examples/check_timesteps.py tests/data - - publish: - needs: build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - name: Install pypa/build - run: python -m pip install build --user - - name: Build binary wheel and source tarball - run: python -m build --sdist --wheel --outdir dist/ - - name: Publish to test PyPI - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startswith(github.ref, 'refs/tags')) - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository-url: https://test.pypi.org/legacy/ - skip-existing: true - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..1dd7208 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,38 @@ +name: Lint + +on: + push: + branches: [ main ] + + pull_request: + branches: [ main ] + + # Allow job to be triggered manually. + workflow_dispatch: + +# Cancel in-progress jobs when pushing to the same branch. +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + architecture: x64 + cache: pip + + - name: Install project + run: | + python -m pip install --upgrade pip + pip install '.[dev,examples]' + + - name: Lint + run: pre-commit run --all-files diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fff6084 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish + +on: + release: + types: [ published ] + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + architecture: x64 + cache: pip + + - name: Install pypa/build + run: python -m pip install build --user + + - name: Build binary wheel and source tarball + run: python -m build --sdist --wheel --outdir dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..384cb86 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +name: Tests + +on: + push: + branches: [ main ] + + pull_request: + branches: [ main ] + + # Allow job to be triggered manually. + workflow_dispatch: + +# Cancel in-progress jobs when pushing to the same branch. +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ "ubuntu-latest" ] + python-version: ["3.9", "3.10", "3.11"] + include: + - os: "macos-latest" + python-version: "3.9" + - os: "windows-latest" + python-version: "3.9" + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + cache: pip + + - name: Install project + run: | + python -m pip install --upgrade pip + pip install '.[dev,examples]' + + - name: Test + run: pytest + + - name: Examples + run: python examples/check_timesteps.py tests/data diff --git a/README.md b/README.md index 96dc160..602d4b6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # pyisd -[![CI](https://github.com/gadomski/pyisd/actions/workflows/ci.yaml/badge.svg)](https://github.com/gadomski/pyisd/actions/workflows/ci.yaml) +[![Tests](https://github.com/gadomski/pyisd/actions/workflows/tests.yaml/badge.svg)](https://github.com/gadomski/pyisd/actions/workflows/tests.yaml) +[![Lint](https://github.com/gadomski/pyisd/actions/workflows/lint.yaml/badge.svg)](https://github.com/gadomski/pyisd/actions/workflows/lint.yaml) ![PyPI](https://img.shields.io/pypi/v/isd) -[![Documentation Status](https://readthedocs.org/projects/isd/badge/?version=latest)](https://isd.readthedocs.io/en/latest/?badge=latest) +[![Documentation](https://readthedocs.org/projects/isd/badge/?version=latest)](https://isd.readthedocs.io/en/latest/?badge=latest) Reads NOAA [Integrated Surface Database (ISD)](https://www.ncei.noaa.gov/products/land-based-station/integrated-surface-database) data.