Skip to content

RPM build of engine in Fedora Copr #344

RPM build of engine in Fedora Copr

RPM build of engine in Fedora Copr #344

Workflow file for this run

---
name: RPM build of engine in Fedora Copr
on:
workflow_dispatch:
inputs:
lts-ver:
description: Engine Release (0 for nightly)
default: 0
required: true
pkg-num:
description: Engine PKG number (for LTS Release)
default: 1
required: true
git-ref:
description: Git Ref Branch
default: master
required: true
copr:
description: COPR Repository development for default
default: openquake-staging
required: true
schedule:
- cron: "0 19 * * *"
push:
branches:
- test_action_rpm
jobs:
build:
name: Submit and publish from Fedora 38 container
runs-on: ubuntu-latest
env:
GITHUB_DEF_BR: ${{ github.event.repository.default_branch }}
strategy:
matrix:
epel-release: [epel-7-x86_64, rocky+epel-8-x86_64, rocky+epel-9-x86_64]
#epel-release: [epel-7-x86_64, rocky+epel-8-x86_64]
# Run in Fedora container on Ubuntu VM
container:
image: fedora:38
options: --privileged
steps:
- name: Clone Repository (Latest)
uses: actions/checkout@v3
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v3
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- name: Install tooling for source RPM build
run: |
dnf --refresh -y install @development-tools @rpm-development-tools \
copr-cli mock make gcc openssl-devel bzip2-devel libffi-devel
- name: Deploy SPEC file from template
env:
REPO: oq-engine
BRANCH: HEAD
STABLE: ${{ github.event.inputs.lts-ver }}
PKG: ${{ github.event.inputs.pkg-num }}
run: |
pwd
ls -lrt
mkdir -p ~/rpmbuild/{RPMS,SOURCES,SPECS,SRPMS}
id
ls -lrt ~/rpmbuild/*
#
LIB=$(cut -d "-" -f 2 <<< ${{ env.REPO }})
VER=$(cat openquake/baselib/__init__.py | sed -n "s/^__version__[ ]*=[ ]*['\"]\([^'\"]\+\)['\"].*/\1/gp")
TIME=$(date +"%s")
echo "$LIB - ${SHA} - $VER $TIME"
echo "${SHA} ${{ env.REPO }} - ${{ env.BRANCH }}"
#
#
if [ "$STABLE" == "1" ]; then
sed "s/##_stable_##/${STABLE}/g;s/##_repo_##/${REPO}/g;s/##_version_##/${VER}/g;s/##_timestamp_##/${TIME}/g" rpm/python3-${REPO}.spec.inc > ~/rpmbuild/SPECS/python3-${REPO}.spec
cd ..
cp -pr oq-engine ${REPO}-${VER}
tar czf ~/rpmbuild/SOURCES/${REPO}-${VER}.tar.gz ${REPO}-${VER}
#git archive --format=tar --prefix=${REPO}-${VER}/ $BRANCH | gzip -9 > build-rpm/SOURCES/${REPO}-${VER}.tar.gz
sed -i "s/##_release_##/${PKG}/g" ~/rpmbuild/SPECS/python3-${REPO}.spec
else
STABLE=0 # set to 0 to avoid failure for schedule run
sed "s/##_stable_##/${STABLE}/g;s/##_repo_##/${REPO}/g;s/##_version_##/${VER}/g;s/##_timestamp_##/${TIME}/g" rpm/python3-${REPO}.spec.inc > ~/rpmbuild/SPECS/python3-${REPO}.spec
#git archive --format=tar --prefix=${REPO}-${VER}-git${SHA}/ $BRANCH | gzip -9 > ~/rpmbuild/SOURCES/${REPO}-${VER}-git${SHA}.tar.gz
cd ..
cp -pr oq-engine ${REPO}-${VER}-git${SHA}
tar czf ~/rpmbuild/SOURCES/${REPO}-${VER}-git${SHA}.tar.gz ${REPO}-${VER}-git${SHA}
sed -i "s/##_release_##/git${SHA}/g" ~/rpmbuild/SPECS/python3-${REPO}.spec
fi
cat ~/rpmbuild/SPECS/python3-${REPO}.spec
ls ~/rpmbuild/SPECS/*
ls ~/rpmbuild/SOURCES/*
- name: Build RPM from SPEC files
env:
REPO: oq-engine
BRANCH: HEAD
STABLE: ${{ github.event.inputs.lts-ver }}
run: |
spectool -g -R ~/rpmbuild/SPECS/python3-${REPO}.spec
rpmbuild -bs ~/rpmbuild/SPECS/python3-${REPO}.spec
rpmbuild -bb ~/rpmbuild/SPECS/python3-${REPO}.spec
SRPM=$(ls ~/rpmbuild/SRPMS/*.src.rpm)
mock -r ${{ matrix.epel-release}} $SRPM
- name: Publish Package on COPR
env:
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
COPR_REPO: ${{ github.event.inputs.copr }}
run: |
mkdir -p "$HOME/.config"
echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr"
COPR_REPO=openquake-staging
echo "COPR REPO: $COPR_REPO"
SRPM=$(ls ~/rpmbuild/SRPMS/*.src.rpm)
copr-cli build ${COPR_REPO} $SRPM
- name: Upload artifacts of job
uses: actions/upload-artifact@v3
with:
name: srpm_files
path: ~/rpmbuild/SRPMS/*.src.rpm
retention-days: 5
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
test_rpm:
name: Test latest packages on RockyLinux8
needs: build
runs-on: ubuntu-latest
container:
image: rockylinux:8
options: --privileged
steps:
- name: Test created RPM use COPR Staging
env:
REPO: oq-engine
COPR_TEST: gem/openquake-staging
run: |
set -x
dnf update -y
dnf install -y dnf-plugins-core nc
dnf copr -y enable ${COPR_TEST}
#install oq-python3 required from RPM of engine
dnf install oq-python39 -y
dnf install python3-oq-engine -y
sleep 5
#
mkdir /var/log/oq-engine/
chown -R openquake /var/log/oq-engine/
runuser -l openquake -c '/opt/openquake/venv/bin/oq dbserver start &'
# Wait the DbServer to come up
echo "Waiting DBServer up on port 1907...."
while ! nc -z localhost 1907; do
sleep 2 # wait for 1/10 of the second before check again
done
sleep 3
oq --version
#
echo "Add settings for login and logging on webui before to start"
cd /opt/openquake/venv/lib/python3.9/site-packages/openquake/server/
ls -lrt
cat > local_settings.py << EOF
LOCKDOWN = True
#
WEBUI_ACCESS_LOG_DIR = '/var/log/oq-engine'
EOF
echo "DISPLAY content of local_settings"
cat local_settings.py
# START WEBUI
runuser -l openquake -c '/opt/openquake/venv/bin/oq webui start 127.0.0.1:8800 -s &'
echo "Waiting WEBUI up on port 8800...."
while ! nc -z localhost 8800; do
sleep 5 # wait for 1/10 of the second before check again
done
echo "Test WebUI with curl before to test django"
sleep 1
# Perform migration after setup local_settings
cd /opt/openquake/venv/lib/python3.9/site-packages/openquake/engine/
runuser -l openquake -c '/opt/openquake/venv/bin/oq webui migrate'
sleep 1
curl -L -I -X GET http://127.0.0.1:8800/accounts/login/
echo -n "TEST DJANGO LOGIN "
LOGIN_URL=http://127.0.0.1:8800/accounts/login/
YOUR_USER='username'
YOUR_PASS='password'
COOKIES=cookies.txt
CURL_BIN="curl -s -c $COOKIES -b $COOKIES -e $LOGIN_URL"
echo -n "Django Auth: get csrftoken ..."
$CURL_BIN $LOGIN_URL > /dev/null
DJANGO_TOKEN="csrfmiddlewaretoken=$(grep csrftoken $COOKIES | sed 's/^.*csrftoken\s*//')"
echo " perform login ..."
$CURL_BIN \
-d "$DJANGO_TOKEN&username=$YOUR_USER&password=$YOUR_PASS" \
-X POST $LOGIN_URL > /dev/null
echo "--------------------"
echo "display log of webui"
echo "--------------------"
cat /var/log/oq-engine/webui-access.log
if [ -s /var/log/oq-engine/webui-access.log ]; then
# The file is not-empty.
cat /var/log/oq-engine/webui-access.log
else
## The file is empty.
echo "Something not work as expected"
exit 1
fi
# Run a calcs using https
#
oq engine --run https://downloads.openquake.org/jobs/risk_test.zip
upload_copr:
name: downloads artifacts and publish from Fedora 38 container
needs: test_rpm
runs-on: ubuntu-latest
env:
GITHUB_DEF_BR: ${{ github.event.repository.default_branch }}
strategy:
matrix:
epel-release: [rocky+epel-9-x86_64]
container:
image: fedora:38
options: --privileged
steps:
- name: Create structure of downloaded files
run: mkdir -p ~/rpmbuild/{RPMS,SOURCES,SPECS,SRPMS}
- name: Download artifact of workflow to upload
uses: actions/download-artifact@v3
with:
name: srpm_files
path: ~/rpmbuild/SRPMS
- name: Display structure of downloaded files
run: ls -rl ~/rpmbuild/{RPMS,SOURCES,SPECS,SRPMS}
- name: Install tooling for source RPM build
run: |
dnf --refresh -y install @development-tools @rpm-development-tools \
copr-cli mock make gcc openssl-devel bzip2-devel libffi-devel
- name: Publish Package on COPR ${COPR_REPO}
env:
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
COPR_REPO: ${{ github.event.inputs.copr }}
run: |
mkdir -p "$HOME/.config"
echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr"
if [ "$COPR_REPO" != "" ]; then
echo "COPR REPO: $COPR_REPO"
SRPM=$(ls ~/rpmbuild/SRPMS/*.src.rpm)
copr-cli build ${COPR_REPO} $SRPM
else
COPR_REPO=openquake
echo "COPR REPO: $COPR_REPO"
SRPM=$(ls ~/rpmbuild/SRPMS/*.src.rpm)
copr-cli build ${COPR_REPO} $SRPM
fi