gitlab-ci: Upload tracie artifacts to MinIO
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 9 Jul 2020 20:29:39 +0000 (22:29 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Jul 2020 09:22:19 +0000 (09:22 +0000)
Upload failed images and the results.yml file to MinIO, to facilitate
debugging.

Also, fix version checking when git is installed as Mesa is going to
output a different renderer string if git is installed.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-By: Rohan Garg <rohan.garg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5472>

.gitlab-ci.yml
.gitlab-ci/container/x86_build-base.sh
.gitlab-ci/container/x86_build.sh
.gitlab-ci/lava-gitlab-ci.yml
.gitlab-ci/piglit/run.sh
.gitlab-ci/prepare-artifacts.sh
.gitlab-ci/tracie-runner-gl.sh
.gitlab-ci/tracie-runner-vk.sh
.gitlab-ci/tracie/README.md
.gitlab-ci/tracie/tracie.py

index d407b388b245aa33148276e96674fb246914fb36..6ffe2bee5ed3f506cb3f75c12fc134018a9e444e 100644 (file)
@@ -203,7 +203,7 @@ x86_build-base:
     - .fdo.container-build@debian
     - .container
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_build-base "2020-06-12"
+    FDO_DISTRIBUTION_TAG: &x86_build-base "2020-07-21-tracie"
 
 .use-x86_build-base:
   extends:
@@ -221,7 +221,7 @@ x86_build:
   extends:
     - .use-x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_build "2020-07-20-jflags"
+    FDO_DISTRIBUTION_TAG: &x86_build "2020-07-21-tracie"
 
 .use-x86_build:
   variables:
@@ -235,7 +235,7 @@ i386_build:
   extends:
     - .use-x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &i386_build "2020-07-20-jflags"
+    FDO_DISTRIBUTION_TAG: &i386_build "2020-07-21-tracie"
 
 .use-i386_build:
   variables:
@@ -249,7 +249,7 @@ ppc64el_build:
   extends:
     - .use-x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &ppc64el_build "2020-07-20-jflags"
+    FDO_DISTRIBUTION_TAG: &ppc64el_build "2020-07-21-tracie"
 
 .use-ppc64el_build:
   variables:
@@ -263,7 +263,7 @@ s390x_build:
   extends:
     - .use-x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &s390x_build "2020-06-29-jflags"
+    FDO_DISTRIBUTION_TAG: &s390x_build "2020-07-21-tracie"
 
 .use-s390x_build:
   variables:
@@ -276,7 +276,7 @@ s390x_build:
 x86_test-base:
   extends: x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_test-base "2020-06-02"
+    FDO_DISTRIBUTION_TAG: &x86_test-base "2020-07-21-tracie"
 
 .use-x86_test-base:
   extends:
@@ -293,19 +293,19 @@ x86_test-base:
 x86_test-gl:
   extends: .use-x86_test-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_test-gl "2020-07-15-virgl"
+    FDO_DISTRIBUTION_TAG: &x86_test-gl "2020-07-21-tracie"
 
 # Debian 10 based x86 test image for VK
 x86_test-vk:
   extends: .use-x86_test-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_test-vk "2020-06-18-vkcts"
+    FDO_DISTRIBUTION_TAG: &x86_test-vk "2020-07-21-tracie"
 
 # Debian 9 based x86 build image (old LLVM)
 x86_build_old:
   extends: x86_build-base
   variables:
-    FDO_DISTRIBUTION_TAG: &x86_build_old "2020-06-29-jflags"
+    FDO_DISTRIBUTION_TAG: &x86_build_old "2020-07-21-tracie"
     FDO_DISTRIBUTION_VERSION: stretch-slim
 
 .use-x86_build_old:
index c904f34ebabf29de7de731ea9ffa91318611a8fa..748fea8652b731cb5506344d4dd97ef2a0d1e562 100644 (file)
@@ -8,6 +8,8 @@ export DEBIAN_FRONTEND=noninteractive
 apt-get install -y \
         ca-certificates \
         gnupg \
+        python3-pip \
+        python3-setuptools \
         unzip \
         wget
 
@@ -30,6 +32,7 @@ apt-get install -y --no-remove \
         g++ \
         g++-mingw-w64-x86-64 \
         gcc \
+        git \
         libclang-9-dev \
         libclc-dev \
         libelf-dev \
@@ -73,6 +76,8 @@ apt-get install -y --no-remove -t buster-backports \
         libllvm8 \
         meson
 
+# Needed for ci-fairy, this revision is able to upload files to MinIO
+pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates@6f5af7e5574509726c79109e3c147cee95e81366
 
 # for the vulkan overlay layer
 wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
index 9f616538e36d87f44ac9207cfc7214c04e024a0e..b2220a61faa899fe8e8f08a1ac9819506ad528dd 100644 (file)
@@ -12,7 +12,6 @@ STABLE_EPHEMERAL=" \
       autotools-dev \
       bzip2 \
       cmake \
-      git \
       gnupg \
       libgbm-dev \
       libtool \
index dbbf1ea7c0965d7707c5260e04a81288fa3c771c..9bd6f1fe392690c6191865ac5b2fb839da09abf8 100644 (file)
@@ -33,6 +33,7 @@ kernel+rootfs_armhf:
   variables:
     GIT_STRATEGY: none # testing doesn't build anything from source
     ENV_VARS: "DEQP_PARALLEL=6"
+    FIXED_ENV_VARS: "CI_PIPELINE_ID=${CI_PIPELINE_ID} CI_PROJECT_PATH=${CI_PROJECT_PATH} TRACIE_NO_UNIT_TESTS=1 TRACIE_UPLOAD_TO_MINIO=1"
     DEQP_VERSION: gles2
     ARTIFACTS_PREFIX: "https://minio-packet.freedesktop.org/mesa-lava/"
     MESA_URL: "https://minio-packet.freedesktop.org/artifacts/${CI_PROJECT_PATH}/${CI_PIPELINE_ID}/mesa-${ARCH}.tar.gz"
@@ -51,7 +52,7 @@ kernel+rootfs_armhf:
         --base-artifacts-url ${ARTIFACTS_URL} \
         --mesa-url ${MESA_URL} \
         --device-type ${DEVICE_TYPE} \
-        --env-vars "${ENV_VARS}" \
+        --env-vars "${ENV_VARS} ${FIXED_ENV_VARS}" \
         --deqp-version ${DEQP_VERSION} \
         --kernel-image-name ${KERNEL_IMAGE_NAME} \
         --kernel-image-type "${KERNEL_IMAGE_TYPE}" \
index c1f50b9751f5084d6382f11688d1644e8897f749..32d2fcd51dbe218820b29020b46c2a746795212a 100755 (executable)
@@ -8,10 +8,16 @@ VERSION=`cat install/VERSION`
 cd /piglit
 
 PIGLIT_OPTIONS=$(echo $PIGLIT_OPTIONS | head -n 1)
+set +e
 xvfb-run --server-args="-noreset" sh -c \
          "export LD_LIBRARY_PATH=$OLDPWD/install/lib;
-         wflinfo --platform glx --api gl --profile core | grep \"Mesa $VERSION\\\$\" &&
+         wflinfo --platform glx --api gl --profile core | tee /tmp/version.txt | grep \"Mesa $VERSION\\\$\" &&
          ./piglit run -j${FDO_CI_CONCURRENT:-4} $PIGLIT_OPTIONS $PIGLIT_PROFILES $OLDPWD/results"
+retVal=$?
+if [ $retVal -ne 0 ]; then
+    echo "Found $(cat /tmp/version.txt), expected $VERSION"
+fi
+set -e
 
 PIGLIT_RESULTS=${PIGLIT_RESULTS:-$PIGLIT_PROFILES}
 mkdir -p .gitlab-ci/piglit
index fb7cc6306d916f51649a21452314a8ad2c83b225..40e7bbb504667bebb70609fdfbeb4256c2c108e5 100755 (executable)
@@ -22,7 +22,7 @@ find install -name \*.so -exec $STRIP {} \;
 
 # Test runs don't pull down the git tree, so put the dEQP helper
 # script and associated bits there.
-cp VERSION install/
+echo "$(cat VERSION) (git-$(git rev-parse HEAD | cut -b -10))" >> install/VERSION
 cp -Rp .gitlab-ci/bare-metal install/
 cp -Rp .gitlab-ci/deqp* install/
 cp -Rp .gitlab-ci/piglit install/
@@ -41,12 +41,15 @@ cp -Rp .gitlab-ci/deqp-runner.sh install/
 cp -Rp .gitlab-ci/deqp-*-fails.txt install/
 cp -Rp .gitlab-ci/deqp-*-skips.txt install/
 
+ci-fairy minio login $CI_JOB_JWT
+# These credentials will be used for uploading artifacts from test jobs
+cp .minio_credentials install/
+
 # Tar up the install dir so that symlinks and hardlinks aren't each
 # packed separately in the zip file.
 mkdir -p artifacts/
 tar -cf artifacts/install.tar install
 
-# If the container has LAVA stuff, prepare the artifacts for LAVA jobs
 if [ -n "$UPLOAD_FOR_LAVA" ]; then
     # Pass needed files to the test stage
     cp $CI_PROJECT_DIR/.gitlab-ci/generate_lava.py artifacts/.
@@ -54,7 +57,6 @@ if [ -n "$UPLOAD_FOR_LAVA" ]; then
     cp $CI_PROJECT_DIR/.gitlab-ci/lava-tracie.yml.jinja2 artifacts/.
 
     gzip -c artifacts/install.tar > mesa-${DEBIAN_ARCH}.tar.gz
-    ci-fairy minio login $CI_JOB_JWT
     MINIO_PATH=minio-packet.freedesktop.org/artifacts/${CI_PROJECT_PATH}/${CI_PIPELINE_ID}
     ci-fairy minio cp mesa-${DEBIAN_ARCH}.tar.gz minio://${MINIO_PATH}/mesa-${DEBIAN_ARCH}.tar.gz
 fi
index 6eb5baadb26683e0be6adf0ab8fe883d00ca32c0..5c864b9ec1b89fff0b747cca6322f1aa4742559e 100755 (executable)
@@ -31,9 +31,12 @@ export PAGER=cat
 RESULTS=`pwd`/results
 mkdir -p $RESULTS
 
+# For artifact uploads to MinIO
+cp install/.minio_credentials .
+
 # Perform a self-test to ensure tracie is working properly.
 if [ -z "$TRACIE_NO_UNIT_TESTS" ]; then
-    python3 -m pytest -v --pyargs $INSTALL/tracie/tests/test.py
+    TRACIE_UPLOAD_TO_MINIO=0 python3 -m pytest -v --pyargs $INSTALL/tracie/tests/test.py
 fi
 
 if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
index f046b7c9b4052f571f6954708b5282e21dca3ba1..da34bd4d8d44063dba86c515f4b9f21f4315df9a 100755 (executable)
@@ -20,6 +20,9 @@ export WINEESYNC=1
 export DXVK_LOG_LEVEL="none"
 export DXVK_STATE_CACHE=0
 
+# For artifact uploads to MinIO
+cp install/.minio_credentials .
+
 # Perform a self-test to ensure tracie is working properly.
 python3 -m pytest -v --pyargs $INSTALL/tracie/tests/test.py
 
index 014bafc92e560034b08c5103a1ceedef3c8111b8..b0526564b46a72fe6cd8113fd348c5dc091e462a 100644 (file)
@@ -5,15 +5,13 @@ Home of the Mesa trace testing effort.
 
 ### Traces definition file
 
-The trace definition file contains information about the GitLab
-project and git commit to get the traces from, and a list of the
-traces to run along with their expected image checksums on each
-device. An example:
+The trace definition file contains information about the traces to run along
+with their expected image checksums on each device, and optionally from where to
+download them. An example:
 
 ```yaml
 traces-db:
-  gitlab-project-url: https://gitlab.freedesktop.org/gfx-ci/tracie/traces-db
-  commit: master
+  download-url: https://minio-packet.freedesktop.org/mesa-tracie-public/
 
 traces:
   - path: glmark2/jellyfish.rdc
@@ -40,12 +38,10 @@ with the [image_checksum.py](.gitlab-ci/tracie/image_checksum.py) script.
 Alternatively, an arbitrary checksum can be used, and during replay (see below)
 the scripts will report the mismatch and expected checksum.
 
-### Trace-db GitLab projects
+### Trace-db download urls
 
-The trace-db GitLab projects are assumed to have git repositories
-using LFS for their trace files. This is so that trace files can be
-potentially checked out and replayed individually, thus reducing
-storage requirements during CI runs.
+The trace-db:download-url property contains an HTTPS url from which traces can
+be downloaded, by appending traces:path properties to it.
 
 ### Enabling trace testing on a new device
 
@@ -94,6 +90,10 @@ applications. Traces for proprietary games and application are typically not
 redistributable, unless specific redistribution rights have been granted by the
 publisher.
 
+Trace files in a given repository are expected to be immutable once committed
+for the first time, so any changes need to be accompanied by a change in the
+file name (eg. by appending a _v2 suffix to the file).
+
 ### Replaying traces
 
 Mesa traces CI uses a set of scripts to replay traces and check the output
index b09bf4a90145f8b49dbf2cea3ae27ed230ab9df7..02797c0c88709cb043ff3fe625b7ea7811c4f7e7 100644 (file)
@@ -1,7 +1,11 @@
 import argparse
+import base64
+import datetime
 import enum
 import glob
 import hashlib
+import hmac
+import json
 import os
 import requests
 import sys
@@ -10,6 +14,7 @@ import time
 import yaml
 import shutil
 
+from email.utils import formatdate
 from pathlib import Path
 from PIL import Image
 from urllib import parse
@@ -55,6 +60,38 @@ def gitlab_ensure_trace(project_url, trace):
     open(trace_path, "wb").write(r.content)
     print("took %ds." % (time.time() - download_time), flush=True)
 
+def sign_with_hmac(key, message):
+    key = key.encode("UTF-8")
+    message = message.encode("UTF-8")
+
+    signature = hmac.new(key, message, hashlib.sha1).digest()
+
+    return base64.encodebytes(signature).strip().decode()
+
+def upload_artifact(file_name, content_type):
+    with open('.minio_credentials', 'r') as f:
+        credentials = json.load(f)["minio-packet.freedesktop.org"]
+        minio_key = credentials["AccessKeyId"]
+        minio_secret = credentials["SecretAccessKey"]
+        minio_token = credentials["SessionToken"]
+
+    resource = '/artifacts/%s/%s/%s' % (os.environ['CI_PROJECT_PATH'], os.environ['CI_PIPELINE_ID'], os.path.basename(file_name))
+    date = formatdate(timeval=None, localtime=False, usegmt=True)
+    url = 'https://minio-packet.freedesktop.org%s' % (resource)
+    to_sign = "PUT\n\n%s\n%s\nx-amz-security-token:%s\n%s" % (content_type, date, minio_token, resource)
+    signature = sign_with_hmac(minio_secret, to_sign)
+
+    with open(file_name, 'rb') as data:
+        headers = {'Host': 'minio-packet.freedesktop.org',
+                   'Date': date,
+                   'Content-Type': content_type,
+                   'Authorization': 'AWS %s:%s' % (minio_key, signature),
+                   'x-amz-security-token': minio_token}
+        print("Uploading artifact to %s" % url);
+        r = requests.put(url, headers=headers, data=data)
+        #print(r.text)
+        r.raise_for_status()
+
 def gitlab_check_trace(project_url, device_name, trace, expectation):
     gitlab_ensure_trace(project_url, trace)
 
@@ -82,6 +119,8 @@ def gitlab_check_trace(project_url, device_name, trace, expectation):
     results_path = os.path.join(RESULTS_PATH, dir_in_results)
     os.makedirs(results_path, exist_ok=True)
     shutil.move(log_file, os.path.join(results_path, os.path.split(log_file)[1]))
+    if not ok and os.environ.get('TRACIE_UPLOAD_TO_MINIO', '0') == '1':
+        upload_artifact(image_file, 'image/png')
     if not ok or os.environ.get('TRACIE_STORE_IMAGES', '0') == '1':
         image_name = os.path.split(image_file)[1]
         shutil.move(image_file, os.path.join(results_path, image_name))
@@ -116,6 +155,8 @@ def run(filename, device_name):
     os.makedirs(RESULTS_PATH, exist_ok=True)
     with open(os.path.join(RESULTS_PATH, 'results.yml'), 'w') as f:
         yaml.safe_dump(results, f, default_flow_style=False)
+    if os.environ.get('TRACIE_UPLOAD_TO_MINIO', '0') == '1':
+        upload_artifact(os.path.join(RESULTS_PATH, 'results.yml'), 'text/yaml')
 
     return all_ok