From 5b6e2ff9bedbea19bd8e0c729adfb35b95eded1c Mon Sep 17 00:00:00 2001 From: Jan Heinrich Reimer Date: Wed, 9 Aug 2023 17:16:41 +0200 Subject: [PATCH] Simplify CI --- .github/workflows/ci.yml | 300 ++++++++++++++++++--------------------- 1 file changed, 137 insertions(+), 163 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175efaa..096482e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,190 +4,164 @@ on: push: jobs: - build-wheel: - name: "๐Ÿ—๏ธ Python wheel" + python-build: + name: "๐Ÿ—๏ธ Build Python wheels" strategy: matrix: - os: - - ubuntu-latest -# - macos-latest -# - windows-latest python: - - 3.7 - - 3.9 - runs-on: ${{ matrix.os }} + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runs-on: ubuntu-latest steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip build twine - pip install -e . - - name: "๐Ÿ—๏ธ Build Python wheel" - run: python -m build - - name: "๐Ÿงช Check package bundles" - run: twine check dist/* - code-format: - name: "๐Ÿ” Python code format" - needs: - - build-wheel + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿงฐ Install Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: pip + cache-dependency-path: pyproject.toml + - name: "๐Ÿงฐ Install dependencies" + run: pip install build twine + - name: "๐Ÿ—๏ธ Build Python wheels" + run: python -m build + - name: "๐Ÿงช Check package bundles" + run: twine check dist/* + - name: "๐Ÿ“ค Upload Python wheels" + uses: actions/upload-artifact@v3 + if: matrix.python == '3.11' + with: + name: wheels + path: dist + python-code-format: + name: "๐Ÿ” Check Python code format" strategy: matrix: - os: - - ubuntu-latest python: - - 3.7 - - 3.9 - runs-on: ${{ matrix.os }} + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runs-on: ubuntu-latest steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip - pip install -e . - pip install -e .[test] - - name: "๐Ÿ” Check Python code format" - run: flake8 chatnoir_api examples tests - lint: - name: "๐Ÿ” Python Lint" - needs: - - build-wheel + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿงฐ Install Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: pip + cache-dependency-path: pyproject.toml + - name: "๐Ÿงฐ Install dependencies" + run: pip install .[test] + - name: "๐Ÿ” Check Python code format" + run: flake8 chatnoir_api tests examples + python-lint: + name: "๐Ÿ” Lint Python code" strategy: matrix: - os: - - ubuntu-latest python: - - 3.7 - - 3.9 - runs-on: ${{ matrix.os }} + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runs-on: ubuntu-latest steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip - pip install -e . - pip install -e .[test] - - name: "๐Ÿ” Lint Python code" - run: pylint -E chatnoir_api examples tests - unit-tests: - name: "๐Ÿงช Python unit tests" - needs: - - build-wheel + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿงฐ Install Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: pip + cache-dependency-path: pyproject.toml + - name: "๐Ÿงฐ Install dependencies" + run: pip install .[test] + - name: "๐Ÿ” Lint Python code" + run: pylint -E chatnoir_api tests examples + python-test: + name: "๐Ÿงช Test Python code" strategy: matrix: - os: - - ubuntu-latest python: - - 3.7 - - 3.9 - runs-on: ${{ matrix.os }} + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runs-on: ubuntu-latest steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip - pip install -e . - pip install -e .[test] - - name: "๐Ÿงช Test Python code" - env: - CHATNOIR_API_KEY: ${{ secrets.CHATNOIR_API_KEY }} - CHATNOIR_API_KEY_STAGING: ${{ secrets.CHATNOIR_API_KEY_STAGING }} - CHATNOIR_API_KEY_CHAT: ${{ secrets.CHATNOIR_API_KEY_CHAT }} - run: pytest chatnoir_api examples tests --cov --cov-report=term --cov-report=xml - - name: "๐Ÿ“ค Upload test coverage" - uses: actions/upload-artifact@v2 - with: - path: coverage.xml - name: Python test coverage - - name: "๐Ÿ“ค Publish test coverage" - uses: codecov/codecov-action@v1 - publish: - name: "๐Ÿš€ Publish Python package" + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿงฐ Install Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: pip + cache-dependency-path: pyproject.toml + - name: "๐Ÿงฐ Install dependencies" + run: pip install .[test] + - name: "๐Ÿงช Test Python code" + env: + CHATNOIR_API_KEY: ${{ secrets.CHATNOIR_API_KEY }} + CHATNOIR_API_KEY_STAGING: ${{ secrets.CHATNOIR_API_KEY_STAGING }} + CHATNOIR_API_KEY_CHAT: ${{ secrets.CHATNOIR_API_KEY_CHAT }} + run: pytest --cov --cov-report=xml chatnoir_api tests examples + - name: "๐Ÿ“ค Upload coverage to Codecov" + uses: codecov/codecov-action@v3 + if: matrix.python == '3.9' + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + python-publish: + name: "๐Ÿš€ Publish Python wheels" if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') needs: - - code-format - - lint - - unit-tests + - python-build + - python-code-format + - python-lint + - python-tests runs-on: ubuntu-latest + permissions: + id-token: write steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: 3.9 - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip build - pip install -e . - - name: "๐Ÿ—๏ธ Build Python wheel" - run: python -m build - - name: "๐Ÿš€ Publish Python package" - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - release: + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿ“ฅ Download Python wheels" + uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + - name: "๐Ÿš€ Publish Python wheels" + uses: pypa/gh-action-pypi-publish@release/v1 + github-release: name: "๐Ÿš€ Create GitHub release" if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') needs: - - code-format - - lint - - unit-tests - runs-on: ubuntu-20.04 + - python-build + - python-code-format + - python-lint + - python-tests + runs-on: ubuntu-latest steps: - - name: "๐Ÿ“ฅ Check-out" - uses: actions/checkout@v2 - - name: "๐Ÿท๏ธ Get version tag" - id: get-version - run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//} - - name: "๐Ÿงฐ Install Python" - uses: actions/setup-python@v2 - with: - python-version: 3.9 - cache: pip - cache-dependency-path: pyproject.toml - - name: "๐Ÿงฐ Install dependencies" - run: | - python -m pip install --upgrade pip build - pip install -e . - - name: "๐Ÿ—๏ธ Build Python wheel" - run: python -m build - - name: "๐Ÿš€ Create GitHub release" - uses: softprops/action-gh-release@v1 - with: - name: Release ${{ steps.get-version.outputs.tag }} - files: dist/* - fail_on_unmatched_files: true - draft: false - prerelease: false - generate_release_notes: true \ No newline at end of file + - name: "๐Ÿ“ฅ Check-out" + uses: actions/checkout@v3 + - name: "๐Ÿ“ฅ Download Python wheels" + uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + - name: "๐Ÿš€ Create GitHub release" + uses: softprops/action-gh-release@v1 + with: + name: Release ${{ github.ref_name }} + files: dist/* + fail_on_unmatched_files: true + draft: false + prerelease: false + generate_release_notes: true