Skip to content
Snippets Groups Projects
Commit 85b6b9e1 authored by Kristian Klausen's avatar Kristian Klausen :tada:
Browse files

test

parent dfb19555
No related branches found
No related tags found
No related merge requests found
Pipeline #10742 passed
......@@ -7,124 +7,21 @@ stages:
- test
- publish
shellcheck:
stage: lint
before_script:
- pacman -Syu --needed --noconfirm shellcheck
script:
- shopt -s globstar
- shellcheck **/*.sh
shfmt:
stage: lint
before_script:
- pacman -Syu --needed --noconfirm shfmt
script:
- shopt -s globstar
- shfmt -i 2 -ci -d **/*.sh
.build:
build:
stage: build
before_script:
- pacman -Syu --needed --noconfirm qemu-headless libisoburn
script:
- |
# If we're building a tagged release, use the tag (without the 'v' prefix) as the
# BUILD_VERSION. Otherwise, determine a new BUILD_VERSION.
if [[ -n "$CI_COMMIT_TAG" ]]; then
echo "BUILD_VERSION=${CI_COMMIT_TAG/v/}" > build.env
else
echo "BUILD_VERSION=$(date +%Y%m%d).$CI_JOB_ID" > build.env
fi
- export $(< build.env)
- ./build-host.sh
after_script:
- echo "image_size_megabytes{image=\"basic\"} $(du -m output/*basic*qcow2)" > metrics.txt
- echo "image_size_megabytes{image=\"cloudimg\"} $(du -m output/*cloudimg*qcow2)" > metrics.txt
- echo "image_size_megabytes{image=\"libvirt\"} $(du -m output/*libvirt*box)" >> metrics.txt
- echo "image_size_megabytes{image=\"virtualbox\"} $(du -m output/*virtualbox*box)" >> metrics.txt
mkdir output
touch output/{Arch-Linux-x86_64-basic-20210815.31636.qcow2,Arch-Linux-x86_64-basic-20210815.31636.qcow2}
echo "BUILD_VERSION=$(date +%Y%m%d).$CI_JOB_ID" > build.env
artifacts:
name: "output"
paths:
- "output/*"
expire_in: 2d
reports:
metrics: metrics.txt
dotenv: build.env
build:
extends: .build
tags:
- fast-single-thread
except:
- master@archlinux/arch-boxes
- schedules@archlinux/arch-boxes
- tags@archlinux/arch-boxes
build:secure:
extends: .build
tags:
- secure
only:
- master@archlinux/arch-boxes
- schedules@archlinux/arch-boxes
- tags@archlinux/arch-boxes
test-vagrant-boxes-format:
stage: test
before_script:
- pacman -Syu --needed --noconfirm vagrant
script:
- vagrant box add output/Arch-Linux-x86_64-virtualbox-*.box --name archlinux-vbox
- vagrant box add output/Arch-Linux-x86_64-libvirt-*.box --name archlinux-libvirt
test-basic-qemu:
stage: test
tags:
- fast-single-thread
variables:
SSHPASS: arch
before_script:
- pacman -Syu --needed --noconfirm qemu-headless sshpass
script:
- qemu-system-x86_64 -m 512 -net nic -net user,hostfwd=tcp::2222-:22 -drive file=$(ls output/Arch-Linux-x86_64-basic-*.qcow2),if=virtio -nographic &
- timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 sudo true; do sleep 1; done"
test-cloudimg-qemu:
stage: test
tags:
- fast-single-thread
variables:
SSHPASS: passw0rd
before_script:
- pacman -Syu --needed --noconfirm qemu-headless cdrtools sshpass
script:
- |
cat > user-data <<EOF
#cloud-config
password: '${SSHPASS}'
chpasswd: { expire: False }
ssh_pwauth: True
packages:
- tmux
- tree
runcmd:
- [ echo, 'Install more packages using runcmd.' ]
- [ pacman, --noconfirm, -Syu, bat ]
- [ touch, /runcmd_successful ]
EOF
- |
cat > meta-data <<EOF
instance-id: iid-local01
local-hostname: cloudimg
EOF
- cat user-data meta-data
- genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
- qemu-system-x86_64 -m 512 -net nic -net user,hostfwd=tcp::2222-:22 -drive file=$(ls output/Arch-Linux-x86_64-cloudimg-*.qcow2),if=virtio -drive file=seed.iso,if=virtio -nographic &
- timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 true; do sleep 1; done"
- timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 pacman -Q bat tmux tree; do sleep 1; done"
- timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 test -f /runcmd_successful ; do sleep 1; done"
tag_release:
stage: publish
tags:
......@@ -135,18 +32,25 @@ tag_release:
variables:
- $SCHEDULED_PUBLISH == "TRUE"
before_script:
- pacman -Syu --needed --noconfirm release-cli
- pacman -Syu --needed --noconfirm release-cli jq
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/images/v${BUILD_VERSION}"
script:
- release-cli create --name "v$BUILD_VERSION" --tag-name v$BUILD_VERSION \
--assets-link "{\"name\":\"Vagrant Cloud Release\",\"url\":\"https://app.vagrantup.com/archlinux/boxes/archlinux/versions/$BUILD_VERSION\"}" \
--assets-link "{\"name\":\"Browse artifacts\",\"url\":\"https://gitlab.archlinux.org/archlinux/arch-boxes/-/jobs/artifacts/v$BUILD_VERSION/browse/output?job=build:secure\"}"
- |
assets_links=()
for f in output/*; do
base="$(basename "${f}")"
curl -sSf --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${f}" "${PACKAGE_REGISTRY_URL}/${base}"
assets_links+=(--assets-link "{\"name\":\"${f}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${base}\"}")
done
- release-cli create --name "v$BUILD_VERSION" --tag-name v$BUILD_VERSION "${assets_links[@]}"
publish:
stage: publish
tags:
- secure
only:
- tags@archlinux/arch-boxes
- schedules@archlinux/arch-boxes
before_script:
- pacman -Syu --needed --noconfirm vagrant
script:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment