From a9db25ae10b65d9f180f0cf3cfa58469423002b9 Mon Sep 17 00:00:00 2001
From: Sergey Vorontsov <piligrim@rootnix.net>
Date: Wed, 18 Oct 2023 18:58:04 +0300
Subject: [PATCH] ci: dockerize linux workflows

Modify Linux workflows for running jobs inside Docker containers. It
helps isolate the building and testing environment from the runner's
system and other workflows.

Closes tarantool/tarantool-qa#327

NO_DOC=ci
NO_TEST=ci
NO_CHANGELOG=ci

(cherry picked from commit af996bbb920372f0323fcb68b5a47b8727c172ee)
---
 .github/workflows/codeql.yml                        | 10 ++++++++++
 .github/workflows/coverage.yml                      | 13 +++++++++++++
 .github/workflows/debug.yml                         | 13 +++++++++++++
 .github/workflows/debug_aarch64.yml                 | 13 +++++++++++++
 .github/workflows/lint.yml                          |  9 +++++++++
 .../workflows/memtx_allocator_based_on_malloc.yml   | 13 +++++++++++++
 .github/workflows/out_of_source.yml                 | 13 +++++++++++++
 .github/workflows/release.yml                       | 13 +++++++++++++
 .github/workflows/release_lto.yml                   | 13 +++++++++++++
 .github/workflows/source.yml                        |  3 +++
 .github/workflows/static_build.yml                  | 13 +++++++++++++
 .github/workflows/static_build_cmake_linux.yml      | 13 +++++++++++++
 .github/workflows/submodule_update.yml              |  3 +++
 13 files changed, 142 insertions(+)

diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 07f265ee74..a1a47b8776 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -27,6 +27,16 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--privileged'
+
     steps:
     - name: Prepare checkout
       uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index d5faf72af4..78f214d24b 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml
index 780f76e3cb..a72763d791 100644
--- a/.github/workflows/debug.yml
+++ b/.github/workflows/debug.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/debug_aarch64.yml b/.github/workflows/debug_aarch64.yml
index 16a2f87e17..f8d1c9d341 100644
--- a/.github/workflows/debug_aarch64.yml
+++ b/.github/workflows/debug_aarch64.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: graviton
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 731689fdab..9bbf9a58c2 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -40,6 +40,9 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
@@ -67,6 +70,9 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
@@ -94,6 +100,9 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/memtx_allocator_based_on_malloc.yml b/.github/workflows/memtx_allocator_based_on_malloc.yml
index 81f456c325..3697c9e5cc 100644
--- a/.github/workflows/memtx_allocator_based_on_malloc.yml
+++ b/.github/workflows/memtx_allocator_based_on_malloc.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/out_of_source.yml b/.github/workflows/out_of_source.yml
index 74c7669dbe..fab4ace0ba 100644
--- a/.github/workflows/out_of_source.yml
+++ b/.github/workflows/out_of_source.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 46c41440f8..e0488aba8d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/release_lto.yml b/.github/workflows/release_lto.yml
index 852deb62a6..9b3afa4809 100644
--- a/.github/workflows/release_lto.yml
+++ b/.github/workflows/release_lto.yml
@@ -40,6 +40,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/source.yml b/.github/workflows/source.yml
index ac771e9bd4..dfa877782c 100644
--- a/.github/workflows/source.yml
+++ b/.github/workflows/source.yml
@@ -15,6 +15,9 @@ jobs:
 
     runs-on: ubuntu-22.04
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+
     steps:
       - uses: actions/checkout@v3
         with:
diff --git a/.github/workflows/static_build.yml b/.github/workflows/static_build.yml
index 1abc71c635..ffe2843932 100644
--- a/.github/workflows/static_build.yml
+++ b/.github/workflows/static_build.yml
@@ -41,6 +41,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/static_build_cmake_linux.yml b/.github/workflows/static_build_cmake_linux.yml
index 16bc449acc..d7c923db4f 100644
--- a/.github/workflows/static_build_cmake_linux.yml
+++ b/.github/workflows/static_build_cmake_linux.yml
@@ -41,6 +41,19 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+      # Mount /dev to the container to be able to mount a disk image inside it
+      # for successful run of the .github/actions/environment action.
+      volumes:
+        - /dev:/dev
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      # Add extra privileges to the container for successful run
+      # of the .github/actions/environment action.
+      options: '--init --privileged'
+
     steps:
       - name: Prepare checkout
         uses: tarantool/actions/prepare-checkout@master
diff --git a/.github/workflows/submodule_update.yml b/.github/workflows/submodule_update.yml
index cf5a397474..208d1e2b65 100644
--- a/.github/workflows/submodule_update.yml
+++ b/.github/workflows/submodule_update.yml
@@ -18,6 +18,9 @@ jobs:
 
     runs-on: [ self-hosted, Linux, x86_64, flavor-1-2 ]
 
+    container:
+      image: docker.io/tarantool/testing:ubuntu-focal
+
     outputs:
       commit-sha: ${{ steps.update-ee.outputs.sha }}
 
-- 
GitLab