From 91500a155cb93eb239623de28ca494b96f4a622d Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 17 Aug 2025 14:30:55 -0500 Subject: [PATCH] Streamline the push and build process --- .gitlab-ci.yml | 74 +++++++--------------------------------------- .gitlab/always.yml | 38 ++++++++++++++++++++++++ .gitlab/build.yml | 27 +++++++++++++++++ 3 files changed, 76 insertions(+), 63 deletions(-) create mode 100644 .gitlab/always.yml create mode 100644 .gitlab/build.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1dedb3..5094a7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,17 @@ stages: - check - trigger +include: + # Low-effort, we can always do lint checks, validations, and so forth + - local: .gitlab/always.yml + # Actual download of ISOs and building of images. This should only be + # done some of the time + - local: .gitlab/build.yml + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_PIPELINE_SOURCE == "tag" + - if: $CI_COMMIT_BRANCH == "main" + variables: PACKER_CONFIG_DIR: ./packer_config/ PACKER_CACHE_DIR: ./cache/ @@ -11,66 +22,3 @@ default: image: registry.thehellings.com/greg/ci-images/vm-test:latest tags: - nix - -generate: - stage: generate - artifacts: - paths: - - distros/**/*.pkrvars.hcl - reports: - dotenv: build.env - script: nix run ".#generate" - -continue: - stage: generate - artifacts: - paths: - - .gitlab-ci-build.yml - script: - - nix build ".#continue" - - cp result .gitlab-ci-build.yml - - cat result - -shellcheck: - stage: generate - script: nix run ".#shellcheck" - -flake-check: - stage: generate - script: nix flake check - -validate: - stage: check - needs: - - generate - cache: - - key: - files: - - sources/build.pkr.hcl - paths: - - ./packer_config/ - script: nix run ".#validate" - -# Makes sure that all of the ISO files we are looking for are -# present on the S3 buckets that we use -downloads: - stage: check - retry: 2 - needs: - - generate - cache: - - key: - files: - - sources/build.pkr.hcl - paths: - - ./packer_config/ - script: nix run ".#cache" - -trigger: - stage: trigger - trigger: - include: - - artifact: .gitlab-ci-build.yml - job: continue - variables: - PARENT_PIPELINE_ID: $CI_PIPELINE_ID diff --git a/.gitlab/always.yml b/.gitlab/always.yml new file mode 100644 index 0000000..5c0a5b2 --- /dev/null +++ b/.gitlab/always.yml @@ -0,0 +1,38 @@ +generate: + stage: generate + artifacts: + paths: + - distros/**/*.pkrvars.hcl + reports: + dotenv: build.env + script: nix run ".#generate" + +continue: + stage: generate + artifacts: + paths: + - .gitlab-ci-build.yml + script: + - nix build ".#continue" + - cp result .gitlab-ci-build.yml + - cat result + +shellcheck: + stage: generate + script: nix run ".#shellcheck" + +flake-check: + stage: generate + script: nix flake check + +validate: + stage: check + needs: + - generate + cache: + - key: + files: + - sources/build.pkr.hcl + paths: + - ./packer_config/ + script: nix run ".#validate" diff --git a/.gitlab/build.yml b/.gitlab/build.yml new file mode 100644 index 0000000..9d0f951 --- /dev/null +++ b/.gitlab/build.yml @@ -0,0 +1,27 @@ +# These jobs actually fetch the downloads and trigger the +# target builds. I don't want to do that on every single push, +# but only when I'm part of a merge request or release event + +# Makes sure that all of the ISO files we are looking for are +# present on the S3 buckets that we use +downloads: + stage: check + retry: 2 + needs: + - generate + cache: + - key: + files: + - sources/build.pkr.hcl + paths: + - ./packer_config/ + script: nix run ".#cache" + +trigger: + stage: trigger + trigger: + include: + - artifact: .gitlab-ci-build.yml + job: continue + variables: + PARENT_PIPELINE_ID: $CI_PIPELINE_ID