[pitivi/thiblahute/pre_commit_ci: 1/4] Run our pre commit hooks on the CI server




commit a4f41f9710dc1a497b94adf7965a4d67575f85a9
Author: Thibault Saunier <tsaunier igalia com>
Date:   Wed May 20 15:11:48 2020 -0400

    Run our pre commit hooks on the CI server
    
    And fix some minor issues that were in the code

 .gitlab-ci.yml                       | 68 ++++++++++++++++++++----------------
 .pre-commit-config.yaml              | 13 +++++++
 data/gstpresets/jpeg-raw-in-qt.gep   |  1 -
 data/gstpresets/prores-raw-in-qt.gep |  2 +-
 pitivi/dialogs/prefs.py              |  2 +-
 5 files changed, 53 insertions(+), 33 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6a6745f2d..b1540797e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,9 +5,8 @@ stages:
   - deploy
 
 variables:
-  MANIFEST: build/flatpak/org.pitivi.Pitivi.json
+  MANIFEST: /build/pitivi/build/flatpak/org.pitivi.Pitivi.json
   DBUS_ID: org.pitivi.Pitivi
-  XUNIT_PATH: ${CI_PROJECT_DIR}/xunit.xml
   GST_DEBUG_NO_COLOR: "true"
 
 
@@ -26,16 +25,23 @@ pitivi:master:
     - export NAMESPACE="$(echo "${CI_PROJECT_NAMESPACE}" | tr A-Z a-z)"
     - export IMAGE="${CI_REGISTRY}/${NAMESPACE}/${CI_PROJECT_NAME}:master-sdk_3.38"
     - export BASE_IMAGE="registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.38"
-    - export TMPIMAGENAME="tmp-pitivi-master-sdk_3.38"
-    - export BUILDDIR="\${HOME}/pitivi"
-    - export CLONE_PITIVI="git clone ${CI_PROJECT_URL}.git --single-branch \${HOME}/pitivi -b 
${CI_COMMIT_REF_NAME}"
-    - export BUILD_PITIVI="flatpak-builder --user --disable-rofiles-fuse ${BUILDDIR}/app 
${BUILDDIR}/build/flatpak/org.pitivi.Pitivi.json --state-dir=\${HOME}/flatpak-cache --ccache"
+
+    # Commands to be run in the Docker image.
+    # Clone the Pitivi repo.
+    - export CLONE_PITIVI="git clone ${CI_PROJECT_URL}.git --single-branch /build/pitivi -b 
${CI_COMMIT_REF_NAME}"
+    # All the downloads, build dirs, build cache, etc. are stored in /build/flatpak-cache.
+    - export BUILD_PITIVI="flatpak-builder --user --disable-rofiles-fuse /build/flatpak-build-dir 
${MANIFEST} --state-dir=/build/flatpak-cache --ccache"
+    # Run pre-commit to download and cache the hooks.
+    - export PRE_COMMIT="cd /build/pitivi && flatpak-builder --disable-rofiles-fuse 
--filesystem=/build/pitivi --env=PRE_COMMIT_HOME=/build/pre-commit-home --share=network --run 
/build/flatpak-build-dir ${MANIFEST} pre-commit install-hooks"
+    # The /build/flatpak-build-dir since it's very large and can be recreated
+    # easily out of /build/flatpak-cache.
+    - export CLEANUP="rm -rf /build/pitivi && rm -rf /build/flatpak-build-dir"
 
     - env
 
-    - docker run --privileged --name ${TMPIMAGENAME} ${BASE_IMAGE} bash -c "${CLONE_PITIVI} && 
${BUILD_PITIVI} && rm -Rf ${BUILDDIR}"
-    - docker commit ${TMPIMAGENAME} ${IMAGE}
-    - docker rm ${TMPIMAGENAME}
+    - docker run --privileged --name local-pitivi-image ${BASE_IMAGE} bash -c "${CLONE_PITIVI} && 
${BUILD_PITIVI} && ${PRE_COMMIT} && ${CLEANUP}"
+    - docker commit local-pitivi-image ${IMAGE}
+    - docker rm local-pitivi-image
     - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
     - docker push ${IMAGE}
   only:
@@ -50,32 +56,35 @@ build:
     - flatpak
   image: registry.gitlab.gnome.org/gnome/pitivi:master-sdk_3.38
   variables:
-    BLACKLIST: >
-      -b tests.test_effects.EffectsPropertiesManagerTest.test_dependent_properties
+    XUNIT_PATH: ${CI_PROJECT_DIR}/xunit.xml
   script:
-    - export BUILDDIR=${HOME}/pitivi
-    - export MANIFEST=${BUILDDIR}/build/flatpak/org.pitivi.Pitivi.json
-    - export RUN_IN_SANDBOX="flatpak-builder --disable-rofiles-fuse --filesystem=${BUILDDIR} 
--filesystem=${CI_PROJECT_DIR} --env=PITIVI_DEVELOPMENT=1 --env=GST_DEBUG=2 --env=GST_DEBUG_NO_COLOR=true 
--run app ${MANIFEST}"
-    - export FLATPAK_BUILDER_CACHE="--state-dir=${HOME}/flatpak-cache"
-    - export FLATPAK_REPO="${CI_PROJECT_DIR}/flatpak_repo"
+    - export RUN_IN_SANDBOX="flatpak-builder --disable-rofiles-fuse --filesystem=${CI_PROJECT_DIR} 
--env=PITIVI_DEVELOPMENT=1 --env=GST_DEBUG=2 --env=GST_DEBUG_NO_COLOR=true 
--env=PRE_COMMIT_HOME=/build/pre-commit-home --env=SKIP=gitlab-ci-linter --run /build/flatpak-build-dir 
${MANIFEST}"
 
     - env
 
-    # Working around the fact that flatpak-builder *requires* the cache dir
-    # to be on the same filesystem as the build dir
-    - mv ${CI_PROJECT_DIR} ${BUILDDIR}
-    - mkdir -p ${CI_PROJECT_DIR}
+    # Move the Pitivi git repo so it has the same location as when the
+    # /build/flatpak-cache has been created.
+    - mv ${CI_PROJECT_DIR} /build/pitivi
+
+    # Create the folder as we need to store here the artifacts.
+    - mkdir ${CI_PROJECT_DIR}
+
+    # Recreate the flatpak build dir using the cache.
+    - flatpak-builder --user --disable-rofiles-fuse --state-dir=/build/flatpak-cache --disable-download 
--ccache --force-clean /build/flatpak-build-dir ${MANIFEST}
 
-    - cd ${BUILDDIR}
-    - flatpak-builder --user --disable-rofiles-fuse ${FLATPAK_BUILDER_CACHE} --disable-download --ccache 
--repo=${FLATPAK_REPO} --force-clean app build/flatpak/org.pitivi.Pitivi.json --subject="Rolling update for 
pitivi master" --body="See ${CI_JOB_URL}"
+    # Build Pitivi.
+    - cd /build/pitivi
     - ${RUN_IN_SANDBOX} meson mesonbuild/
     - ${RUN_IN_SANDBOX} ninja -C mesonbuild/
-    - xvfb-run -n 32 -s "-screen 0 640x480x24" ${RUN_IN_SANDBOX} gst-validate-launcher 
$PWD/tests/ptv_testsuite.py --dump-on-failure --timeout-factor 4 --xunit-file ${XUNIT_PATH} 
--logs-dir=${CI_PROJECT_DIR}/tests-logs ${BLACKLIST}
 
-    # For some reason GitLab fails to upload directories
-    - cd ${CI_PROJECT_DIR}/
-    - tar czf tests-logs.tar.gz tests-logs/
-    - tar cf flatpak_repo.tar flatpak_repo/
+    # Run the pre-commit hooks.
+    - ${RUN_IN_SANDBOX} pre-commit run --all-files
+
+    # Run the unit tests.
+    - xvfb-run -n 32 -s "-screen 0 640x480x24" ${RUN_IN_SANDBOX} gst-validate-launcher 
/build/pitivi/tests/ptv_testsuite.py --dump-on-failure --timeout-factor 4 --xunit-file ${XUNIT_PATH} 
--logs-dir ${CI_PROJECT_DIR}/tests-logs
+
+    # Create a flatpak repo.
+    - flatpak build-export ${CI_PROJECT_DIR}/flatpak_repo /build/flatpak-build-dir --subject="Rolling update 
for Pitivi master" --body="See ${CI_JOB_URL}"
   cache:
     paths:
       - flatpak-cache
@@ -83,8 +92,8 @@ build:
     expire_in: 30 days
     paths:
       - xunit.xml
-      - flatpak_repo.tar
-      - tests-logs.tar.gz
+      - flatpak_repo/
+      - tests-logs/
     reports:
       junit:
         - ${XUNIT_PATH}
@@ -95,7 +104,6 @@ deploy:
     - PitiviBuildMachine
   stage: deploy
   script:
-    - tar xf flatpak_repo.tar
     - flatpak build-commit-from --src-repo=flatpak_repo /srv/http --timestamp=NOW --gpg-sign=739E841A
   only:
     - master@GNOME/pitivi
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 17a758c49..9d2a97ecf 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -27,6 +27,7 @@ repos:
         args:
           # http://www.pydocstyle.org/en/latest/error_codes.html
           - --ignore=D1,D203,D213,D401,D406,D407,D413
+        exclude: '.*pitivi/utils/extract.py$|.*pitivi/autoaligner.py$'
   - repo: https://gitlab.com/PyCQA/flake8
     rev: 3.7.9
     hooks:
@@ -35,6 +36,11 @@ repos:
           # http://flake8.pycqa.org/en/latest/user/error-codes.html
           # https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
           - --ignore=E402,E501,E722,F401,F841,W504
+        exclude: >
+          (?x)^(
+            pitivi/utils/extract.py|
+            pitivi/autoaligner.py|
+          )$
   - repo: local
     hooks:
       - id: pylint
@@ -42,6 +48,13 @@ repos:
         entry: python3 -m pylint.__main__ --rcfile=pylint.rc
         language: system
         types: [python]
+        exclude: >
+          (?x)^(
+            pitivi/utils/extract.py|
+            pitivi/autoaligner.py|
+            tests/validate-tests/manager.py|
+            bin/pitivi.in
+          )$
   - repo: https://github.com/adrienverge/yamllint.git
     rev: v1.20.0
     hooks:
diff --git a/data/gstpresets/jpeg-raw-in-qt.gep b/data/gstpresets/jpeg-raw-in-qt.gep
index bf3a86de6..876f60a33 100644
--- a/data/gstpresets/jpeg-raw-in-qt.gep
+++ b/data/gstpresets/jpeg-raw-in-qt.gep
@@ -23,4 +23,3 @@ presence=0
 pass=0
 variableframerate=false
 preset=Quality High
-
diff --git a/data/gstpresets/prores-raw-in-qt.gep b/data/gstpresets/prores-raw-in-qt.gep
index 4081291df..8b247f772 100644
--- a/data/gstpresets/prores-raw-in-qt.gep
+++ b/data/gstpresets/prores-raw-in-qt.gep
@@ -21,4 +21,4 @@ type=video
 format=video/x-prores
 presence=0
 pass=0
-variableframerate=false
\ No newline at end of file
+variableframerate=false
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index d8e0c21ae..14d593917 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -393,7 +393,7 @@ class PreferencesDialog(Loggable):
         index = 0
         for group in shortcuts_manager.groups:
             actions = shortcuts_manager.group_actions[group]
-            for action, title, _ in actions:
+            for action, title, _unused in actions:
                 item = ModelItem(self.app, action, title, group)
                 self.list_store.append(item)
                 self.action_ids[action] = index


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]