Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Github CI workflow #239

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
codecov:
notify:
after_n_builds: 4
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches: [ main ]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
uses: ./.github/workflows/step_pre-commit.yml
tests:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yml
pass:
if: always()
needs: [ pre-commit, tests ]
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
14 changes: 0 additions & 14 deletions .github/workflows/pre-commit.yml

This file was deleted.

21 changes: 12 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release
name: 🚀 Release

on:
release:
Expand All @@ -11,18 +11,21 @@ on:

jobs:
release:
name: 🚀 Release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/fmf
permissions:
id-token: write # For pypi-publish
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
if: ${{ github.event_name == 'release' }}
- uses: actions/checkout@v2
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Create dist
run: make wheel
if: ${{ github.event_name == 'workflow_dispatch' }}
- name: Build package
run: pipx hatch build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/step_pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
workflow_call:

permissions:
contents: read

jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
27 changes: 27 additions & 0 deletions .github/workflows/step_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_call:

permissions:
contents: read

jobs:
checks:
name: Check 🐍 ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install hatch
run: pip install hatch
- name: Test package
run: hatch run cov:xml
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
name: python-${{ matrix.python-version }}
11 changes: 7 additions & 4 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ synced_files:
upstream_package_name: fmf
downstream_package_name: fmf

# Epel9 fails to build with dynamic version. Need to create archive with PKG-INFO
# F37 works with setuptools_scm 7.0
actions:
create-archive:
- make tarball
- "hatch build -t sdist"
- "sh -c 'echo dist/fmf-*.tar.gz'"
get-current-version:
- make version
- "hatch version"

srpm_build_deps:
- make
- python3-docutils
- hatch
- python3-hatch-vcs

jobs:
- job: copr_build
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

37 changes: 12 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Prepare variables
TMP = $(CURDIR)/tmp
VERSION = $(shell grep ^Version fmf.spec | sed 's/.* //')
COMMIT = $(shell git rev-parse --short HEAD)
REPLACE_VERSION = "s/running from the source/$(VERSION) ($(COMMIT))/"
VERSION = $(hatch version)
PACKAGE = fmf-$(VERSION)
FILES = LICENSE README.rst \
Makefile fmf.spec setup.py \
examples fmf bin tests
Makefile fmf.spec pyproject.toml \
examples fmf tests

# Define special targets
all: docs packages
Expand All @@ -19,35 +17,25 @@ tmp:

# Run the test suite, optionally with coverage
test: tmp
pytest tests/unit -c tests/unit/pytest.ini
hatch run test:unit
smoke: tmp
pytest tests/unit/test_smoke.py -c tests/unit/pytest.ini
hatch run test:smoke
coverage: tmp
coverage run --source=fmf,bin -m py.test -c tests/unit/pytest.ini tests
coverage report
coverage annotate
hatch run cov:cov


# Build documentation, prepare man page
docs: man
cd docs && make html
man: source
hatch run docs:html
man:
cp docs/header.txt $(TMP)/man.rst
tail -n+7 README.rst >> $(TMP)/man.rst
rst2man $(TMP)/man.rst > $(TMP)/$(PACKAGE)/fmf.1


# RPM packaging
source: clean tmp
mkdir -p $(TMP)/SOURCES
mkdir -p $(TMP)/$(PACKAGE)
cp -a $(FILES) $(TMP)/$(PACKAGE)
sed -i $(REPLACE_VERSION) $(TMP)/$(PACKAGE)/fmf/__init__.py
tarball: source man
cd $(TMP) && tar cfz SOURCES/$(PACKAGE).tar.gz $(PACKAGE)
@echo ./tmp/SOURCES/$(PACKAGE).tar.gz
version:
@echo "$(VERSION)"
tarball: man
hatch build -t sdist
rpm: tarball
rpmbuild --define '_topdir $(TMP)' -bb fmf.spec
srpm: tarball
Expand All @@ -57,10 +45,9 @@ packages: rpm srpm

# Python packaging
wheel:
python setup.py bdist_wheel
python3 setup.py bdist_wheel
hatch build
upload:
twine upload dist/*.whl
hatch publish


# Vim tags and cleanup
Expand Down
40 changes: 0 additions & 40 deletions bin/fmf

This file was deleted.

62 changes: 32 additions & 30 deletions fmf.spec
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
Name: fmf
Version: 1.4.1
Release: 1%{?dist}
Name: fmf
Version: 0.0.0
Release: 1%{?dist}

Summary: Flexible Metadata Format
License: GPLv2+
BuildArch: noarch
Summary: Flexible Metadata Format
License: GPL-2.0-or-later
BuildArch: noarch

URL: https://github.com/psss/fmf
Source0: https://github.com/psss/fmf/releases/download/%{version}/fmf-%{version}.tar.gz
URL: https://github.com/teemtee/fmf
Source: %{pypi_source fmf}

# Main fmf package requires the Python module
Requires: python%{python3_pkgversion}-%{name} == %{version}-%{release}
BuildRequires: python3-devel
BuildRequires: python3dist(docutils)
BuildRequires: git-core
Requires: python3-fmf == %{version}-%{release}

%description
The fmf Python module and command line tool implement a flexible
Expand All @@ -20,22 +23,12 @@ with support for inheritance and elasticity it provides an
efficient way to organize data into well-sized text documents.
This package contains the command line tool.

%?python_enable_dependency_generator


%package -n python%{python3_pkgversion}-%{name}
%package -n python3-fmf
Summary: %{summary}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-ruamel-yaml
BuildRequires: python%{python3_pkgversion}-filelock
BuildRequires: python%{python3_pkgversion}-jsonschema
BuildRequires: git-core
%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
Requires: git-core

%description -n python%{python3_pkgversion}-%{name}
%description -n python3-fmf
The fmf Python module and command line tool implement a flexible
format for defining metadata in plain text files which can be
stored close to the source code. Thanks to hierarchical structure
Expand All @@ -45,35 +38,44 @@ This package contains the Python 3 module.


%prep
%autosetup
%autosetup -p1 -n fmf-%{version}


%generate_buildrequires
%pyproject_buildrequires -x tests %{?epel:-w}


%build
%py3_build
%pyproject_wheel
cp docs/header.txt man.rst
tail -n+7 README.rst >> man.rst
rst2man man.rst > fmf.1


%install
%py3_install
%pyproject_install
%pyproject_save_files fmf

mkdir -p %{buildroot}%{_mandir}/man1
install -pm 644 fmf.1* %{buildroot}%{_mandir}/man1


%check
%{__python3} -m pytest -vv -c tests/unit/pytest.ini -m 'not web'

%pytest -vv -m 'not web'

%{!?_licensedir:%global license %%doc}

%files
%{_mandir}/man1/*
%{_bindir}/%{name}
%doc README.rst examples
%license LICENSE

%files -n python%{python3_pkgversion}-%{name}
%{python3_sitelib}/%{name}/
%{python3_sitelib}/%{name}-*.egg-info
%files -n python3-fmf -f %{pyproject_files}
# Epel9 does not tag the license file in pyproject_files as a license. Manually install it in this case
%if 0%{?el9}
%license LICENSE
%endif
%doc README.rst


%changelog
Expand Down
Loading
Loading