Skip to content

Commit

Permalink
add testing farm github action
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyLuLiu committed Jul 31, 2024
1 parent db4810b commit 6fc632e
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
41 changes: 41 additions & 0 deletions .github/workflows/testing-farm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Testing Farm test
on:
push:
branches:
- main
pull_request: {}

# The concurrency key is used to prevent multiple workflows from running at the same time
#concurrency:
# group: my-concurrency-group
# cancel-in-progress: true

permissions:
contents: read
# This is required for the ability to create Issue comment
pull-requests: write
# This is required for the ability to create/update the Pull request status
statuses: write

jobs:
tests:
runs-on: ubuntu-latest
# Let's schedule tests only on user request. NOT automatically.
# Only repository owner or member can schedule tests
#if: |
# github.event.issue.pull_request
# && contains(github.event.comment.body, '[test]')
# && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)
steps:
- name: Schedule test on Testing Farm
uses: sclorg/testing-farm-as-github-action@v2
with:
api_key: ${{ secrets.TF_API_KEY }}
compose: fedora40
arch: x86_64
git_ref: ${{ github.ref_name }}
secrets: "PULL_SECRET=${{ secrets.PULL_SECRET }}"
tmt_plan_regex: smoke_plan
#variables: "SOME_DUMMY_VARIABLE =FOO_BAR_VARIABLE;OS_VARIABLE=DUMMY_OS"
#tmt_plan_regex: "tf-test"
#tmt_path: "test"
22 changes: 22 additions & 0 deletions testing-farm/install.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
summary: Install CRC

description: |
Install CRC

discover:
how: fmf
test:
- /testing-farm/script

provision:
hardware:
virtualization:
is-virtualized: false
is-supported: true
compatible:
distro: fedora40

execute:
how: tmt

42 changes: 42 additions & 0 deletions testing-farm/script/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#source prepare.sh
set -x
set -e
CRC_SCM="https://github.com/code-ready/crc.git"
LIBVIRT_DRIVER_SCM="https://github.com/code-ready/machine-driver-libvirt.git"
ADMINHELPER_SCM="https://github.com/code-ready/admin-helper.git"
git clone $CRC_SCM

git clone $LIBVIRT_DRIVER_SCM
pushd machine-driver-libvirt
mdl_version_line=$(cat pkg/libvirt/constants.go | grep DriverVersion)
mdl_version=${mdl_version_line##*=}
mdl_version=$(echo $mdl_version | xargs)
go build -v -o crc-driver-libvirt-local ./cmd/machine-driver-libvirt
popd

git clone $ADMINHELPER_SCM
admin_version_line=$(cat admin-helper/crc-admin-helper.spec.in | grep Version:)
admin_version=${admin_version_line##*:}
admin_version=$(echo $admin_version | xargs)
make -C admin-helper out/linux-amd64/crc-admin-helper VERSION=$admin_version

pushd crc
mkdir -p custom_embedded
cp ./../machine-driver-libvirt/crc-driver-libvirt-local custom_embedded/crc-driver-libvirt-amd64
cp ./../admin-helper/out/linux-amd64/crc-admin-helper custom_embedded/crc-admin-helper-linux-amd64
# Match admin-helper version with latest from master head
sed -i "s/crcAdminHelperVersion.*=.*/crcAdminHelperVersion = \"${admin_version}\"\n/g" pkg/crc/version/version.go
# Match machine-driver-libvirt version with latest from master head
sed -i "s/MachineDriverVersion =.*/MachineDriverVersion = \"${mdl_version}\"/g" pkg/crc/machine/libvirt/constants.go
make linux-release CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=custom_embedded
popd

# Download crc installer, first parmater is the install url
#curl --insecure -LO -C - ${1}
#sudo tar xvf crc-linux-amd64.tar.xz --strip-components 1 -C /usr/local/bin/
#crc version
#rm crc-linux-amd64.tar.xz
ls crc/release

tar xvf crc/release/crc-linux-amd64.tar.xz --strip-components 1 -C /usr/local/bin/
crc version
15 changes: 15 additions & 0 deletions testing-farm/script/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
summary: Run an arbitrary script

description: |
Runs an arbitrary script specified by the SCRIPT environment variable.

If not script given, `cat /etc/os-release` is used.

test: |
source prepare.sh
./build.sh
./test.sh

# set the duration to 1h in case of more demanding commands
duration: 60m
13 changes: 13 additions & 0 deletions testing-farm/script/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!bin/bash
set -x
cat /etc/fedora-release
dnf install -y git libvirt libvirt-libs libvirt-devel gcc make
#libvirt-glib pkg-config
rpm -qa "*libvirt*"
curl --insecure -LO -C - https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
export CGO_ENABLED="1"
echo "${PULL_SECRET}" > ~/crc-pull-secret
cat ~/crc-pull-secret

5 changes: 5 additions & 0 deletions testing-farm/script/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set -x
set -e
pushd crc
make e2e PULL_SECRET_FILE=--pull-secret-file=~/crc-pull-secret
make integration
7 changes: 7 additions & 0 deletions testing-farm/smoke_plan.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary: Basic smoke test
execute:
how: tmt
script: |
set +x
echo "${PULL_SECRET}" > ~/crc-pull-secret
cat ~/crc-pull-secret

0 comments on commit 6fc632e

Please sign in to comment.