From e7db820439a4d5ff5f5a0772df34626c4b2ac850 Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 08:33:27 +0300 Subject: [PATCH 1/6] Run ghactions on pull_request only --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 14830b2..35d8c8a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,6 +1,6 @@ name: czml3 gh actions workflow -on: [push, pull_request] +on: [pull_request] jobs: build: From ae0ada5de2c6b074ac8a0ed400216a7b3af1e1cf Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 08:46:47 +0300 Subject: [PATCH 2/6] Publish to PyPi only on pushes to main branch --- .github/workflows/publish-to-pypi.yml | 50 +++++++++++++++++++++++++++ .github/workflows/workflow.yml | 49 +------------------------- 2 files changed, 51 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..dab4ef2 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,50 @@ +name: Publish to PyPi + +on: + push: + branches: + - main +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/czml3 + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 35d8c8a..c6a2bb5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,60 +1,13 @@ -name: czml3 gh actions workflow +name: Run checks on: [pull_request] jobs: - build: - name: Build distribution 📦 - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: python3 -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - publish-to-pypi: - name: >- - Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/czml3 - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - tox-checks: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From c82350f773763a2012bf397f26098578a06c495b Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 09:46:56 +0300 Subject: [PATCH 3/6] Codecov reports coverage of czml3 only --- .github/workflows/workflow.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index c6a2bb5..7f8d0db 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -28,19 +28,18 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 + with: + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install .[dev] - name: Generate coverage report - run: python -m pytest --cov=./ --cov-report=xml:pytest_cov.xml + run: python -m pytest --cov=czml3 --cov-report=xml:pytest_cov.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: - directory: ./coverage/reports/ fail_ci_if_error: true - files: ./coverage.xml,./pytest_cov.xml,!./cache - flags: unittests - name: codecov-umbrella + files: ./pytest_cov.xml token: ${{ secrets.CODECOV_TOKEN }} verbose: true From c17580bbf6a85a8556e05839ebf4ff6701eb9a84 Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 09:56:01 +0300 Subject: [PATCH 4/6] Upload codecov report --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 7f8d0db..f04a1b6 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -40,6 +40,6 @@ jobs: uses: codecov/codecov-action@v4 with: fail_ci_if_error: true - files: ./pytest_cov.xml + files: pytest_cov.xml, coverage.xml token: ${{ secrets.CODECOV_TOKEN }} verbose: true From fc216b83ed7c0e9fb35df1ec3d2bb589be8886a2 Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 12:45:46 +0300 Subject: [PATCH 5/6] Remove user flag from pip install build in publish to PyPi ghaction --- .github/workflows/publish-to-pypi.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index dab4ef2..b79bb17 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -15,11 +15,7 @@ jobs: with: python-version: "3.11" - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user + run: python3 -m pip install build - name: Build a binary wheel and a source tarball run: python3 -m build - name: Store the distribution packages From 3eda1382ee067177f1255e24497fab177f46095e Mon Sep 17 00:00:00 2001 From: Daniel Stoops Date: Tue, 25 Jun 2024 19:00:22 +0300 Subject: [PATCH 6/6] Publish to PyPi on release --- .github/workflows/publish-to-pypi.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index b79bb17..3f30775 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,9 +1,9 @@ name: Publish to PyPi on: - push: - branches: - - main + release: + types: [created] + jobs: build: name: Build distribution 📦 @@ -27,7 +27,6 @@ jobs: publish-to-pypi: name: >- Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build runs-on: ubuntu-latest