-
Notifications
You must be signed in to change notification settings - Fork 86
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
[RHELC-1748] Manpage generation check #1422
base: main
Are you sure you want to change the base?
Changes from all commits
fdb6c3f
8605004
2cf6892
d750568
fe28782
674ad99
773de3c
c0c1754
1400d37
148906c
f30d20e
6ea158e
1350c41
52e85d0
b8dbd5b
39e6fd7
2c92f8a
424f1de
6665577
3ee77a9
5746eae
da0033f
752aeb4
a2d3579
001fbde
512bff3
e7b219f
6b772ee
5e95a96
46750a7
88f9585
890a422
7bc9014
5168edb
1ceefaf
8fcf22d
89924ca
71e912d
d4d9c91
bf98f70
27c5eec
d4dadff
b0e6327
632ee69
7dbc24d
e5325da
859773d
d6fb1a7
419689d
3efe1d6
045404a
184b95f
5c8ace0
f702d2e
cd67883
874e81a
37af56b
b07b946
92a478d
084e04c
c1fac74
5dd979a
0794325
22b6c57
15052d9
82a8924
b5f7d7a
3a26cb0
e88f0dc
33bd3a9
a63333b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,103 @@ | ||
name: Generate Manpages | ||
name: Update Manpages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate-manpages: | ||
update-manpages: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.10.13 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install argparse-manpage six pexpect | ||
|
||
- name: Install python3-rpm and python3-dnf package with apt-get | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y python3-rpm python3-dnf | ||
|
||
- name: Generate Manpages | ||
run: | | ||
chmod +x scripts/manpage_generation.sh | ||
bash scripts/manpage_generation.sh | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Add Universe Repository | ||
run: | | ||
sudo add-apt-repository universe | ||
sudo apt-get update | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -y python3-pip rpm libnspr4-dev libnss3-dev libpopt-dev libarchive-dev libdb-dev \ | ||
autoconf automake bison flex gettext libtool pkg-config | ||
pip install --upgrade pip | ||
pip install pexpect argparse-manpage six | ||
|
||
- name: Create /etc/convert2rhel.ini | ||
run: | | ||
sudo mkdir -p /etc | ||
sudo bash -c 'cat <<EOF > /etc/convert2rhel.ini | ||
[main] | ||
subscription_manager = placeholder_value | ||
host_metering = placeholder_value | ||
inhibitor_overrides = placeholder_value | ||
EOF' | ||
|
||
- name: Download and install RPM | ||
run: | | ||
wget http://ftp.rpm.org/releases/rpm-4.14.x/rpm-4.14.2.tar.bz2 | ||
tar -xjf rpm-4.14.2.tar.bz2 | ||
cd rpm-4.14.2 | ||
export PKG_CONFIG_PATH=/opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig | ||
export PYTHON_CFLAGS="-I/opt/hostedtoolcache/Python/3.10.15/x64/include/python3.10" | ||
export PYTHON_LIBS="-L/opt/hostedtoolcache/Python/3.10.15/x64/lib -lpython3.10" | ||
./configure --disable-nls --enable-python --without-lua | ||
make | ||
sudo make install | ||
cd python | ||
python3 setup.py install | ||
sudo ldconfig | ||
|
||
- name: Verify Python Path | ||
run: | | ||
python -c "import sys; print(sys.path)" | ||
python -c "import pexpect; print('pexpect module is available.')" | ||
python -c "import rpm; print('rpm module is available.')" | ||
|
||
- name: Debug CLI Attribute | ||
run: | | ||
python -c "import convert2rhel.cli as cli; print(dir(cli)); print(cli.CLI)" || exit 1 | ||
|
||
- name: Generate manpages | ||
run: | | ||
set -e | ||
|
||
# Directory to store the generated manpages | ||
MANPAGE_DIR='man' | ||
|
||
# Ensure the manpage directory exists | ||
mkdir -p "$MANPAGE_DIR" | ||
|
||
echo 'Generating manpages' | ||
|
||
# Add debug statements | ||
python -c 'import convert2rhel.cli as cli; print(dir(cli)); print(cli.CLI)' || exit 1 | ||
|
||
# Generate a file with convert2rhel synopsis for argparse-manpage | ||
python -c 'from convert2rhel.cli import CLI; print("[synopsis]\n."+CLI.usage())' > "$MANPAGE_DIR/synopsis" | ||
|
||
# Extract the current version from the spec file | ||
CURRENT_VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) | ||
echo 'Current version: $CURRENT_VER' | ||
|
||
# Generate the manpage using argparse-manpage | ||
PYTHONPATH=. argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title='General Commands Manual' --description='Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux.' --project-name 'convert2rhel $CURRENT_VER' --prog='convert2rhel' --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" | ||
|
||
# Check for differences in the generated manpage | ||
if ! git diff --quiet HEAD -- "$MANPAGE_DIR/convert2rhel.8"; then | ||
echo 'Manpages are outdated. Please update them.' | ||
exit 1 | ||
else | ||
echo 'Manpages are up-to-date.' | ||
exit 0 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Use the latest Fedora image as the base | ||
FROM quay.io/fedora/fedora:latest | ||
|
||
# Install system dependencies | ||
RUN dnf install -y \ | ||
python3 \ | ||
python3-pip \ | ||
python3-devel \ | ||
rpm-devel \ | ||
python3-rpm \ | ||
git \ | ||
&& dnf clean all | ||
|
||
# Install Python packages | ||
RUN pip3 install --upgrade pip | ||
RUN pip3 install pexpect argparse-manpage six | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the project files into the container | ||
COPY . /app | ||
|
||
# Copy the convert2rhel.ini configuration file into the container | ||
COPY config/convert2rhel.ini /etc/convert2rhel/convert2rhel.ini | ||
|
||
# Copy manpage_generation.sh from the scripts directory into the container | ||
COPY scripts/manpage_generation.sh /app/ | ||
|
||
# Ensure the script is executable | ||
RUN chmod +x /app/manpage_generation.sh | ||
|
||
# Set up entrypoint to run manpage_generation.sh | ||
ENTRYPOINT ["/app/manpage_generation.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,26 @@ | |
# Directory to store the generated manpages | ||
MANPAGE_DIR="man" | ||
|
||
echo Generating manpages | ||
# Ensure the manpage directory exists | ||
mkdir -p "$MANPAGE_DIR" | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
|
||
VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) | ||
echo "Generating manpages" | ||
|
||
echo Generating for version $VER | ||
# Generate a file with convert2rhel synopsis for argparse-manpage | ||
/usr/bin/python -c 'from convert2rhel import toolopts; print("[synopsis]\n."+toolopts.CLI.usage())' > man/synopsis | ||
python -c 'from convert2rhel import toolopts; print("[synopsis]\n."+toolopts.CLI.usage())' > "$MANPAGE_DIR/synopsis" | ||
|
||
/usr/bin/python -m pip install argparse-manpage six pexpect | ||
# Extract the current version from the spec file | ||
CURRENT_VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) | ||
echo "Current version: $CURRENT_VER" | ||
|
||
# Generate the manpage using argparse-manpage | ||
PYTHONPATH=. /usr/bin/python /home/runner/.local/bin/argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title="General Commands Manual" --description="Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux." --project-name "convert2rhel $VER" --prog="convert2rhel" --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" | ||
PYTHONPATH=. argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title="General Commands Manual" --description="Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux." --project-name "convert2rhel $CURRENT_VER" --prog="convert2rhel" --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're missing python call here. Does it still work locally? |
||
|
||
git status | ||
# Check for differences in the generated manpage | ||
if ! git diff --quiet HEAD -- "$MANPAGE_DIR/convert2rhel.8"; then | ||
echo "Manpages are outdated. Please update them." | ||
exit 1 | ||
else | ||
echo "Manpages are up-to-date." | ||
exit 0 | ||
fi | ||
Comment on lines
+22
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not enough to check with the previous version. I would like to see the manpages generated and the difference checked to see if there are any changes. Not just if the version changed.
As this will fail every time we submit a new version it's already too late to update too.