Skip to content

Commit

Permalink
Updates for Public Builds (#5)
Browse files Browse the repository at this point in the history
* Update pipenv to work with public pypi, on centos:7

* Put spops calls behind if statements for now

* Make changes needed for rollback to python 3.6

* Update cargo deps to public url for spfs

* Add docker based build of rpm file

* Update readme with information for building locally

* Add actions for building in github CI
  • Loading branch information
rydrman authored Apr 17, 2021
1 parent 3771cb7 commit 5b8fa2b
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 214 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git/
target/
.vscode/
docs/
examples/
packages/
.github/
__pycache__/
*.so
*.egg-info/
20 changes: 20 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Python

on: push

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: sudo pip3 install pipenv
- run: pipenv sync --dev
- name: Lint Formatting with Black
run: pipenv run -- black --check
- name: Lint Typing with MyPy
run: pipenv run -- mypy spk
# TODO: find a way to run the unit test suite... it needs an installation
# of spfs and we currently only produce a centos rpm that's not easy to use here
23 changes: 23 additions & 0 deletions .github/workflows/rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: RPM Build

on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo RPM_NAME=$(rpmspec -q spk.spec | head -n1) >> $GITHUB_ENV
- run: echo Building ${{ env.RPM_NAME }}.rpm
- name: build RPM package
env:
SPFS_PULL_USERNAME: ${{ secrets.SPFS_PULL_USERNAME }}
SPFS_PULL_PASSWORD: ${{ secrets.SPFS_PULL_PASSWORD }}
run: make rpm
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: Binary RPM
path: dist/rpm/RPMS/x86_64/${{ env.RPM_NAME }}.rpm
# TODO: find a way to run the unit test suite... it needs an installation
# of spfs and we currently only produce a centos rpm that's not easy to use here
29 changes: 29 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Rust

on: push

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: cargo fmt -- --check
build:
runs-on: ubuntu-18.04
env:
SPFS_PULL_USERNAME: ${{ secrets.SPFS_PULL_USERNAME }}
SPFS_PULL_PASSWORD: ${{ secrets.SPFS_PULL_PASSWORD }}
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install -y libcap-dev
- run: sudo pip3 install pipenv
- name: Patch spfs Pull Auth
run: sed -i "s|github.com|$SPFS_PULL_USERNAME:$SPFS_PULL_PASSWORD@github.com|" Cargo.toml
- run: pipenv sync --dev
- name: Build
run: pipenv run -- cargo build --verbose
- name: Run tests
run: pipenv run -- cargo test --verbose --no-default-features
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dist/
.idea/
.vscode/
.nfs*
.env
# GENERATED FOR spdev:Shell

# END spdev:Shell
Expand All @@ -32,4 +33,4 @@ dist/
# END spdev:Pipenv
# GENERATED FOR spdev:Rust
target/
# END spdev:Rust
# END spdev:Rust
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ extension-module = ["pyo3/extension-module"]
[dependencies]
pyo3 = {version = "0.13.2"}
relative-path = "1.3.2"
spfs = {git = 'https://gitlab.spimageworks.com/spi/dev/dev-ops/spfs', tag = 'v0.27.0'}
spfs = {git = 'https://github.com/imageworks/spfs', tag = 'v0.27.0'}
tracing = "0.1.25"
tracing-subscriber = "0.2.16"
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
VERSION = $(shell cat spk.spec | grep Version | cut -d ' ' -f 2)
SOURCE_ROOT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

.PHONY: rpm devel test
default: devel

devel:
cd $(SOURCE_ROOT)
pipenv run -- python setup.py develop

test:
cd $(SOURCE_ROOT)
pipenv run -- spfs run - -- pytest

rpm: SPFS_PULL_USERNAME ?= $(shell read -p "Github Username: " user; echo $$user)
rpm: SPFS_PULL_PASSWORD ?= $(shell read -s -p "Github Password/Access Token: " pass; echo $$pass)
rpm:
cd $(SOURCE_ROOT)
docker build . \
-f rpmbuild.Dockerfile \
--build-arg VERSION=$(VERSION) \
--build-arg SPFS_PULL_USERNAME=$(SPFS_PULL_USERNAME) \
--build-arg SPFS_PULL_PASSWORD=$(SPFS_PULL_PASSWORD) \
--tag spk-rpm-builder
mkdir -p dist/rpm
CONTAINER=$$(docker create spk-rpm-builder) \
&& docker cp $$CONTAINER:/root/rpmbuild/RPMS dist/rpm/ \
&& docker rm --force $$CONTAINER
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[source]]
name = "pypi"
url = "https://artifactory.spimageworks.com/api/pypi/pypi/simple"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
Expand All @@ -19,15 +19,15 @@ colorama = "~=0.4.3"
typing-extensions = "~=3.7"
simplejson = "~=3.17"
semver = "~=2.9"
sentry-sdk = "~=1.0"
structlog = "~=19.2"
spops = "~=0.1.13"
sortedcontainers = "~=2.1"
pytz = ">=2020"
cerberus = "~=1.3"
distro = "~=1.5"

[requires]
python_version = "3.7"
python_version = "3.6"

[pipenv]
allow_prereleases = true
Loading

0 comments on commit 5b8fa2b

Please sign in to comment.