Merge pull request #546 from modoboa/feature/versioning
Added version check
This commit is contained in:
22
.github/workflows/installer.yml
vendored
22
.github/workflows/installer.yml
vendored
@@ -11,29 +11,29 @@ 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:
|
||||
- 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
|
||||
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' }}
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ matrix.python-version == '3.11' }}
|
||||
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.9'
|
||||
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
|
||||
|
||||
29
.github/workflows/versioning.yml
vendored
Normal file
29
.github/workflows/versioning.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Update version file
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
update-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
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 }}
|
||||
|
||||
- name: Commit & Push
|
||||
uses: Andro999b/push@v1.3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref_name }}
|
||||
force: true
|
||||
message: '[GitHub Action] Updated version file'
|
||||
37
checks.py
Normal file
37
checks.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""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 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)
|
||||
else:
|
||||
utils.success("Installer seems up to date!")
|
||||
|
||||
|
||||
def handle():
|
||||
check_version()
|
||||
12
run.py
12
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user