From 8ac76fd62115d1c8fb75e6622dd3777f3308a494 Mon Sep 17 00:00:00 2001
From: Yaroslav Lobankov <y.lobankov@tarantool.org>
Date: Mon, 4 Oct 2021 13:32:53 +0300
Subject: [PATCH] ci: add workflow for checking module integration

For now, there is no testing for the tarantool project verifying its
integration with different modules and connectors from the ecosystem.
This is a quite huge gap in our CI system that is going to be covered
by these changes.

This patch introduces a couple of new workflow files that are named
'integration.yml' and 'reusable_build.yml'. The main workflow is
'integration.yml' that will run automatically per push to master and
release branches. Also, this workflow can be run manually against a
development branch. The 'reusable_build.yml' workflow is called by the
main workflow and builds needed tarantool packages (at this moment for
Ubuntu Focal Fossa only), then stores them as a build artifact. After
that, the main workflow calls the 'reusable_testing.yml' workflow from
a module project that tarantool is going to verify integration with.
The testing workflow should download the tarantool build artifact and
run tests against it.

The basic scheme describing the verification process is represented
below:

      integration.yml
             |
             |
             v
     reusable_build.yml --> <artifact>
             |                  |
             |                  |
             v                  |
    reusable_testing.yml <------+
             |
             |
             v
          <result>

For now, we start only with the vshard module. In the future, we are
going to extend the module list incrementally.

Part of #5265
Part of #6056
Closes #4972
---
 .github/workflows/integration.yml    | 24 ++++++++++
 .github/workflows/reusable_build.yml | 70 ++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)
 create mode 100644 .github/workflows/integration.yml
 create mode 100644 .github/workflows/reusable_build.yml

diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
new file mode 100644
index 0000000000..0727fb435f
--- /dev/null
+++ b/.github/workflows/integration.yml
@@ -0,0 +1,24 @@
+name: integration
+
+on:
+  push:
+    branches:
+      - 'master'
+      - '[0-9].[0-9]+'  # release branches
+    tags:
+      - '*'
+  workflow_dispatch:
+
+jobs:
+  tarantool:
+    uses: tarantool/tarantool/.github/workflows/reusable_build.yml@master
+    with:
+      ref: ${{ github.ref }}
+      os: ubuntu
+      dist: focal
+
+  vshard:
+    needs: tarantool
+    uses: tarantool/vshard/.github/workflows/reusable_testing.yml@master
+    with:
+      artifact_name: tarantool-ubuntu-focal-${{ github.sha }}
diff --git a/.github/workflows/reusable_build.yml b/.github/workflows/reusable_build.yml
new file mode 100644
index 0000000000..a11469a19e
--- /dev/null
+++ b/.github/workflows/reusable_build.yml
@@ -0,0 +1,70 @@
+name: reusable_build
+
+on:
+  workflow_call:
+    inputs:
+      ref:
+        description: |
+          The tarantool branch, tag, or commit SHA to checkout for build
+        default: master
+        required: false
+        type: string
+      os:
+        description: 'The name of the OS to build tarantool packages for'
+        default: ubuntu
+        required: false
+        type: string
+      dist:
+        description: 'The version of the OS'
+        default: focal
+        required: false
+        type: string
+
+jobs:
+  build:
+    runs-on: ubuntu-20.04
+    env:
+      OS: ${{ inputs.os }}
+      DIST: ${{ inputs.dist }}
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          ref: ${{ inputs.ref }}
+          # Fetch the entire history for all branches and tags.
+          fetch-depth: 0
+          # Enable recursive submodules checkout.
+          submodules: recursive
+      - name: 'Get the commit SHA'
+        id: get_sha
+        run: echo "::set-output name=sha::$(git log -1 --format='%H')"
+      - uses: ./.github/actions/environment
+      - name: 'Build tarantool packages for ${{ env.OS }}(${{ env.DIST }})'
+        id: run_build
+        env:
+          # 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.
+          PACKPACK_EXTRA_DOCKER_RUN_PARAMS: --init
+          # There are packages like tzdata or postfix, whose configuration
+          # is interactive by default. The environment variable below
+          # forbids interactive configuration phase. Otherwise the CI gets
+          # stuck from time to time on `apt-get update`.
+          DEBIAN_FRONTEND: noninteractive
+        run: make -f .gitlab.mk package
+      - name: 'Upload build artifacts'
+        uses: actions/upload-artifact@v2
+        with:
+          name: tarantool-${{ env.OS }}-${{ env.DIST }}-${{ steps.get_sha.outputs.sha }}
+          retention-days: 21
+          path: |
+            build/tarantool*.deb
+            build/tarantool*.rpm
+          if-no-files-found: error
+      - name: 'Upload logs if the build failed'
+        if: failure() && steps.run_build.conclusion == 'failure'
+        uses: actions/upload-artifact@v2
+        with:
+          name: tarantool-build-log-${{ env.OS }}-${{ env.DIST }}-${{ steps.get_sha.outputs.sha }}
+          retention-days: 21
+          path: build/*build*
+          if-no-files-found: error
-- 
GitLab