From 607c8dd1d967a8a57ee111da530c65ff4d9a3883 Mon Sep 17 00:00:00 2001 From: Cyprien Pelisse-Verdoux Date: Thu, 19 Sep 2024 16:58:33 +0200 Subject: [PATCH] feat(ci): modified action to build rpm --- .github/workflows/main.yaml | 50 +++++++++++++++++++++++---- specs/alumet.spec | 67 ++++++++++++++++++++++++++----------- 2 files changed, 90 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index db22284..1c2f93c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - ci/create-rpm-package pull_request: env: os: RHEL @@ -41,17 +42,29 @@ jobs: name: ${{ needs.parsing.outputs.compname }} compvers: ${{ needs.parsing.outputs.compvers }} arch: ${{ needs.parsing.outputs.comparch }} - + container: + image: fedora:40 steps: - uses: actions/checkout@v4 - name: Install RPM - run: sudo apt update && sudo apt upgrade -y && sudo apt install rpm - + run: | + sudo dnf install rust cargo -y -v + export PATH=$PATH:$HOME/.cargo/bin/ + sudo dnf install rpm-build rpmdevtools -y -v + sudo dnf install cargo-rpm-macros -y -v + cargo install cargo-lock2rpmprovides + PROTOC_ZIP=protoc-28.0-linux-x86_64.zip + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v28.0/$PROTOC_ZIP + sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc + sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*' + rm -f $PROTOC_ZIP + - name: Setup for alumet run: | mkdir -p alumet - - name: Install alumet + + - name: Checkout alumet uses: actions/checkout@v4 with: repository: alumet-dev/alumet @@ -63,8 +76,31 @@ jobs: env: build_dir: "$(pwd)/build" run: | - echo $(pwd) - ls -al mkdir -p ${{ env.build_dir }}/SOURCES tar --exclude=".[^/]*" --exclude="./build" --transform 's|.|alumet|' -zcvf ${{ env.build_dir }}/SOURCES/alumet.tar.gz . - rpmbuild -ba --define "_topdir ${{ env.build_dir }}" specs/alumet.spec + rpmbuild -ba -vv --define "_topdir ${{ env.build_dir }}" --define "release ${{env.os}}${{env.os_version}}" specs/alumet.spec + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.name }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm + path: ./build/RPMS/${{ env.arch }}/alumet-${{ env.compvers }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm + + # publish: + # runs-on: ubuntu-latest + # needs: + # - packaging + # env: + # name: ${{ needs.parsing.outputs.compname }} + # compvers: ${{ needs.parsing.outputs.compvers }} + # arch: ${{ needs.parsing.outputs.comparch }} + + # steps: + # - name: Checkout git repository + # uses: actions/checkout@v4 + + # - name: Download artifact + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.name }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm + diff --git a/specs/alumet.spec b/specs/alumet.spec index e7bcb62..a18d233 100644 --- a/specs/alumet.spec +++ b/specs/alumet.spec @@ -1,15 +1,26 @@ -Name: ALUMET +Name: alumet Version: 0.5.0 -Release: 1%{?dist} +Release: %{release} Summary: A tool for measuring the energy consumption and performance metrics License: EUPL Url: https://github.com/alumet-dev/alumet -Source: %{name}_v%{version}.tar.gz +Source: %{name}.tar.gz BuildArch: x86_64 +%package alumet-local-agent +Summary: alumet-local-agent package +%description alumet-local-agent +This package contains the alumet app agent. -# Disable this line if you wish to support all platforms. -# In most situations, you will likely only target tier1 arches for user facing components. +%package alumet-relay-server +Summary: alumet-relay-server package +%description alumet-relay-server +This package contains the alumet alumet-relay-server. + +%package alumet-relay-client +Summary: alumet-relay-client package +%description alumet-relay-client +This package contains the alumet alumet-relay-client. %description Customizable and efficient tool for measuring the energy consumption and performance metrics of software on HPC, Cloud and Edge devices. @@ -19,21 +30,37 @@ Customizable and efficient tool for measuring the energy consumption and perform %build -%{cargo_build} - +cd alumet/app-agent +json=$(CARGO_TARGET_DIR=%{_builddir} cargo build --bins --release --all-features --message-format=json-render-diagnostics "$@") +executables=$(echo "$json" | grep -oP '"executable":"\K[^"]+' | tr '\n' ' ') +echo "$executables" > %{_builddir}/executables.txt + + + %install -pwd -ls -al -cd app-agent -%{cargo_install} -pwd -ls -al +mkdir -p %{buildroot}%{_bindir} +ls -al %{_builddir} +ls -al %{_builddir}/release/ +ls -al %{_builddir}/release/build/ +ls -al %{_builddir}/release/incremental +ls -al %{buildroot}%{_bindir} +executables=$(cat %{_builddir}/executables.txt) +for binary in $executables; do + filename=$(basename "$binary") + install -D -m 0755 "$binary" %{buildroot}%{_bindir}/"$filename" +done + + +%files alumet-local-agent +%{_bindir}/alumet-local-agent + +%files alumet-relay-server +%{_bindir}/alumet-relay-server + +%files alumet-relay-client +%{_bindir}/alumet-relay-client -%files -# %license LICENSE -%{_bindir}/alumet-agent - - -%clean -รน{cargo} \ No newline at end of file +%changelog +* Wed Sep 18 2024 Cyprien cyprien.pelisse-verdoux@eviden.com - 0.0.1 +- Initial package