Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for github action #2

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
3 changes: 2 additions & 1 deletion .github/workflows/qe-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Push qe images for new tag
name: Push qe images for new tag test2

on:
push:
tags:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/testing-farm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Testing Farm test
on:
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: Fedora-40
arch: x86_64
git_ref: main
secrets: "PULL_SECRET=${{ secrets.PULL_SECRET }}"
tmt_plan_regex: smoke_plan
variables: "PR_ID=${{ github.event.pull_request.head }}"
#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 "${PR_ID}" > PR.txt
cat PR.txt