Skip to content

Commit

Permalink
ci(release): switch to PyPi trusted publisher (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts authored May 2, 2024
2 parents 23d96a8 + dc37aa9 commit 718a4bd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ jobs:
release:
name: "🚀 GitHub Release"
runs-on: ubuntu-latest
needs: [build-macos, build-python-wheel, build-ubuntu, build-windows]
needs:
- build-macos
- build-python-wheel
- build-ubuntu
- build-windows

if: startsWith(github.ref, 'refs/tags/')

Expand Down Expand Up @@ -208,14 +212,21 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v2
with:
discussion_category_name: announcements
fail_on_unmatched_files: true
files: builds/**/*
generate_release_notes: true

release-pypi:
name: "🐍 Release on PyPI"
runs-on: ubuntu-latest
needs: [build-python-wheel]
needs:
- build-python-wheel
environment:
name: pypi
url: https://pypi.org/project/geotribu/
permissions:
id-token: write

if: startsWith(github.ref, 'refs/tags/')

Expand All @@ -230,12 +241,15 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: builds/wheel
print-hash: true

release-ghcr:
name: "🐳 Release as Docker container"
runs-on: ubuntu-latest
needs: [release, release-pypi]
needs:
- release
- release-pypi
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ norecursedirs = .* build dev development dist docs CVS fixtures _darcs {arch} *.
python_files = test_*.py
testpaths = tests

[tool.pytest.ini_options]
retries = 2
retry_delay = 0.5
cumulative_timing = false

[coverage:run]
branch = True
omit =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def load_requirements(requirements_files: Union[Path, list[Path]]) -> list:
long_description=README,
long_description_content_type="text/markdown",
keywords=__about__.__keywords__,
url=__about__.__uri__,
url=__about__.__uri_homepage__,
project_urls={
"Docs": __about__.__uri_homepage__,
"Bug Reports": __about__.__uri_tracker__,
Expand Down
15 changes: 13 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,21 @@ def test_cli_run_comments_open(capsys):
assert Path(Path().home() / ".geotribu/comments/latest.json").exists()


@pytest.mark.flaky(retries=3, delay=1, only_on=[SystemExit])
@pytest.mark.flaky(retries=3, delay=5, only_on=[SystemExit])
def test_cli_run_comments_open_specific(capsys):
"""Test nested subcommand comments latest."""
cli.main(["comments", "open", "--page-size", "25", "--comment-id", "15"])
cli.main(
[
"comments",
"open",
"--page-size",
"25",
"--comment-id",
"15",
"--expiration-rotating-hours",
"0",
]
)

out, err = capsys.readouterr()

Expand Down
8 changes: 5 additions & 3 deletions tests/test_mastodon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@

# standard
import unittest
from os import getenv
from pathlib import Path
from tempfile import TemporaryDirectory

# project
from geotribu_cli.__about__ import __title_clean__, __version__
from geotribu_cli.social.mastodon_client import ExtendedMastodonClient

# 3rd party


# ############################################################################
# ########## Classes #############
# ################################
Expand Down Expand Up @@ -58,6 +56,10 @@ def test_instance_domain_from_url(self):
"mapstodon.space",
)

@unittest.skipIf(
condition=getenv("GEOTRIBU_MASTODON_API_ACCESS_TOKEN") is None,
reason="Le jeton d'API Mastodon est requis pour exécuter ce test.",
)
def test_export_data_all(self):
"""Test export following accounts to CSV."""
masto_client = ExtendedMastodonClient(
Expand Down

0 comments on commit 718a4bd

Please sign in to comment.