Skip to content

Commit 32d855b

Browse files
authored
Build images before running integration tests. (#230)
1 parent 0802dfa commit 32d855b

File tree

3 files changed

+67
-23
lines changed

3 files changed

+67
-23
lines changed

.github/workflows/integration.yaml

+62-23
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,11 @@ env:
1212
REGISTRY: ghcr.io
1313

1414
jobs:
15-
test:
16-
name: Run tests
17-
runs-on: self-hosted
18-
19-
strategy:
20-
matrix:
21-
flavors:
22-
- name: cumulus
23-
- name: sonic
24-
- name: gardener
15+
build-mini-lab-vms-image:
16+
name: Build mini-lab-vms image
17+
runs-on: ubuntu-latest
2518

2619
steps:
27-
- name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211
28-
run: |
29-
[ -d "${GITHUB_WORKSPACE}" ] && sudo chown -R $USER:$USER ${GITHUB_WORKSPACE}
30-
31-
- name: Setup Containerlab
32-
run: |
33-
bash -c "$(curl -sL https://get.containerlab.dev)"
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
# set if required:
37-
# DESIRED_VERSION: v0.59.0
38-
3920
- name: Log in to the container registry
4021
uses: docker/login-action@v3
4122
with:
@@ -63,6 +44,28 @@ jobs:
6344
cache-from: type=registry,ref=${{ env.MINI_LAB_VM_IMAGE }}
6445
cache-to: type=inline
6546

47+
build-mini-lab-sonic-image:
48+
name: Build mini-lab-sonic image
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Log in to the container registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ secrets.DOCKER_REGISTRY_USER }}
57+
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
58+
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Make tag
63+
run: |
64+
IMAGE_TAG=$([ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo ${GITHUB_HEAD_REF##*/} || echo "latest")
65+
66+
echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:${IMAGE_TAG}" >> $GITHUB_ENV
67+
echo "MINI_LAB_SONIC_IMAGE=ghcr.io/metal-stack/mini-lab-sonic:${IMAGE_TAG}" >> $GITHUB_ENV
68+
6669
- name: Build and push mini-lab-sonic container
6770
uses: docker/build-push-action@v5
6871
with:
@@ -71,7 +74,43 @@ jobs:
7174
tags: ${{ env.MINI_LAB_SONIC_IMAGE }}
7275
cache-from: type=registry,ref=${{ env.MINI_LAB_SONIC_IMAGE }}
7376
cache-to: type=inline
74-
if: ${{ matrix.flavors.name == 'sonic' }}
77+
78+
test:
79+
name: Run tests
80+
runs-on: self-hosted
81+
needs:
82+
- build-mini-lab-vms-image
83+
- build-mini-lab-sonic-image
84+
85+
strategy:
86+
matrix:
87+
flavors:
88+
- name: cumulus
89+
- name: sonic
90+
- name: gardener
91+
92+
steps:
93+
- name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211
94+
run: |
95+
[ -d "${GITHUB_WORKSPACE}" ] && sudo chown -R $USER:$USER ${GITHUB_WORKSPACE}
96+
97+
- name: Setup Containerlab
98+
run: |
99+
bash -c "$(curl -sL https://get.containerlab.dev)"
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
# set if required:
103+
# DESIRED_VERSION: v0.59.0
104+
105+
- name: Checkout
106+
uses: actions/checkout@v4
107+
108+
- name: Make tag
109+
run: |
110+
IMAGE_TAG=$([ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo ${GITHUB_HEAD_REF##*/} || echo "latest")
111+
112+
echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:${IMAGE_TAG}" >> $GITHUB_ENV
113+
echo "MINI_LAB_SONIC_IMAGE=ghcr.io/metal-stack/mini-lab-sonic:${IMAGE_TAG}" >> $GITHUB_ENV
75114
76115
- name: Run integration tests
77116
shell: bash

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.env
22
.idea
3+
.vscode
34
.kubeconfig
45
**/*.pyc
56
clab-mini-lab

inventories/group_vars/all/images.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ setup_yaml:
55
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
66
meta_var: metal_stack_release
77

8+
# TODO: remove these overrides again.
9+
# see: https://github.com/metal-stack/metal-api/pull/612
10+
metal_api_image_tag: v0.40.4
11+
812
##
913
## for development purposes, you can override releases from our image vector here
1014
##

0 commit comments

Comments
 (0)