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

Build and release binaries for ppc64le #7

Draft
wants to merge 17 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
8 changes: 7 additions & 1 deletion .github/workflows/build-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on: [workflow_dispatch]
jobs:
build-dev-image:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- arch: amd64
- arch: ppc64le
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -21,4 +26,5 @@ jobs:
context: build/
pull: true
push: true
tags: ghcr.io/olcf/greggd/dev-image:8.3_20210513
platforms: linux/${{ matrix.arch }}
tags: ghcr.io/olcf/greggd/dev-image:8.3_20210706-${{ matrix.arch }}
28 changes: 24 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,36 @@ on: [push]
jobs:
build-binary:
runs-on: ubuntu-20.04
container: ghcr.io/olcf/greggd/dev-image:8.3_20210513
strategy:
matrix:
include:
- arch: amd64
image: ghcr.io/olcf/greggd/dev-image:8.3_20210706-amd64
- arch: ppc64le
image: ghcr.io/olcf/greggd/dev-image:8.3_20210706-ppc64le
steps:
- run: sudo apt-get install qemu binfmt-support qemu-user-static
- run: |
docker run --rm --privileged \
multiarch/qemu-user-static:5.2.0-2 --reset
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: go build -v ./cmd/greggd/
run: |
docker run --rm --platform ${{ matrix.arch }} \
--workdir "${GITHUB_WORKSPACE}" \
-v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
${{ matrix.image }} \
/bin/bash -c "uname -a && make build"
- name: Test
run: go test -v ./...
run: |
docker run --rm --platform ${{ matrix.arch }} \
--workdir "${GITHUB_WORKSPACE}" \
-v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
${{ matrix.image }} \
/bin/bash -c "make test"
- name: Save artifact
uses: actions/upload-artifact@v2
with:
name: greggd
name: greggd.${{ matrix.arch }}
path: greggd
23 changes: 9 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,22 @@ jobs:
# No shallow clone
with:
fetch-depth: 0
- name: Export release vars
id: vars
shell: bash
run: |
echo "::set-output name=version::$(git describe --tags --abbrev=0)"
echo "::set-output name=release::$(git rev-parse --short HEAD)"
- name: Build
run: go build -v ./cmd/greggd/
run: make test
- name: Test
run: go test -v ./...
run: make test
- name: Build RPM
env:
VERSION: ${{ steps.vars.outputs.version }}
RELEASE: ${{ steps.vars.outputs.release }}
run: |
envsubst < build/nfpm-template.yaml > build/nfpm.yaml
nfpm -f build/nfpm.yaml pkg --packager rpm
make srpm
make rpm
cp ~/rpmbuild/SRPMS/greggd*.rpm .
cp ~/rpmbuild/RPMS/*/greggd*.rpm .
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: greggd*.rpm
files: |
greggd*.rpm
greggd*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
VERSION != git describe --tags --abbrev=0
RELEASE != git rev-parse --short HEAD
PREFIX := /usr
GREGGD_ARCHIVE := greggd-$(VERSION)-$(RELEASE).tar.gz

.PHONY: build
build:
go build -v ./cmd/greggd/

.PHONY: test
test:
go test -v ./...

.PHONY: install
install: greggd
mkdir -p $(DESTDIR)/$(PREFIX)/sbin/
mkdir -p $(DESTDIR)/$(PREFIX)/share/greggd/{c,doc}/
mkdir -p $(DESTDIR)/$(PREFIX)/lib/systemd/system/
install -m 0755 ./greggd $(DESTDIR)/$(PREFIX)/sbin/
install -m 0644 ./README.md $(DESTDIR)/$(PREFIX)/share/greggd/doc/
install -m 0644 ./LICENSE.md $(DESTDIR)/$(PREFIX)/share/greggd/doc/
install -m 0644 ./csrc/*.c $(DESTDIR)/$(PREFIX)/share/greggd/c/
install -m 0644 ./init/greggd.service $(DESTDIR)/$(PREFIX)/lib/systemd/system/

.PHONY: clean
clean:
rm ./greggd

.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)/$(PREFIX)/sbin/greggd
mkdir -p $(DESTDIR)/$(PREFIX)/share/greggd/{c,doc}/
mkdir -p $(DESTDIR)/$(PREFIX)/lib/systemd/system/greggd.service

.PHONY: archive
archive:
git archive -o greggd-$(VERSION)-$(RELEASE).tar.gz HEAD

.PHONY: srpm
srpm:
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
make archive
cp $(GREGGD_ARCHIVE) ~/rpmbuild/SOURCES
rpmbuild -bs ./build/greggd.spec

.PHONY: rpm
rpm:
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
rpmbuild -bb ./build/greggd.spec
5 changes: 1 addition & 4 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ LABEL name="greggd-devel" \
version="centos8.3-297"

RUN dnf install --enablerepo=powertools -y \
@development git golang kernel-devel bcc-devel; \
@development git golang kernel-devel bcc-devel rpm-build make; \
yum clean all
RUN \
curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.5.1/nfpm_amd64.rpm; \
rpm -i nfpm_amd64.rpm; rm nfpm_amd64.rpm

CMD ["/bin/bash"]
39 changes: 39 additions & 0 deletions build/greggd.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%global gitversion %(git describe --tags --abbrev=0)
%global gitrelease %(git rev-parse --short HEAD)
%define debug_package %{nil}
Name: greggd
Version: %{gitversion}
Release: %{gitrelease}%{?dist}
Summary: Global runtime for eBPF-enabled gathering (w/ gumption) daemon

License: ASL 2.0
URL: https://github.com/olcf/%{name}
Source0: https://github.com/olcf/%{name}/release/%{name}-%{gitversion}-%{gitrelease}.tar.gz

BuildRequires: golang
BuildRequires: bcc
BuildRequires: bcc-devel
BuildRequires: git
Requires: bcc

%description
System daemon wrapping the BPF Compiler Collection to compile and load BPF
programs into the kernel, and output data to metric reporting tools via a
unix-socket.

%prep
%setup -q -c %{name}-%{gitversion}-%{gitrelease}

%build
make build

%install
make DESTDIR=%{buildroot} PREFIX=%{_prefix} install

%files
%{_prefix}/sbin/%{name}
%{_prefix}/lib/systemd/system/%{name}.service
%{_prefix}/share/%{name}/c/
%doc %{_prefix}/share/%{name}/doc/

%changelog