Skip to content

Commit

Permalink
Move some CI tests to CircleCI (kairos-io#178)
Browse files Browse the repository at this point in the history
* 🤖 Run datasource tests on CircleCI

* 🤖 Run bundles tests on CircleCI

* 🤖 Fixups

* 🤖 Run cli tests to CircleCI

* 🤖 Extend wait time

* 🤖 Fail when VM is aborted

* 🤖 Enlart waiting time window

* 🤖 Do not set VM specs

* 🤖 Shift just some of the tests
  • Loading branch information
mudler authored Oct 4, 2022
1 parent b541b36 commit 3edf7a6
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 115 deletions.
189 changes: 115 additions & 74 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,84 @@ jobs:
docker push << parameters.image >>-<< parameters.flavor >>:${TAG}
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${TAG} ./build/
fi
run-test:
parameters:
flavor:
type: string
test_suite:
type: string
machine:
image: ubuntu-2004:current
resource_class: large
steps:
- checkout
- run:
name: Build
command: |
./earthly.sh +pull-release --FLAVOR=<< parameters.flavor >>
ls -liah
export ISO=$(ls build/*.iso)
sudo mv $ISO build/kairos.iso
./earthly.sh +run-qemu-test --FLAVOR=<< parameters.flavor >> --CONTAINER_IMAGE=ttl.sh/tests-<< parameters.flavor >>-$CIRCLE_SHA1:8h --TEST_SUITE=<< parameters.test_suite >>
run-latest-test:
parameters:
flavor:
type: string
test_suite:
type: string
machine:
image: ubuntu-2004:current
resource_class: large
steps:
- checkout
- run:
name: Build
command: |
./earthly.sh +pull-release --FLAVOR=<< parameters.flavor >>
ls -liah
export ISO=$(ls build/*.iso)
sudo mv $ISO build/kairos.iso
./earthly.sh +run-qemu-test --FLAVOR=<< parameters.flavor >> --CONTAINER_IMAGE=ttl.sh/tests-<< parameters.flavor >>-$CIRCLE_SHA1:8h --TEST_SUITE=<< parameters.test_suite >>
run-datasource-test:
parameters:
flavor:
type: string
cloud_config:
type: string
test_suite:
type: string
machine:
image: ubuntu-2004:current
resource_class: large
steps:
- checkout
- run:
name: Build
command: |
./earthly.sh +pull-build-artifacts --BUNDLE_IMAGE=ttl.sh/<< parameters.flavor >>-$CIRCLE_SHA1:8h
ls -liah
export ISO=$(ls build/*.iso)
sudo mv $ISO build/kairos.iso
./earthly.sh +datasource-iso --CLOUD_CONFIG=tests/assets/<< parameters.cloud_config >>.yaml
./earthly.sh +run-qemu-datasource-tests --TEST_SUITE=<< parameters.test_suite >> --FLAVOR=<< parameters.flavor >>
run-bundles-test:
parameters:
flavor:
type: string
machine:
image: ubuntu-2004:current
resource_class: large
steps:
- checkout
- run:
name: Build
command: |
./earthly.sh +pull-build-artifacts --BUNDLE_IMAGE=ttl.sh/<< parameters.flavor >>-$CIRCLE_SHA1:8h
ls -liah
export ISO=$(ls build/*.iso)
sudo mv $ISO build/kairos.iso
./earthly.sh +prepare-bundles-tests
./earthly.sh +run-qemu-bundles-tests --FLAVOR=<< parameters.flavor >>
build-iso:
parameters:
flavor:
Expand All @@ -80,10 +157,13 @@ jobs:
export TAG=latest
fi
./earthly.sh +all --IMAGE=<< parameters.image >>-<< parameters.flavor >>:${TAG} --FLAVOR=<< parameters.flavor >> --ISO_NAME=kairos-<< parameters.flavor >>-${TAG}
./earthly.sh +push-build-artifacts --BUNDLE_IMAGE=ttl.sh/<< parameters.flavor >>-$CIRCLE_SHA1:8h
if [ "<< parameters.release >>" == "yes" ]; then
docker push << parameters.image >>-<< parameters.flavor >>:${TAG}
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${TAG} ./build/
fi
docker tag << parameters.image >>-<< parameters.flavor >>:${TAG} ttl.sh/tests-<< parameters.flavor >>-$CIRCLE_SHA1:8h
docker push ttl.sh/tests-<< parameters.flavor >>-$CIRCLE_SHA1:8h
lint:
machine:
Expand Down Expand Up @@ -162,84 +242,45 @@ workflows:
image: ["quay.io/kairos/framework"]
flavor: ["opensuse"]
release: ["no"]
# - run-datasource-test:
# matrix:
# parameters:
# cloud_config: ["autoinstall"]
# flavor: ["alpine","opensuse","ubuntu"]
# test_suite: ["reset-test", "autoinstall-test"]
# requires:
# - build-iso
# - run-latest-test:
# matrix:
# parameters:
# flavor: ["alpine","opensuse","ubuntu"]
# test_suite: ["upgrade-latest-with-cli"]
# requires:
# - build-iso
# - run-test:
# matrix:
# parameters:
# flavor: ["alpine","opensuse","ubuntu"]
# test_suite: ["upgrade-with-cli"]
# requires:
# - build-iso
- run-bundles-test:
matrix:
parameters:
flavor: ["opensuse"]
requires:
- build-iso
- build-iso:
matrix:
parameters:
image: [quay.io/kairos/core]
flavor: ["alpine","opensuse","ubuntu"]
release: ["no"]
lint:
jobs:
- lint
test:
jobs:
- unit-test
- build-bin
# - build-iso:
# matrix:
# parameters:
# image: [quay.io/kairos/core]
# flavor: ["alpine","opensuse","ubuntu"]
# release: ["no"]
# - build-framework:
# matrix:
# parameters:
# image: [quay.io/kairos/framework]
# flavor: ["opensuse"]
# release: ["no"]
# - build-arm:
# matrix:
# parameters:
# image: [quay.io/kairos/core]
# flavor: ["opensuse-arm-rpi", "alpine-arm-rpi"]
# model: ["rpi64"]
# release: ["no"]

# release:
# jobs:
# - lint:
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
# - unit-test:
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
# - build-bin:
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
# - build-iso:
# matrix:
# parameters:
# image: [quay.io/kairos/core]
# flavor: ["alpine","opensuse","ubuntu"]
# release: ["yes"]
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
# - build-framework:
# matrix:
# parameters:
# image: [quay.io/kairos/framework]
# flavor: ["opensuse"]
# release: ["yes"]
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
# - build-arm:
# matrix:
# parameters:
# image: [quay.io/kairos/core]
# flavor: ["opensuse-arm-rpi", "alpine-arm-rpi"]
# model: ["rpi64"]
# release: ["yes"]
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v.*/
46 changes: 22 additions & 24 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ jobs:
path: tests/**/logs/*
if-no-files-found: warn



latest-release:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -171,28 +169,28 @@ jobs:
./earthly.sh +datasource-iso --CLOUD_CONFIG=tests/assets/autoinstall.yaml
./earthly.sh +run-qemu-datasource-tests --FLAVOR=${{ matrix.flavor }}
qemu-bundles-tests:
needs:
- build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- flavor: "opensuse"
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: kairos-${{ matrix.flavor }}.iso.zip
- run: |
ls -liah
export ISO=$PWD/$(ls *.iso)
mkdir build
mv $ISO build/kairos.iso
./earthly.sh +prepare-bundles-tests
./earthly.sh +run-qemu-bundles-tests --FLAVOR=${{ matrix.flavor }}
# qemu-bundles-tests:
# needs:
# - build
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# include:
# - flavor: "opensuse"
# steps:
# - uses: actions/checkout@v2
# - name: Download artifacts
# uses: actions/download-artifact@v2
# with:
# name: kairos-${{ matrix.flavor }}.iso.zip
# - run: |
# ls -liah
# export ISO=$PWD/$(ls *.iso)
# mkdir build
# mv $ISO build/kairos.iso
# ./earthly.sh +prepare-bundles-tests
# ./earthly.sh +run-qemu-bundles-tests --FLAVOR=${{ matrix.flavor }}

qemu-reset-tests:
needs:
Expand Down
46 changes: 46 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,52 @@ run-qemu-test:

RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/

###
### Artifacts targets
###

## Gets the latest release artifacts for a given release
pull-release:
FROM alpine
RUN apk add curl wget
RUN curl -s https://api.github.com/repos/kairos-io/kairos/releases/latest | grep "browser_download_url.*${FLAVOR}.*iso" | cut -d : -f 2,3 | tr -d \" | wget -i -
RUN mkdir build
RUN mv *.iso build/
SAVE ARTIFACT build AS LOCAL build

## Pull build artifacts from BUNDLE_IMAGE (expected arg)
pull-build-artifacts:
ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
RUN zypper in -y jq docker
COPY +uuidgen/UUIDGEN ./
COPY +version/VERSION ./
ARG UUIDGEN=$(cat UUIDGEN)
ARG BUNDLE_IMAGE=ttl.sh/$UUIDGEN:8h

COPY +luet/luet /usr/bin/luet
RUN luet util unpack $BUNDLE_IMAGE build
SAVE ARTIFACT build AS LOCAL build

## Push build artifacts as BUNDLE_IMAGE (expected arg, common is to use ttl.sh/$(uuidgen):8h)
push-build-artifacts:
ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
RUN zypper in -y jq docker
COPY +uuidgen/UUIDGEN ./
COPY +version/VERSION ./
ARG UUIDGEN=$(cat UUIDGEN)
ARG BUNDLE_IMAGE=ttl.sh/$UUIDGEN:8h

COPY . .
COPY +luet/luet /usr/bin/luet

RUN cd build && tar cvf ../build.tar ./
RUN luet util pack $BUNDLE_IMAGE build.tar image.tar
WITH DOCKER
RUN docker load -i image.tar && docker push $BUNDLE_IMAGE
END

# bundles tests needs to run in sequence:
# +prepare-bundles-tests
# +run-bundles-tests
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ require (
github.com/joho/godotenv v1.4.0
github.com/mudler/go-nodepair v0.0.0-20220507212557-7d47aa3cc1f1
github.com/mudler/go-pluggable v0.0.0-20220716112424-189d463e3ff3
github.com/mudler/go-processmanager v0.0.0-20220724164624-c45b5c61312d
github.com/mudler/yip v0.0.0-20220725150231-976737b2353c
github.com/nxadm/tail v1.4.8
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.20.0
github.com/pterm/pterm v0.12.41
github.com/qeesung/image2ascii v1.0.1
github.com/spectrocloud/peg v0.0.0-20220928170937-6323fd1d63c4
github.com/spectrocloud/peg v0.0.0-20221004124828-dc401eb8ddad
github.com/twpayne/go-vfs v1.7.2
github.com/urfave/cli v1.22.9
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
Expand Down Expand Up @@ -67,7 +68,6 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mudler/go-processmanager v0.0.0-20220724164624-c45b5c61312d // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spectrocloud/peg v0.0.0-20220928170937-6323fd1d63c4 h1:HTGwJxg40ELjvAlK86tkAh+kY7PTpPa3iFtN/0ZTjKI=
github.com/spectrocloud/peg v0.0.0-20220928170937-6323fd1d63c4/go.mod h1:H0Vd1P9FdZfrv1QIiQetY4ckDpiD9R71OcUyuvJadno=
github.com/spectrocloud/peg v0.0.0-20221004124828-dc401eb8ddad h1:vb+7fDjQ8GF5QpvL4JUcoN6B7KuyW8V0HjNKBkYOMk8=
github.com/spectrocloud/peg v0.0.0-20221004124828-dc401eb8ddad/go.mod h1:H0Vd1P9FdZfrv1QIiQetY4ckDpiD9R71OcUyuvJadno=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
Expand Down
2 changes: 1 addition & 1 deletion tests/autoinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _ = Describe("kairos autoinstall test", Label("autoinstall-test"), func() {
Fail("CLOUD_INIT must be set and must be pointing to a file as an absolute path")
}

EventuallyConnects(720)
EventuallyConnects(1200)
})

AfterEach(func() {
Expand Down
2 changes: 1 addition & 1 deletion tests/bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _ = Describe("kairos bundles test", Label("bundles-test"), func() {
Fail("CLOUD_INIT must be set and must be pointing to a file as an absolute path")
}

EventuallyConnects(720)
EventuallyConnects(1200)
})

AfterEach(func() {
Expand Down
Loading

0 comments on commit 3edf7a6

Please sign in to comment.