Files
vms/.gitlab-ci.yml
T
2024-04-10 13:42:59 -05:00

95 lines
2.1 KiB
YAML

stages:
- generate
- lint
- cache
- trigger
variables:
PACKER_CONFIG_DIR: ./packer_config/
PACKER_CACHE_DIR: ./cache/
generate:
stage: generate
artifacts:
paths:
- distros/**/*.pkrvars.hcl
script: |-
for vars in $(find distros/ -name '*.pkrvars.hcl.sh'); do
"./${vars}"
done
distros:
stage: generate
image: $CI_REGISTRY_DIRECT/greg/ci-images/fedora:latest
artifacts:
reports:
dotenv: build.env
paths:
- .gitlab-ci-build.yml
script: |-
xonsh ./build.xsh -a --list
echo "BUILD=$(date +'%Y.%m.%d.%H')" >> build.env
validate:
stage: lint
needs:
- generate
cache:
- key:
files:
- sources/build.pkr.hcl
paths:
- ./packer_config/
script: |-
set -exo pipefail
packer init sources
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
packer validate -except=upload -var-file=${vars} sources/
done
shellcheck:
stage: lint
script: |-
shellcheck --version
shellcheck $(find . -name '*.sh')
# Downloads all the ISO files so that we have a single cache with all
# of them present. This prevents a race condition where some of the
# files were being downloaded multiple times due to parallel jobs, and
# others were disappearing (e.g. daily builds for Rawhide) before we
# could get to them
downloads:
stage: cache
image: $CI_REGISTRY_DIRECT/greg/ci-images/fedora:latest
cache:
- key: isofiles
paths:
- cache/*.iso
- key:
files:
- sources/build.pkr.hcl
paths:
- ./packer_config/
script:
- set -exo pipefail
- packer init sources
- files=()
- |-
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
file=$(echo var.iso.url | packer console -var-file=${vars} -config-type=hcl2 sources/)
files+=("${file}")
done
- mkdir -p cache
- pushd cache
- curl --parallel -L -O "${files[@]}"
- popd
trigger:
stage: trigger
trigger:
include:
- artifact: .gitlab-ci-build.yml
job: distros
variables:
PARENT_PIPELINE_ID: $CI_PIPELINE_ID