From 7bf0689cf523c4f40828eb708e37486c608be60d Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 26 Jul 2023 17:39:23 +0200 Subject: [PATCH] Add Github Action for CI --- .github/workflows/github-actions.yml | 46 +++++++++++++++++++++++++ policyd_rate_limit/tests/test_daemon.py | 12 +++---- tox.ini | 2 ++ 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..5def6f6 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,46 @@ +name: policyd-rate-limit +run-name: ${{ github.actor }} is running policyd-rate-limit CI tests +on: [push] +jobs: + flake8: + runs-on: ubuntu-latest + container: + image: python:bookworm + steps: + - uses: actions/checkout@v3 + - run: pip install tox + - run: apt-get update && apt-get install -y --no-install-recommends sudo + - run: useradd --uid 1000 testuser && mkdir -p /home/testuser && chown testuser -R . /home/testuser + - run: sudo -u testuser tox -e flake8 + check_rst: + runs-on: ubuntu-latest + container: + image: python:bookworm + steps: + - uses: actions/checkout@v3 + - run: pip install tox + - run: apt-get update && apt-get install -y --no-install-recommends sudo + - run: useradd --uid 1000 testuser && mkdir -p /home/testuser && chown testuser -R . /home/testuser + - run: sudo -u testuser tox -e check_rst + tests: + runs-on: ubuntu-latest + container: + image: python:bookworm + steps: + - uses: actions/checkout@v3 + - run: pip install tox + - run: apt-get update && apt-get install -y --no-install-recommends sudo + - run: useradd --uid 1000 testuser && mkdir -p /home/testuser && chown testuser -R . /home/testuser + - run: sudo -u testuser tox -e py3 + coverage: + runs-on: ubuntu-latest + container: + image: python:bookworm + steps: + - uses: actions/checkout@v3 + - run: pip install tox + - run: apt-get update && apt-get install -y --no-install-recommends sudo + - run: useradd --uid 1000 testuser && mkdir -p /home/testuser && chown testuser -R . /home/testuser + - run: sudo --preserve-env=COVERAGE_TOKEN -u testuser tox -e coverage + env: + COVERAGE_TOKEN: ${{ secrets.COVERAGE_TOKEN }} diff --git a/policyd_rate_limit/tests/test_daemon.py b/policyd_rate_limit/tests/test_daemon.py index 19cfa2e..155b39f 100644 --- a/policyd_rate_limit/tests/test_daemon.py +++ b/policyd_rate_limit/tests/test_daemon.py @@ -46,11 +46,11 @@ def test_main_afinet_socket(self): with test_utils.lauch(self.base_config) as cfg: self.base_test(cfg) - # travis CI has no IPv6 support - #def test_main_afinet6_socket(self): - # self.base_config["SOCKET"] = ["::1", 27184] - # with test_utils.lauch(self.base_config) as cfg: - # self.base_test(cfg) + # travis CI/Github Action has no IPv6 support + # def test_main_afinet6_socket(self): + # self.base_config["SOCKET"] = ["::1", 27184] + # with test_utils.lauch(self.base_config) as cfg: + # self.base_test(cfg) def test_no_debug_no_report(self): self.base_config["debug"] = False @@ -217,7 +217,7 @@ def test_already_running(self): f.write("") os.chmod(self.base_config["pidfile"], 0) with test_utils.lauch(self.base_config, get_process=True) as p: - self.assertEqual(p.wait(), 6) + self.assertEqual(p.wait(timeout=5), 6) finally: try: os.remove(self.base_config["pidfile"]) diff --git a/tox.ini b/tox.ini index 412cec0..09c56af 100644 --- a/tox.ini +++ b/tox.ini @@ -60,3 +60,5 @@ commands= coverage report coverage html {toxinidir}/.update_coverage "{toxinidir}" "policyd-rate-limit" +allowlist_externals= + {toxinidir}/.update_coverage