diff --git a/.github/workflows/debops-ci-pipeline.yml b/.github/workflows/debops-ci-pipeline.yml index 757e20894b..cfbc39ad61 100644 --- a/.github/workflows/debops-ci-pipeline.yml +++ b/.github/workflows/debops-ci-pipeline.yml @@ -1,21 +1,64 @@ --- # Copyright (C) 2021 Maciej Delmanowski -# Copyright (C) 2021 DebOps +# Copyright (C) 2023 Berkhan Berkdemir +# Copyright (C) 2021-2024 DebOps # SPDX-License-Identifier: GPL-3.0-or-later # TODO: The CI pipeline is not finished yet, it needs more work around # preparing the environment and Ansible configuration for execution. -name: DebOps CI pipeline -on: [ 'workflow_dispatch' ] +name: 'DebOps CI Pipeline' +on: [ 'push', 'pull_request' ] jobs: + bootstrap_playbook: + runs-on: 'ubuntu-latest' + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Prepare the CI pipeline environment + uses: './.github/workflows/prepare-ci-pipeline' + + - name: Apply the playbook on the host + env: + PY_COLORS: 1 + ANSIBLE_FORCE_COLOR: 1 + run: | + source venv/bin/activate + cd ~/src/controller + debops run bootstrap --diff + debops run bootstrap --diff + + + common_playbook: + runs-on: 'ubuntu-latest' + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Prepare the CI pipeline environment + uses: './.github/workflows/prepare-ci-pipeline' + + - name: Apply the playbook on the host + env: + PY_COLORS: 1 + ANSIBLE_FORCE_COLOR: 1 + run: | + source venv/bin/activate + cd ~/src/controller + debops run common --diff + debops run common --diff + + apt_role: runs-on: 'ubuntu-latest' steps: - - name: Check out the repository - uses: 'actions/checkout@v3' + - name: Checkout code + uses: actions/checkout@v4 - name: Prepare the CI pipeline environment uses: './.github/workflows/prepare-ci-pipeline' @@ -25,6 +68,7 @@ jobs: PY_COLORS: 1 ANSIBLE_FORCE_COLOR: 1 run: | + source venv/bin/activate cd ~/src/controller debops run service/apt --diff debops run service/apt --diff @@ -34,8 +78,8 @@ jobs: runs-on: 'ubuntu-latest' steps: - - name: Check out the repository - uses: 'actions/checkout@v3' + - name: Checkout code + uses: actions/checkout@v4 - name: Prepare the CI pipeline environment uses: './.github/workflows/prepare-ci-pipeline' @@ -45,17 +89,18 @@ jobs: PY_COLORS: 1 ANSIBLE_FORCE_COLOR: 1 run: | + source venv/bin/activate cd ~/src/controller debops run service/apt_listchanges --diff debops run service/apt_listchanges --diff - python_role: + mariadb_server_role: runs-on: 'ubuntu-latest' steps: - - name: Check out the repository - uses: 'actions/checkout@v3' + - name: Checkout code + uses: actions/checkout@v4 - name: Prepare the CI pipeline environment uses: './.github/workflows/prepare-ci-pipeline' @@ -65,27 +110,61 @@ jobs: PY_COLORS: 1 ANSIBLE_FORCE_COLOR: 1 run: | + source venv/bin/activate cd ~/src/controller - printf "[debops_service_python]\nlocalhost\n" >> ansible/inventory/hosts - debops run service/python --diff - debops run service/python --diff + cat <> ansible/inventory/hosts + [debops_service_mariadb_server] + localhost + EOL + debops run service/mariadb_server --diff + debops run service/mariadb_server --diff - common_playbook: + postgresql_server_role: runs-on: 'ubuntu-latest' steps: - - name: Check out the repository - uses: 'actions/checkout@v3' + - name: Checkout code + uses: actions/checkout@v4 - name: Prepare the CI pipeline environment uses: './.github/workflows/prepare-ci-pipeline' - - name: Apply the playbook on the host + - name: Apply the role on the host env: PY_COLORS: 1 ANSIBLE_FORCE_COLOR: 1 run: | + source venv/bin/activate cd ~/src/controller - debops common --diff - debops common --diff + cat <> ansible/inventory/hosts + [debops_service_postgresql_server] + localhost + EOL + debops run service/postgresql_server --diff + debops run service/postgresql_server --diff + + + python_role: + runs-on: 'ubuntu-latest' + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Prepare the CI pipeline environment + uses: './.github/workflows/prepare-ci-pipeline' + + - name: Apply the role on the host + env: + PY_COLORS: 1 + ANSIBLE_FORCE_COLOR: 1 + run: | + source venv/bin/activate + cd ~/src/controller + cat <> ansible/inventory/hosts + [debops_service_python] + localhost + EOL + debops run service/python --diff + debops run service/python --diff diff --git a/.github/workflows/prepare-ci-pipeline/action.yml b/.github/workflows/prepare-ci-pipeline/action.yml index 5c393864d6..b581f71d39 100644 --- a/.github/workflows/prepare-ci-pipeline/action.yml +++ b/.github/workflows/prepare-ci-pipeline/action.yml @@ -1,6 +1,7 @@ --- # Copyright (C) 2021 Maciej Delmanowski -# Copyright (C) 2021 DebOps +# Copyright (C) 2023 Berkhan Berkdemir +# Copyright (C) 2021-2024 DebOps # SPDX-License-Identifier: GPL-3.0-or-later name: Prepare CI pipeline environment @@ -12,16 +13,31 @@ runs: - name: Add ~/.local/bin to $PATH run: 'printf "%s/.local/bin\n" "${HOME}" >> ${GITHUB_PATH}' - shell: 'bash' + shell: bash - - name: Prepare test environment + - name: Install system dependencies run: | sudo apt-get -qq update - sudo apt-get remove --purge -yq ansible python python2.7 python2.7-minimal - pip3 install --user --upgrade pip wheel "setuptools==65.7.0" - pip3 install --user --upgrade Jinja2 ansible - pip3 install --user . - debops-init ~/src/controller - printf "[debops_all_hosts]\nlocalhost ansible_connection=local\n" \ - >> ~/src/controller/ansible/inventory/hosts - shell: 'bash' + sudo apt-get install build-essential python3-dev libffi-dev libssl-dev \ + libsasl2-dev libldap2-dev libpq-dev python3-pip python3-psycopg2 + shell: bash + + - name: Configure VirtualEnv and install Python dependencies + run: | + python3 -m venv venv + source venv/bin/activate + pip install wheel "setuptools==65.7.0" + pip install -r requirements-integration.txt + pip install . + shell: bash + + - name: Initialize DebOps project + run: | + source venv/bin/activate + debops project init ~/src/controller + cd ~/src/controller + cat <> ansible/inventory/hosts + [debops_all_hosts] + localhost ansible_connection=local + EOL + shell: bash diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0928e51d1f..29a4ac5935 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -67,6 +67,9 @@ General :file:`~/.ssh/authorized_keys` files correctly using optional ``follow`` parameter. +- The DebOps CI pipeline in GitHub Actions is improved and will be executed on + pull requests and pushes to test changes before merging them. + :ref:`debops.gitlab_runner` role '''''''''''''''''''''''''''''''' diff --git a/requirements-integration.txt b/requirements-integration.txt new file mode 100644 index 0000000000..1936ca9a09 --- /dev/null +++ b/requirements-integration.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2023 Berkhan Berkdemir +# Copyright (C) 2024 DebOps +# SPDX-License-Identifier: GPL-3.0-or-later + +# List of Python packages used by GitHub CI pipeline for continuous integration + +ansible==8.0.0a1 +ansible-core==2.15.0b2 +cffi==1.16.0 +cryptography==41.0.5 +distro==1.8.0 +dnspython==2.4.2 +future==0.18.3 +Jinja2==3.1.2 +MarkupSafe==2.1.3 +netaddr==0.9.0 +packaging==23.2 +passlib==1.7.4 +pyasn1==0.5.0 +pyasn1-modules==0.3.0 +pycparser==2.21 +pyOpenSSL==23.2.0 +python-dotenv==1.0.0 +python-ldap==3.4.3 +pyxdg==0.28 +PyYAML==6.0.1 +resolvelib==0.8.1 +toml==0.10.2