diff mbox series

[XEN,3/3] automation: check for generated files

Message ID 20220301121133.19271-4-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series automation: auto-build container, check generated file | expand

Commit Message

Anthony PERARD March 1, 2022, 12:11 p.m. UTC
Try to find out whether genereted files that are commited needs to be
regenerated.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 automation/gitlab-ci/test.yaml           | 10 +++++
 automation/scripts/check-generated-files | 55 ++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100755 automation/scripts/check-generated-files
diff mbox series

Patch

diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
index 56747fb335..a4b08c26ca 100644
--- a/automation/gitlab-ci/test.yaml
+++ b/automation/gitlab-ci/test.yaml
@@ -25,6 +25,16 @@  build-each-commit-gcc:
   tags:
     - x86_64
 
+build-check-generated-files-tools:
+  extends: .test-jobs-common
+  variables:
+    CONTAINER: debian:stable
+  script:
+    - automation/scripts/check-generated-files
+  needs: []
+  tags:
+    - x86_64
+
 qemu-alpine-arm64-gcc:
   extends: .test-jobs-common
   variables:
diff --git a/automation/scripts/check-generated-files b/automation/scripts/check-generated-files
new file mode 100755
index 0000000000..054ea3e025
--- /dev/null
+++ b/automation/scripts/check-generated-files
@@ -0,0 +1,55 @@ 
+#!/bin/bash
+
+# Check that generated files that are commited are actually up to date
+
+check_git_status() {
+    output="$(git status --porcelain --untracked-files=no)"
+    if [ -n "$output" ]; then
+        echo
+        echo "Files potentially needs to be regenerated:"
+        echo "$output"
+        return 1
+    fi
+}
+
+set -e
+set -x
+
+# Try to have recently changed files more recent than generated files if those haven't been regenerated.
+if [[ "$CI_COMMIT_BEFORE_SHA" && "$CI_COMMIT_BEFORE_SHA" != 0000000000000000000000000000000000000000 ]]; then
+    git switch --detach $CI_COMMIT_BEFORE_SHA
+    git switch --detach -
+fi
+
+# Lists of files that generate other commited files:
+touch tools/libs/light/*.idl
+
+
+# Regen autoconf files
+./autogen.sh
+
+# build up our configure options
+cfgargs=()
+
+# Disable non-tools subsystems
+cfgargs+=("--disable-xen")
+cfgargs+=("--disable-stubdom")
+cfgargs+=("--disable-docs")
+
+
+# Disable external trees
+cfgargs+=("--with-system-seabios=/bin/false")
+cfgargs+=("--with-system-qemu=/bin/false")
+cfgargs+=("--with-system-ipxe=/usr/lib/ipxe/ipxe.pxe")
+cfgargs+=("--disable-ovmf")
+cfgargs+=("--disable-pvshim")
+cfgargs+=("--disable-qemu-traditional")
+
+
+./configure --quiet "${cfgargs[@]}"
+make -s -j$(nproc) build-tools
+
+if ! check_git_status; then
+    git diff
+    exit 1
+fi