From d852e167b00895c08233186e00ff6272b56ad049 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 | 68 ----------------------------------- .github/workflows/lint.yml | 39 ++++++++++++++++++++ .github/workflows/publish.yml | 31 ++++++++++++++++ .github/workflows/tests.yml | 52 +++++++++++++++++++++++++++ README.md | 5 +-- 5 files changed, 125 insertions(+), 70 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 64ad198..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: CI - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.7, 3.8, 3.9] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Get pip cache dir - id: pip-cache - run: echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements-dev.txt') }} - restore-keys: ${{ runner.os }}-pip- - - name: Install package and dependencies - run: | - python -m pip install --upgrade pip - pip install . - pip install -r requirements-dev.txt - - 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@v2 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - 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..d1280da --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +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.9" + architecture: x64 + cache: pip + + - name: Install project + run: | + python -m pip install --upgrade pip + pip install . + pip install -r requirements-dev.txt + + - 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..5050929 --- /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.9" + 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..28df5f5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,52 @@ +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.7", "3.8", "3.9" ] + 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 . + pip install -r requirements-dev.txt + + - name: Test + run: pytest + + - name: Examples + run: python examples/check_timesteps.py tests/data diff --git a/README.md b/README.md index f745b45..2f19686 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ Reads NOAA [Integrated Surface Database (ISD)](https://www.ncei.noaa.gov/products/land-based-station/integrated-surface-database) data. -[![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) ## Installation