From 382a2d5a1266d8e52e57bf323191b85cc03946cd Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 14:01:19 +0200 Subject: [PATCH 01/11] Added github action --- .github/workflows/versioning.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/versioning.yml diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml new file mode 100644 index 0000000..d368512 --- /dev/null +++ b/.github/workflows/versioning.yml @@ -0,0 +1,25 @@ +name: Update version file + +on: push + +jobs: + update-version: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Overwrite file + uses: "DamianReeves/write-file-action@master" + with: + path: version.txt + write-mode: overwrite + contents: $GITHUB_SHA + + - name: Commit & Push + uses: Andro999b/push@v1.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main + force: true + message: '[GitHub Action] Updated version file' From 14f0da5c1f59097d53763c62e5caa47daf9798e5 Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 14:10:20 +0200 Subject: [PATCH 02/11] Updated versioning --- .github/workflows/versioning.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index d368512..1ac170b 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -7,19 +7,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v3 - + uses: actions/checkout@v4 + with: + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + ref: ${{ github.head_ref }} - name: Overwrite file uses: "DamianReeves/write-file-action@master" with: path: version.txt write-mode: overwrite - contents: $GITHUB_SHA + contents: ${{ GITHUB_SHA }} - name: Commit & Push uses: Andro999b/push@v1.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - branch: main + branch: ${{ github.ref_name }} force: true message: '[GitHub Action] Updated version file' From 6da31945d62c6839e8f53c82cfea9dd388e8d06f Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 14:11:35 +0200 Subject: [PATCH 03/11] fixed workflow --- .github/workflows/versioning.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 1ac170b..530fb30 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -16,7 +16,7 @@ jobs: with: path: version.txt write-mode: overwrite - contents: ${{ GITHUB_SHA }} + contents: ${GITHUB_SHA} - name: Commit & Push uses: Andro999b/push@v1.3 From 938629eb9767c2bb0bee110cfe0ccadf8664175f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Apr 2024 12:11:48 +0000 Subject: [PATCH 04/11] [GitHub Action] Updated version file --- version.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 version.txt diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..7734aa7 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +${GITHUB_SHA} \ No newline at end of file From ece8c309795387ec6e51a6e84a136780726b5aea Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 14:19:03 +0200 Subject: [PATCH 05/11] fixed version.txt content --- .github/workflows/versioning.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 530fb30..837ef9e 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -16,7 +16,7 @@ jobs: with: path: version.txt write-mode: overwrite - contents: ${GITHUB_SHA} + contents: ${{ github.sha }} - name: Commit & Push uses: Andro999b/push@v1.3 From ef1d7670dd9b4dddaa1473fde63e422df93606ae Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Apr 2024 12:20:19 +0000 Subject: [PATCH 06/11] [GitHub Action] Updated version file --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 7734aa7..5d5460a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -${GITHUB_SHA} \ No newline at end of file +d75f500cd85e7066d8837acdcc7f01f03f8f371a \ No newline at end of file From 64ba5eb5436bb63e2e55e259a8baf9381cce1e4b Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 16:12:36 +0200 Subject: [PATCH 07/11] Added checks on install --- .github/workflows/versioning.yml | 4 +++- checks.py | 33 ++++++++++++++++++++++++++++++++ run.py | 12 +++++++++++- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 checks.py diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 837ef9e..9879f00 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -1,6 +1,8 @@ name: Update version file -on: push +on: + push: + branches: [ master ] jobs: update-version: diff --git a/checks.py b/checks.py new file mode 100644 index 0000000..8a52cc3 --- /dev/null +++ b/checks.py @@ -0,0 +1,33 @@ +"""Checks to be performed before any install or upgrade""" + +import sys +from urllib.request import urlopen + +from modoboa_installer import utils + + +def check_version(): + local_version = "" + with open("version.txt", "r") as version: + local_version = version.readline() + remote_version = "" + with urlopen("https://raw.githubusercontent.com/modoboa/modoboa-installer/master/version.txt") as r_version: + remote_version = r_version.read().decode() + if local_version == "" or remote_version == "": + utils.printcolor("Could not check that your installer is up to date: " + f"local version: {local_version}, " + f"remote version: {remote_version}", + utils.YELLOW) + if remote_version != local_version: + utils.error("Your installer seems outdated.\n" + "Check the README for instruction on how to update.\n" + "No support will be provided without an up to date installer!") + answer = utils.user_input("Continue anyway? (Y/n) ") + if not answer.lower().startswith("y"): + sys.exit(0) + else: + utils.success("Installer seems up to date!") + + +def handle(): + check_version() diff --git a/run.py b/run.py index 6ceeacf..36cde1f 100755 --- a/run.py +++ b/run.py @@ -11,6 +11,7 @@ except ImportError: import ConfigParser as configparser import sys +import checks from modoboa_installer import compatibility_matrix from modoboa_installer import constants from modoboa_installer import package @@ -168,7 +169,10 @@ def main(input_args): "--restore", type=str, metavar="path", help="Restore a previously backup up modoboa instance on a NEW machine. " "You MUST provide backup directory" - ) + ), + parser.add_argument( + "--skip-checks"; action="store_true", default=False, + help="Skip the checks the installer performs initially") parser.add_argument("domain", type=str, help="The main domain of your future mail server") args = parser.parse_args(input_args) @@ -189,6 +193,12 @@ def main(input_args): utils.success("Welcome to Modoboa installer!\n") + # Checks + if not args.skip_checks: + utils.printcolor("Checking the installer...", utils.BLUE) + checks.handle() + utils.success("Checks complete") + is_config_file_available, outdate_config = utils.check_config_file( args.configfile, args.interactive, args.upgrade, args.backup, is_restoring) From a64c12bf9b2bd5fb53914ebcac6ef3181ff31361 Mon Sep 17 00:00:00 2001 From: Spitfireap Date: Fri, 12 Apr 2024 16:36:52 +0200 Subject: [PATCH 08/11] fixed typo --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 36cde1f..9ab6841 100755 --- a/run.py +++ b/run.py @@ -171,7 +171,7 @@ def main(input_args): "You MUST provide backup directory" ), parser.add_argument( - "--skip-checks"; action="store_true", default=False, + "--skip-checks", action="store_true", default=False, help="Skip the checks the installer performs initially") parser.add_argument("domain", type=str, help="The main domain of your future mail server") From fb961f93390fecd7b293a9fe5bdaa9c8e83c8f8b Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 24 Apr 2024 07:18:56 +0200 Subject: [PATCH 09/11] Updated worflow --- .github/workflows/installer.yml | 10 +++++----- checks.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index df9bfd6..b3f8a11 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.8, 3.9, 3.10, 3.11] fail-fast: false steps: @@ -24,15 +24,15 @@ jobs: run: | pip install -r test-requirements.txt - name: Run tests - if: ${{ matrix.python-version != '3.9' }} + if: ${{ matrix.python-version != '3.11' }} run: | python tests.py - name: Run tests and coverage - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} run: | coverage run tests.py - name: Upload coverage result - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} uses: actions/upload-artifact@v2 with: name: coverage-results @@ -46,7 +46,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.9' + python-version: '3.11' - name: Install dependencies run: | pip install codecov diff --git a/checks.py b/checks.py index 8a52cc3..a8022a7 100644 --- a/checks.py +++ b/checks.py @@ -14,14 +14,18 @@ def check_version(): with urlopen("https://raw.githubusercontent.com/modoboa/modoboa-installer/master/version.txt") as r_version: remote_version = r_version.read().decode() if local_version == "" or remote_version == "": - utils.printcolor("Could not check that your installer is up to date: " - f"local version: {local_version}, " - f"remote version: {remote_version}", - utils.YELLOW) + utils.printcolor( + "Could not check that your installer is up-to-date: " + f"local version: {local_version}, " + f"remote version: {remote_version}", + utils.YELLOW + ) if remote_version != local_version: - utils.error("Your installer seems outdated.\n" - "Check the README for instruction on how to update.\n" - "No support will be provided without an up to date installer!") + utils.error( + "Your installer seems outdated.\n" + "Check README file for instructions about how to update.\n" + "No support will be provided without an up-to-date installer!" + ) answer = utils.user_input("Continue anyway? (Y/n) ") if not answer.lower().startswith("y"): sys.exit(0) From 0d6507e2dc9765db007956c7f199e6319592b2ab Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 24 Apr 2024 07:21:45 +0200 Subject: [PATCH 10/11] Quote version numbers --- .github/workflows/installer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index b3f8a11..5932c98 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10, 3.11] + python-version: [3.8, 3.9, '3.10', '3.11'] fail-fast: false steps: From 8fec73ebbadc50e761e305f4142ae99b0183f4e3 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 24 Apr 2024 07:23:34 +0200 Subject: [PATCH 11/11] Updated version numbers in workflow --- .github/workflows/installer.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index 5932c98..d90fec6 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -15,9 +15,9 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -33,7 +33,7 @@ jobs: coverage run tests.py - name: Upload coverage result if: ${{ matrix.python-version == '3.11' }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage-results path: .coverage @@ -42,16 +42,16 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies run: | pip install codecov - name: Download coverage results - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: coverage-results - name: Report coverage