mirror of
https://github.com/flatcar/scripts.git
synced 2026-03-05 05:22:41 +01:00
Make the kola test workflow reusable
* Adds a reusable workflow that can run tests
* Adapts the ci.yaml to use reusable workflow
* Creates a new workflow that helps trigger tests using an arbitrary
workflow run.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
680d2521ac
commit
3cbb6cbd04
64
.github/workflows/ci.yaml
vendored
64
.github/workflows/ci.yaml
vendored
@ -43,9 +43,9 @@ jobs:
|
||||
packages:
|
||||
name: "Build Flatcar packages"
|
||||
runs-on:
|
||||
- self-hosted
|
||||
- debian
|
||||
- build
|
||||
- self-hosted
|
||||
- x64
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@ -62,18 +62,14 @@ jobs:
|
||||
run: |
|
||||
sudo rm /bin/sh
|
||||
sudo ln -s /bin/bash /bin/sh
|
||||
sudo apt-get install \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release
|
||||
sudo apt-get install -y ca-certificates curl gnupg lsb-release qemu-user-static git
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin qemu-user-static git
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
@ -288,53 +284,13 @@ jobs:
|
||||
scripts/images/**/flatcar_production_*.sh
|
||||
scripts/images/**/flatcar_test_update.gz
|
||||
scripts/ebuild_logs.tar.xz
|
||||
|
||||
test:
|
||||
name: "Run kola tests"
|
||||
needs: packages
|
||||
runs-on:
|
||||
- debian
|
||||
- kola
|
||||
- self-hosted
|
||||
- ${{ matrix.arch }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: ["amd64", "arm64"]
|
||||
defaults:
|
||||
run:
|
||||
working-directory: scripts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
path: scripts
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
# it downloads from the previous linked job.
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: images-${{ matrix.arch }}
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
exec 2>&1
|
||||
set +x
|
||||
set -euo pipefail
|
||||
|
||||
source ci-automation/test.sh
|
||||
|
||||
# TODO: REMOVE ME (for debugging purposes)
|
||||
ls -ali
|
||||
find . -type f -name "*.bz2"
|
||||
|
||||
# extract the image.
|
||||
bzip2 --decompress scripts/images/**/flatcar_production_image.bin.bz2
|
||||
|
||||
# export the QEMU_IMAGE_NAME to avoid to download it.
|
||||
export QEMU_IMAGE_NAME=$(readlink -f scripts/images/**/flatcar_production_image.bin)
|
||||
|
||||
# run the test.
|
||||
test_run ${{ matrix.arch }} qemu
|
||||
uses: ./.github/workflows/run-kola-tests.yaml
|
||||
with:
|
||||
arch: '["amd64", "arm64"]'
|
||||
workflow_name_or_id: ${{ github.event.workflow_run.workflow_id }}
|
||||
workflow_run_id: ${{ github.event.workflow_run.id }}
|
||||
parallel_tests: "2"
|
||||
|
||||
42
.github/workflows/dispatch-kola-tests.yaml
vendored
Normal file
42
.github/workflows/dispatch-kola-tests.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Dispatch kola tests
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
arch:
|
||||
type: string
|
||||
default: '["amd64", "arm64"]'
|
||||
description: |
|
||||
The architectures to run tests for. This is an array of architectures
|
||||
that can be deserialized in JSON and results in an array of strings.
|
||||
required: true
|
||||
workflow_name_or_id:
|
||||
type: string
|
||||
required: true
|
||||
default: ci.yaml
|
||||
description: |
|
||||
The workflow ID from where we'll download the artifacts to be tested.
|
||||
workflow_run_id:
|
||||
type: string
|
||||
required: true
|
||||
description: |
|
||||
The run ID of the workflow specified in workflow_name_or_id
|
||||
parallel_tests:
|
||||
type: string
|
||||
required: true
|
||||
default: "2"
|
||||
description: |
|
||||
The number of parallel tests to run.
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Trigger kola test"
|
||||
uses: ./.github/workflows/run-kola-tests.yaml
|
||||
with:
|
||||
arch: ${{ github.event.inputs.arch }}
|
||||
workflow_name_or_id: ${{ github.event.inputs.workflow_name_or_id }}
|
||||
workflow_run_id: ${{ github.event.inputs.workflow_run_id }}
|
||||
parallel_tests: ${{ github.event.inputs.parallel_tests }}
|
||||
|
||||
137
.github/workflows/run-kola-tests.yaml
vendored
Normal file
137
.github/workflows/run-kola-tests.yaml
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
name: "Run kola tests"
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
type: string
|
||||
default: '["amd64", "arm64"]'
|
||||
description: |
|
||||
The architectures to run tests for. This is an array of architectures
|
||||
that can be deserialized in JSON and results in an array of strings.
|
||||
required: true
|
||||
workflow_name_or_id:
|
||||
type: string
|
||||
required: true
|
||||
default: ci.yaml
|
||||
description: |
|
||||
The workflow ID from where we'll download the artifacts to be tested.
|
||||
workflow_run_id:
|
||||
type: string
|
||||
required: true
|
||||
description: |
|
||||
The run ID of the workflow specified in workflow_name_or_id
|
||||
parallel_tests:
|
||||
type: string
|
||||
required: true
|
||||
default: "2"
|
||||
description: |
|
||||
The number of parallel tests to run.
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: "Build Flatcar packages"
|
||||
runs-on:
|
||||
- self-hosted
|
||||
- debian
|
||||
- kola
|
||||
- ${{ matrix.arch }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: ${{fromJSON(github.event.inputs.arch)}}
|
||||
|
||||
steps:
|
||||
- name: Prepare machine
|
||||
shell: bash
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
sudo rm /bin/sh
|
||||
sudo ln -s /bin/bash /bin/sh
|
||||
sudo apt-get install -y ca-certificates curl gnupg lsb-release qemu-system qemu-user-static git bzip2 jq dnsmasq
|
||||
sudo systemctl stop dnsmasq
|
||||
sudo systemctl mask dnsmasq
|
||||
|
||||
# Install Docker-CE
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
# Install latest Go
|
||||
VERSION=$(curl -s -L https://golang.org/dl/?mode=json | jq -r .[0].version)
|
||||
curl -s -L https://dl.google.com/go/$VERSION.linux-amd64.tar.gz | sudo tar -xz -C /usr/local
|
||||
sudo ln -s /usr/local/go/bin/go /usr/local/bin/
|
||||
sudo ln -s /usr/local/go/bin/gofmt /usr/local/bin/
|
||||
|
||||
# Set up MASQUERADE. Don't care much to secure it.
|
||||
# This is needed for the VMs kola spins up to have internet access.
|
||||
DEFAULT_ROUTE_DEVICE=$(ip -j route sh default |jq -r .[0].dev)
|
||||
sudo iptables -t nat -I POSTROUTING -o $DEFAULT_ROUTE_DEVICE -j MASQUERADE
|
||||
sudo iptables -I FORWARD -o $DEFAULT_ROUTE_DEVICE -j ACCEPT
|
||||
sudo iptables -I FORWARD -i $DEFAULT_ROUTE_DEVICE -j ACCEPT
|
||||
|
||||
# Enable IP forward
|
||||
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/ip_forward.conf
|
||||
# Enable unprivileged bpf
|
||||
echo 'kernel.unprivileged_bpf_disabled=0' | sudo tee /etc/sysctl.d/enable_unprivileged_bpf.conf
|
||||
sudo sysctl --system
|
||||
sysctl -p
|
||||
|
||||
# Enable extra SWAP
|
||||
sudo fallocate /swap.img -l 8GiB
|
||||
sudo chmod 600 /swap.img
|
||||
sudo mkswap /swap.img
|
||||
sudo swapon /swap.img
|
||||
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
path: scripts
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: Download artifacts
|
||||
uses: gabriel-samfira/action-download-artifact@v5
|
||||
with:
|
||||
workflow: ${{ github.event.inputs.workflow_name_or_id }}
|
||||
workflow_conclusion: success
|
||||
run_id: ${{ github.event.inputs.workflow_run_id }}
|
||||
name: images-${{ matrix.arch }}
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
exec 2>&1
|
||||
set +x
|
||||
set -euo pipefail
|
||||
|
||||
# extract the image.
|
||||
IMG_ARCHIVE=$(readlink -f images/**/flatcar_production_image.bin.bz2)
|
||||
bzip2 --decompress ${IMG_ARCHIVE}
|
||||
|
||||
# export the QEMU_IMAGE_NAME to avoid to download it.
|
||||
cp ${IMG_ARCHIVE%%.bz2} ./scripts/
|
||||
pushd scripts
|
||||
pwd
|
||||
source ci-automation/test.sh
|
||||
cat > sdk_container/.env <<EOF
|
||||
export QEMU_IMAGE_NAME="/work/flatcar_production_image.bin"
|
||||
export PARALLEL_TESTS=${{ github.event.inputs.parallel_tests }}
|
||||
EOF
|
||||
export MAX_RETRIES=2
|
||||
export SKIP_COPY_TO_BINCACHE=1
|
||||
# run the test.
|
||||
test_run ${{ matrix.arch }} qemu
|
||||
|
||||
- name: Upload artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-results-${{ matrix.arch }}
|
||||
path: |
|
||||
scripts/__TESTS__
|
||||
scripts/results-.*.tap
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user