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

Extract smoketests job into its own file #4678

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 11 additions & 103 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
id: generate-smoketest-matrix
run: |
./vars.sh FROM=inttest smoketests | jq --raw-input --raw-output \
'split(" ") | [ .[] | select(. != "") ] | "smoketests=" + tojson' >>$GITHUB_OUTPUT
'split(" ") | [ .[] | select(startswith("check-")) | .[6:] ] | "smoketests=" + tojson' >>$GITHUB_OUTPUT

- name: "Generate :: Autopilot test matrix"
id: generate-autopilot-matrix
Expand Down Expand Up @@ -206,63 +206,12 @@ jobs:
matrix:
smoke-suite: ${{ fromJson(needs.prepare.outputs.smoketest-matrix) }}

name: "Smoke tests :: ${{ matrix.smoke-suite }}"
name: "Smoke test :: ${{ matrix.smoke-suite }}"
needs: [prepare, build-k0s, build-airgap-image-bundle]
runs-on: ubuntu-22.04

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Reclaim runner disk space
run: .github/workflows/reclaim-runner-disk-space.bash

- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh

- name: Prepare docker for ipv6 dual-stack tests
if: contains(matrix.smoke-suite, 'dualstack')
run: .github/workflows/prepare-docker-ipv6.sh

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Download compiled executable
uses: actions/download-artifact@v4
with:
name: k0s-linux-amd64

- name: k0s sysinfo
run: |
chmod +x k0s
./k0s sysinfo

- name: Download airgap image bundle
if: contains(matrix.smoke-suite, 'airgap')
uses: actions/download-artifact@v4
with:
name: airgap-image-bundle-linux-amd64

- name: Run inttest
run: make -C inttest ${{ matrix.smoke-suite }}

- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v4
with:
name: smoketests-${{ matrix.smoke-suite }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz

- name: Collect sonobuoy results
if: failure() && contains(matrix.smoke-suite, 'conformance')
uses: actions/upload-artifact@v4
with:
name: smoketests-${{ matrix.smoke-suite }}-sonobuoy-results
path: /tmp/*_sonobuoy_*.tar.gz
uses: ./.github/workflows/smoketest.yaml
with:
name: ${{ matrix.smoke-suite }}

autopilot-tests:
strategy:
Expand All @@ -273,55 +222,14 @@ jobs:
- controllerworker
- ha3x3

name: "Autopilot tests :: ${{ matrix.version }} :: ${{ matrix.smoke-suite }}"
name: "Autopilot test :: ${{ matrix.version }} :: ${{ matrix.smoke-suite }}"
needs: [prepare, build-k0s]
runs-on: ubuntu-22.04

env:
K0S_VERSION: ${{ matrix.version }}

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Reclaim runner disk space
run: .github/workflows/reclaim-runner-disk-space.bash

- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Download compiled executable
uses: actions/download-artifact@v4
with:
name: k0s-linux-amd64

- name: Download latest release
run: |
curl --proto '=https' --tlsv1.2 --retry 5 --retry-all-errors -sSLfo "k0s-$K0S_VERSION" "https://github.com/k0sproject/k0s/releases/download/$K0S_VERSION/k0s-$K0S_VERSION-amd64"
chmod +x "k0s-$K0S_VERSION"

- name: k0s sysinfo
run: |
chmod +x k0s
./k0s sysinfo

- name: Run inttest
run: |
make -C inttest check-ap-${{ matrix.smoke-suite }} K0S_UPDATE_FROM_BIN="../k0s-$K0S_VERSION"

- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v4
with:
name: autopilot-tests-${{ matrix.version }}-${{ matrix.smoke-suite }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
uses: ./.github/workflows/smoketest.yaml
with:
name: ap-${{ matrix.smoke-suite }}
job-name: autopilot-test
k0s-reference-version: ${{ matrix.version }}

smoketest-arm:
name: Smoke test on armv7/arm64
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/smoketest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 k0s authors

name: Smoke test

on:
workflow_call:
inputs:
name:
type: string
required: true
description: The integration test name to be executed.
job-name:
type: string
default: smoketest
description: >-
The name to use for the test job.
Will be used as a prefix for artifact uploads.
k0s-reference-version:
type: string
description: >-
The k0s release version to be used as a reference.
Mostly used for Autopilot upgrade checks.

permissions:
contents: read

jobs:
smoketest:
name: ${{ inputs.job-name }}
runs-on: ubuntu-22.04

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
persist-credentials: false
show-progress: false

- name: Reclaim runner disk space
run: .github/workflows/reclaim-runner-disk-space.bash

- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh

- name: Prepare Docker for ipv6 dual-stack tests
if: contains(inputs.name, 'dualstack')
run: .github/workflows/prepare-docker-ipv6.sh

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Download compiled executable
uses: actions/download-artifact@v4
with:
name: k0s-linux-amd64

- name: k0s sysinfo
run: |
chmod +x k0s
./k0s sysinfo

- name: Download airgap image bundle
if: contains(inputs.name, 'airgap')
uses: actions/download-artifact@v4
with:
name: airgap-image-bundle-linux-amd64

- name: Download k0s reference release
if: inputs.k0s-reference-version != ''
env:
K0S_VERSION: ${{ inputs.k0s-reference-version }}
run: |
curl --proto '=https' --tlsv1.2 -sSLo "k0s-$K0S_VERSION" --retry 5 --retry-all-errors "https://github.com/k0sproject/k0s/releases/download/$K0S_VERSION/k0s-$K0S_VERSION-amd64"
chmod +x "k0s-$K0S_VERSION"
k0sRealPath="$(realpath "k0s-$K0S_VERSION")"
echo K0S_UPDATE_FROM_PATH="$k0sRealPath" >>"$GITHUB_ENV"

- name: Run inttest
env:
SMOKETEST_NAME: check-${{ inputs.name }}
run: make -C inttest "$SMOKETEST_NAME"

- name: Collect k0s logs, support bundle and conformance test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.job-name }}-${{ inputs.name }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
/tmp/*_sonobuoy_*.tar.gz
Loading