From fc846006bc759436fd3256c8dda1745360d7d268 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 14 Sep 2024 18:15:27 +0200 Subject: [PATCH] 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. --- .github/workflows/atp-get_install_inn2.yaml | 72 +++++++++++++++++++++ contrib/inn_article_001.txt | 6 ++ support/mkmanifest | 2 + 3 files changed, 80 insertions(+) create mode 100644 .github/workflows/atp-get_install_inn2.yaml create mode 100644 contrib/inn_article_001.txt diff --git a/.github/workflows/atp-get_install_inn2.yaml b/.github/workflows/atp-get_install_inn2.yaml new file mode 100644 index 000000000..959c6124a --- /dev/null +++ b/.github/workflows/atp-get_install_inn2.yaml @@ -0,0 +1,72 @@ +# 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. + +name: InterNetNews2 +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: +jobs: + inn2: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: cat "localhost.localdomain" > /etc/hostname + run: | + echo "localhost.localdomain" > hostname + sudo mv hostname /etc/ + cat /etc/hostname + # The next commands usually pass but not always!!! + - run: | + sudo apt-get update -qq + sudo apt-get install --yes inn2 + # - run: cat /etc/news/inn.conf # Useful for debugging + - run: systemctl status inn2 + + - uses: actions/setup-python@v5 + with: + python-version: 3.12 # nntplib was removed from the Standard Library in Python 3.13. + + - name: nntplib_demo + shell: python + run: | + import nntplib # Removed from the Standard Library in Python 3.13. + import pathlib + with nntplib.NNTP("localhost", readermode=True) as nntp_server: + print(f"{nntp_server = }") + # print(f"{nntp_server.starttls() = }") # nntplib.NNTPTemporaryError: 401 MODE-READER + print(f"{nntp_server.nntp_version = }") + print(f"{nntp_server.nntp_implementation = }") + print(f"{nntp_server.getwelcome() = }") + print(f"{nntp_server.getcapabilities() = }") + print(f"{nntp_server.list() = }") + print("News group list:") + print("\n".join( + f"{i}. {group_info.group}" for i, group_info in enumerate(nntp_server.list()[1], 1) + )) + # Ensure the 'local.test' group has no articles. + resp, count, first, last, name = nntp_server.group('local.test') + print(f"Group '{name}' has {count} articles, range {first} to {last}.") + # Post an article to the 'local.test' group. + msg = pathlib.Path("contrib/inn_article_001.txt").read_text() + # print(f"{msg = }") + response = nntp_server.post(msg.encode("utf-8")) + print(f"{response = }") + # Verify that the article is there. + resp, count, first, last, name = nntp_server.group('local.test') + print(f"Group '{name}' has {count} articles, range {first} to {last}.") + # Read the article. + stat = nntp_server.stat() # last() and next() both fail + # print(f"{stat = }") + article = nntp_server.article(stat[2]) + print(f"{article = }") + # Print the lines of the article + print("\n".join(line.decode("utf-8") for line in article[1].lines)) + # Print the overview information + resp, count, first, last, name = nntp_server.group('local.test') + # print(resp, count, first, last, name) + resp, overviews = nntp_server.over((first, last)) + for id, over in overviews: + print(id, nntplib.decode_header(over['subject'])) \ No newline at end of file diff --git a/contrib/inn_article_001.txt b/contrib/inn_article_001.txt new file mode 100644 index 000000000..633aa7eee --- /dev/null +++ b/contrib/inn_article_001.txt @@ -0,0 +1,6 @@ +From: GitHub Actions +Newsgroups: local.test +Subject: inews test +Message-ID: + +This is a test message posted to the local.test group. diff --git a/support/mkmanifest b/support/mkmanifest index c75f9a701..22ae4b0ce 100755 --- a/support/mkmanifest +++ b/support/mkmanifest @@ -71,6 +71,7 @@ __DATA__ # The following additional files should be ignored. The file names are # relative to the root of the tree. Shell wildcards are supported. +.github/workflows/atp-get_install_inn2.yaml BOOTSTRAP LIST.* Makefile.global @@ -123,6 +124,7 @@ contrib/count_overview contrib/expirectl contrib/findreadgroups contrib/fixhist +contrib/inn_article_001.txt contrib/innconfcheck contrib/makeexpctl contrib/makestorconf