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 RPM packaging #23

Merged
merged 2 commits into from
Jan 31, 2024
Merged
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
44 changes: 18 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:

codespell:
name: Check common misspellings
if: false
runs-on: ubuntu-20.04
defaults:
run:
Expand All @@ -112,7 +113,7 @@ jobs:
generate-docs:
name: Generate project documentation
runs-on: ubuntu-20.04
if: github.event_name == 'push' && github.ref_name == 'main'
if: false
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
Expand Down Expand Up @@ -146,6 +147,7 @@ jobs:

static-code-analysis:
name: Static Code Analysis
if: false
needs: [elixir-deps, npm-deps, api-bc-check]
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -199,6 +201,7 @@ jobs:

test-fe:
name: Run FE tests
if: false
needs: npm-deps
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -226,6 +229,7 @@ jobs:

test:
name: Test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }})
if: false
needs: [elixir-deps, api-bc-check]
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -258,7 +262,7 @@ jobs:
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
- name: Compile
run: mix compile --warnings-as-errors
- name: "Docker compose dependencies"
- name: "Docker compose dependencies"
uses: isbang/compose-action@v1.5.1
with:
compose-file: "./docker-compose.yaml"
Expand All @@ -272,7 +276,7 @@ jobs:
name: Chromatic deployment
needs: [elixir-deps, npm-deps]
runs-on: ubuntu-20.04
if: github.event_name != 'repository_dispatch'
if: false
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
Expand Down Expand Up @@ -350,6 +354,7 @@ jobs:

test-e2e:
name: End to end tests
if: false
needs: [elixir-deps, npm-deps, npm-e2e-deps, api-bc-check]
runs-on: ubuntu-20.04
env:
Expand Down Expand Up @@ -399,7 +404,7 @@ jobs:
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('test/e2e/package-lock.json') }}
- name: Check Eslint and JS Code Format
run: cd test/e2e && npm run lint && npm run format:check
- name: "Docker compose dependencies"
- name: "Docker compose dependencies"
uses: isbang/compose-action@v1.5.1
with:
compose-file: "./docker-compose.yaml"
Expand Down Expand Up @@ -478,6 +483,7 @@ jobs:

api-bc-check:
name: API bc check
if: false
needs: [elixir-deps, main-branch-deps]
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -548,7 +554,7 @@ jobs:
build-and-push-container-images:
name: Build and push container images
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
if: false
needs: [static-code-analysis, test, test-fe, test-e2e]
permissions:
contents: read
Expand Down Expand Up @@ -586,7 +592,7 @@ jobs:
build-demo-img:
name: Build the docker image for the demo environment
runs-on: ubuntu-latest
if: github.event.action == 'deploy-demo' || github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
if: false
needs: [static-code-analysis, test, test-fe]
permissions:
contents: read
Expand Down Expand Up @@ -625,14 +631,7 @@ jobs:
deploy-demo-env:
name: Deploy updated images to the demo environment
runs-on: self-hosted
if: |
vars.DEPLOY_DEMO == 'true' &&
(
github.event_name == 'release' ||
github.event.action == 'deploy-demo' ||
(github.event_name == 'push' && github.ref_name == 'main') ||
github.event_name == 'workflow_dispatch'
)
if: false
env:
IMAGE_REPOSITORY: ghcr.io/${{ github.repository_owner }}
needs: [build-demo-img, test-e2e]
Expand Down Expand Up @@ -667,14 +666,7 @@ jobs:
run-photofinish-demo-env:
name: Use photofinish to push mock data to the demo environment
runs-on: ubuntu-20.04
if: |
vars.DEPLOY_DEMO == 'true' &&
(
github.event_name == 'release' ||
github.event.action == 'deploy-demo' ||
(github.event_name == 'push' && github.ref_name == 'main') ||
github.event_name == 'workflow_dispatch'
)
if: false
needs: deploy-demo-env
env:
TRENTO_DEMO_IP: ${{ secrets.TRENTO_DEMO_IP }}
Expand All @@ -700,7 +692,6 @@ jobs:
name: Commit the project on OBS
runs-on: ubuntu-20.04
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
needs: [static-code-analysis, test, test-fe, test-e2e]
container:
image: ghcr.io/trento-project/continuous-delivery:main
env:
Expand All @@ -710,6 +701,7 @@ jobs:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
RPM_NAME: $${ secrets.RPM_NAME }}
FOLDER: packaging/suse
REPOSITORY: ${{ github.repository }}
options: -u 0:0
Expand Down Expand Up @@ -757,12 +749,12 @@ jobs:
# "+" character is not allowed in OBS dockerfile version strings
VERSION=${VERSION//[+]/-}
sed -i 's~%%VERSION%%~'"${VERSION}"'~' packaging/suse/Dockerfile
- name: Commit on OBS
- name: Commit to RPM package on OBS
run: |
OBS_PACKAGE=$OBS_PROJECT/$NAME
OBS_PACKAGE=$OBS_PROJECT/$RPM_NAME
osc checkout $OBS_PACKAGE -o $DEST_FOLDER
cp -r packaging/suse/* $DEST_FOLDER
tar --transform 's,^./,/web/,' -zcvf $DEST_FOLDER/web.tar.gz --exclude=./.git ./*
cd $DEST_FOLDER
osc ar
osc commit -m "New development version of $NAME released"
osc commit -m "New development version of $RPM_NAME released"
18 changes: 18 additions & 0 deletions packaging/suse/rpm/_service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<services>
<service name="tar_scm" mode="manual">
<param name="url">https://github.com/%%REPOSITORY%%.git</param>
<param name="scm">git</param>
<param name="revision">%%REVISION%%</param>
<param name="exclude">.git</param>
<param name="exclude">.github</param>
<param name="versionformat">%%VERSION%%</param>
<param name="filename">trento-web</param>
</service>
<service name="set_version" mode="manual">
<param name="file">trento-web.spec</param>
</service>
<service name="recompress" mode="manual">
<param name="file">*.tar</param>
<param name="compression">gz</param>
</service>
</services>
11 changes: 11 additions & 0 deletions packaging/suse/rpm/systemd/env_trento_web
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
AMQP_URL=amqp://trento_user:trento_user_password@host.docker.internal/vhost
DATABASE_URL=ecto://trento_user:web_password@host.docker.internal/trento
EVENTSTORE_URL=ecto://trento_user:web_password@host.docker.internal/trento_event_store
ENABLE_ALERTING=false
PROMETHEUS_URL=http://host.docker.internal:9090
SECRET_KEY_BASE=zw/eHC77bbukYBwbkZFJb0YBCvZxqk27oYg816UyzshSo462a+pHe9D6/rj2WfdR
ACCESS_TOKEN_ENC_SECRET=7Ymy+mnLAroB3a9q1Z0fMa7cb9HPjTin4ULVmHDlphCE3p7lidvmju143ksj5rZN
REFRESH_TOKEN_ENC_SECRET=wnA562Bd00f40R4mfsZsP8lv5jhV+Psi4aFz1U0pwDo2bIX0j7iL7iw301ia8M+p
ADMIN_USERNAME=admin
ADMIN_PASSWORD=test1234
ENABLE_API_KEY=true
13 changes: 13 additions & 0 deletions packaging/suse/rpm/systemd/trento-web.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Trento web service

[Service]
ExecStart=/usr/lib/trento/bin/trento start
EnvironmentFile=/etc/trento/env_trento_web
Type=simple
User=root
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
63 changes: 63 additions & 0 deletions packaging/suse/rpm/trento-web.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# spec file for package trento-web
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name: trento-web
Version: 2.2.0
Release: 0
Summary: Trento server component
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
License: Apache-2.0
URL: https://www.trento-project.io
Source: https://github.com/trento-project/web/archive/refs/tags/%{version}.tar.gz
Group: System/Monitoring
BuildRequires: elixir, elixir-hex, npm16, erlang-rebar3, git-core

%description

%prep
%autosetup -n web

%build
npm run tailwind:build --prefix ./assets
npm run build --prefix ./assets
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_ALL=en_US.UTF-8
export MIX_ENV=prod
export MIX_HOME=/usr/bin
export MIX_REBAR3=/usr/bin/rebar3
export MIX_PATH=/usr/lib/elixir/lib/hex/ebin
echo $LANG
mix phx.digest
mix release

%install
mkdir -p %{buildroot}/usr/lib/trento
cp -a _build/prod/rel/trento %{buildroot}/usr/lib
ln -s %{buildroot}/usr/lib/trento/bin/trento

%post
%postun

%files
/usr/lib/trento

%license LICENSE
%doc CHANGELOG.md README.md

%changelog
Loading