Skip to content

Commit

Permalink
feat: Added github actions for rpm package build
Browse files Browse the repository at this point in the history
This includes the rpm dir with a makefile and spec template.
Ported over async_lru for lack of fedora packaging.
  • Loading branch information
grafuls committed Nov 26, 2021
1 parent 505daf7 commit 0060ab1
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 16 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/push-copr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: RPM build in Fedora Copr
on:
# Build only on pushes into master branch.
push:
branches: [master]

jobs:
build:
name: Submit a build from Fedora container
container: fedora:latest
runs-on: ubuntu-latest

steps:
- name: Check out proper version of sources
uses: actions/checkout@v1

- name: Install API token for copr-cli
env:
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
run: |
mkdir -p "$HOME/.config"
echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr"
- name: Install tooling for source RPM build
run: |
dnf -y install @development-tools @rpm-development-tools copr-cli make
- name: Build the source RPM
run: |
cd rpm && make srpm
- name: Submit the build by uploading the source RPM
run: |
copr build quadsdev/python3-badfish rpm/*.src.rpm
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![badfish](/image/badfish-original-licensed.small.png)

[![Copr build status](https://copr.fedorainfracloud.org/coprs/quadsdev/python3-badfish/package/python3-badfish/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/quadsdev/python3-badfish/package/python3-badfish/)
[![Build Status](https://travis-ci.com/redhat-performance/badfish.svg?branch=master)](https://travis-ci.com/redhat-performance/badfish)
[![codecov](https://codecov.io/gh/redhat-performance/badfish/branch/master/graph/badge.svg?token=CNJN0CD6GN)](https://codecov.io/gh/redhat-performance/badfish)
[![Docker Repository on Quay](https://quay.io/repository/quads/badfish/status "Docker Repository on Quay")](https://quay.io/repository/quads/badfish)
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@

pyyaml>=4.2b1
aiohttp>=3.7.4
async-lru==1.0.2
pytest~=4.3.0
asynctest~=0.13.0
setuptools~=46.1.3
setuptools>=46.4.0
5 changes: 5 additions & 0 deletions rpm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.spec
*.tar.gz
*.src.rpm
noarch/
python3-badfish.spec/
Binary file added rpm/.python3-badfish.spec.tpl.swp
Binary file not shown.
36 changes: 36 additions & 0 deletions rpm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PYTHON := python3
BUILD_HELPER := ./build-helper

VERSION = $(shell $(BUILD_HELPER) --version)
RELEASE = $(shell $(BUILD_HELPER) --release)
DATE = $(shell date +'%a %b %d %Y')
TARBALL = python3-badfish-$(VERSION).tar.gz

all: python3-badfish.spec python3-badfish-$(VERSION).tar.gz

.PHONY: $(TARBALL)
$(TARBALL):
rm -f $(TARBALL)
( cd .. && git archive --prefix python3-badfish-$(VERSION)/ HEAD ) \
| gzip > "$@"

python3-badfish.spec: python3-badfish.spec.tpl ../setup.py
@echo " GEN $@" ; \
sed -e "s|@VERSION@|$(VERSION)|g" \
-e "s|@RELEASE@|$(RELEASE)|g" \
-e "s|@DATE@|$(DATE)|g" \
$< > $@.output ; \
mv "$@.output" "$@" # move when successful

srpm: all
dir=`pwd` ; \
rm *.src.rpm ; \
rpmbuild --define "_sourcedir $$dir" \
--define "_rpmdir $$dir" \
--define "_builddir $$dir" \
--define "_specdir $$dir" \
--define "_srcrpmdir $$dir" \
-bs *.spec

clean:
rm -rf *.src.rpm *.tar.gz *.spec noarch
10 changes: 10 additions & 0 deletions rpm/build-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/sh

case $1 in
--version)
cd .. ; ${PYTHON-python3} setup.py --version
;;
--release)
echo "git.$(date +"%Y%m%d_%H%M%S")"
;;
esac
42 changes: 42 additions & 0 deletions rpm/python3-badfish.spec.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%global sum Badfish is a Redfish-based API tool for managing bare-metal systems via the Redfish API
%global desc \
Badfish is a vendor-agnostic, redfish-based API tool used to consolidate \
management of IPMI and out-of-band interfaces for common server hardware \
vendors. Badfish is also a popular song from Sublime, this may be a \
coincidence – are you a badfish too?


Name: python3-badfish
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: %{sum}

License: GPLv3
URL: https://github.com/redhat-performance/badfish
Source0: %{url}/archive/v%{version}/python3-badfish-%{version}.tar.gz

BuildArch: noarch
BuildRequires: python3-setuptools
BuildRequires: python3-devel

%description
%{desc}

%prep
%autosetup -n %{name}-%{version}

%build
%py3_build

%install
%py3_install

%files -n %{name}
%doc README.md
%license LICENSE
%{python3_sitelib}/*
%{_bindir}/badfish

%changelog
* @DATE@ Gonzalo Rafuls <gonza@redhat.com> - @VERSION@-@RELEASE@
- built from upstream, changelog ignored
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

setuptools.setup(
name="badfish",
version="1.0.0",
version="1.0.1",
description="Badfish is a Redfish-based API tool for managing bare-metal systems via the Redfish API",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/redhat-performance/badfish",
install_requires=[
"pyyaml>=4.2b1",
"aiohttp>=3.7.4",
"async-lru==1.0.2",
"setuptools~=46.1.3",
"setuptools>=46.4.0",
],
package_dir={"": "src"},
packages=setuptools.find_packages(where="src"),
Expand All @@ -25,7 +24,7 @@
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GPLv3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
Expand Down
10 changes: 4 additions & 6 deletions src/badfish/badfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from queue import Queue
from logging.handlers import QueueHandler, QueueListener

from async_lru import alru_cache
from helpers.async_lru import alru_cache
from logging import (
Formatter,
FileHandler,
Expand All @@ -35,7 +35,7 @@
RETRIES = 15


async def badfish_factory(_host, _username, _password, _logger, _retries, _loop=None):
async def badfish_factory(_host, _username, _password, _logger, _retries=RETRIES, _loop=None):
badfish = Badfish(_host, _username, _password, _logger, _retries, _loop)
await badfish.init()
return badfish
Expand All @@ -56,11 +56,9 @@ def __init__(self, _host, _username, _password, _logger, _retries, _loop=None):
self.root_uri = "%s%s" % (self.host_uri, self.redfish_uri)
self.logger = _logger
self.semaphore = asyncio.Semaphore(50)
if not _loop:
self.loop = _loop
if not self.loop:
self.loop = asyncio.get_event_loop()
else:
self.loop = _loop

self.system_resource = None
self.manager_resource = None
self.bios_uri = None
Expand Down
Empty file added src/helpers/__init__.py
Empty file.

0 comments on commit 0060ab1

Please sign in to comment.