Skip to content

Commit 0803f96

Browse files
committed
Properly apt-get install inn2 in a GitHub Action.
Demonstrate how to properly `apt-get install inn2` in a GitHub Action. Configure the inn2 instance so that other code can test interactions with the inn2 server. Much of this project's documentation covers how to build inn2 from source. It would be helpful if there were working examples of how to `apt-get install inn2` in Docker or in a GitHub Action. I have been struggling to do so for a few hours without success.
1 parent 1643b4c commit 0803f96

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Demonstrate how to properly `apt-get install inn2` in a GitHub Action.
2+
# Configure the inn2 instance so that other code can test interactions with the inn2 server.
3+
4+
name: InterNetNews2
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
workflow_dispatch:
11+
jobs:
12+
inn2:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: cat "localhost.localdomain" > /etc/hostname
17+
run: |
18+
echo "localhost.localdomain" > hostname
19+
sudo mv hostname /etc/
20+
cat /etc/hostname
21+
# The next commands usually pass but not always!!!
22+
- run: |
23+
sudo apt-get update -qq
24+
sudo apt-get install --yes inn2
25+
# - run: cat /etc/news/inn.conf # Useful for debugging
26+
- run: systemctl status inn2
27+
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: 3.12 # nntplib was removed from the Standard Library in Python 3.13.
31+
32+
- name: nntplib_demo
33+
shell: python
34+
run: |
35+
import nntplib # Removed from the Standard Library in Python 3.13.
36+
import pathlib
37+
with nntplib.NNTP("localhost", readermode=True) as nntp_server:
38+
print(f"{nntp_server = }")
39+
# print(f"{nntp_server.starttls() = }") # nntplib.NNTPTemporaryError: 401 MODE-READER
40+
print(f"{nntp_server.nntp_version = }")
41+
print(f"{nntp_server.nntp_implementation = }")
42+
print(f"{nntp_server.getwelcome() = }")
43+
print(f"{nntp_server.getcapabilities() = }")
44+
print(f"{nntp_server.list() = }")
45+
print("News group list:")
46+
print("\n".join(
47+
f"{i}. {group_info.group}" for i, group_info in enumerate(nntp_server.list()[1], 1)
48+
))
49+
# Ensure the 'local.test' group has no articles.
50+
resp, count, first, last, name = nntp_server.group('local.test')
51+
print(f"Group '{name}' has {count} articles, range {first} to {last}.")
52+
# Post an article to the 'local.test' group.
53+
msg = pathlib.Path("contrib/inn_article_001.txt").read_text()
54+
# print(f"{msg = }")
55+
response = nntp_server.post(msg.encode("utf-8"))
56+
print(f"{response = }")
57+
# Verify that the article is there.
58+
resp, count, first, last, name = nntp_server.group('local.test')
59+
print(f"Group '{name}' has {count} articles, range {first} to {last}.")
60+
# Read the article.
61+
stat = nntp_server.stat() # last() and next() both fail
62+
# print(f"{stat = }")
63+
article = nntp_server.article(stat[2])
64+
print(f"{article = }")
65+
# Print the lines of the article
66+
print("\n".join(line.decode("utf-8") for line in article[1].lines))
67+
# Print the overview information
68+
resp, count, first, last, name = nntp_server.group('local.test')
69+
# print(resp, count, first, last, name)
70+
resp, overviews = nntp_server.over((first, last))
71+
for id, over in overviews:
72+
print(id, nntplib.decode_header(over['subject']))

contrib/inn_article_001.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
From: GitHub Actions <actions@github.com>
2+
Newsgroups: local.test
3+
Subject: inews test
4+
Message-ID: <test.inews.1@inn2.packages.debian.org>
5+
6+
This is a test message posted to the local.test group.

support/mkmanifest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ __DATA__
7171
7272
# The following additional files should be ignored. The file names are
7373
# relative to the root of the tree. Shell wildcards are supported.
74+
.github/workflows/atp-get_install_inn2.yaml
7475
BOOTSTRAP
7576
LIST.*
7677
Makefile.global
@@ -123,6 +124,7 @@ contrib/count_overview
123124
contrib/expirectl
124125
contrib/findreadgroups
125126
contrib/fixhist
127+
contrib/inn_article_001.txt
126128
contrib/innconfcheck
127129
contrib/makeexpctl
128130
contrib/makestorconf

0 commit comments

Comments
 (0)