forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (147 loc) · 6.13 KB
/
integration-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Integration Tests
on:
workflow_call:
inputs:
parent_run_id:
type: string
description: "parent run_id to download images from"
required: true
permissions: {}
env:
TAG: v2.10-${{ github.sha }}-head
GIT_TAG: v2.10-${{ github.sha }}-head
HOST_ARCH: amd64
ARCH: amd64
PYTHON_VERSION: '3.11'
GOLANG_VERSION: '1.22'
IMAGE: ${{ github.repository_owner }}/rancher
IMAGE_AGENT: ${{ github.repository_owner }}/rancher-agent
REPO: ${{ github.repository_owner }}
jobs:
test:
runs-on: runs-on,runner=8cpu-linux-x64,image=legacy-cgroups-for-x64,run-id=${{ github.run_id }}
timeout-minutes: 60
env:
K3D_VERSION: v5.7.1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Environment Variables
uses: ./.github/actions/setup-tag-env
- name: Clean up Docker
run: |
docker system prune -af
docker volume prune -f
# Cleaning the runner is important to free enough space to build rancher, otherwise the build will fail
- name: Clean runner
run: |
# removes dotnet
sudo rm -rf /usr/share/dotnet
# removes haskell
sudo rm -rf /opt/ghc
# removes android sdk
sudo rm -rf /usr/local/lib/android
- id: env
name: Setup Dependencies Env Variables
uses: ./.github/actions/setup-build-env
- name: Download Docker images artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ inputs.parent_run_id }}
github-token: ${{ github.token }}
path: "/tmp"
merge-multiple: true
- name: Load server image
run: |
image_server_id=$(docker load --input /tmp/rancher-linux-amd64.tar 2>&1 | grep "Loaded image" | awk '{print $NF}')
if [ -z "$image_server_id" ]; then
echo "Error: Failed to load image from tarball!"
exit 1
fi
AMD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -E "rancher/rancher:.*amd64.*$" | head -n 1)
echo "the image created is $AMD_IMAGE"
docker tag "$image_server_id" ${{ env.IMAGE }}:${{ env.TAG }}
docker image ls
docker rmi "$AMD_IMAGE"
docker image ls
- name: Load agent image
run: |
image_agent_id=$(docker load --input /tmp/rancher-agent-linux-amd64.tar 2>&1 | grep "Loaded image" | awk '{print $NF}')
if [ -z "$image_agent_id" ]; then
echo "Error: Failed to load image from tarball!"
exit 1
fi
AMD_IMAGE_AGENT=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -E "rancher/rancher-agent:.*amd64.*$" | head -n 1)
docker tag "$image_agent_id" ${{ env.IMAGE_AGENT }}:${{ env.TAG }}
echo "the image created is $AMD_IMAGE_AGENT"
docker image ls
docker rmi "$AMD_IMAGE_AGENT"
docker image ls
- name: Install k3d
run: curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${{ env.K3D_VERSION }} bash
- name: Uninstall existing Python versions
run: |
sudo apt-get remove -y python3
sudo apt-get autoremove -y
sudo apt-get purge -y python3
sudo apt-get clean
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Check Python version
run: |
sudo rm -rf /usr/bin/python3
sudo cp $(which python3) /usr/bin/python3
python3 --version
python3 -m ensurepip --upgrade
- name: Install Python and dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-dev libffi-dev libssl-dev
sudo pip3 install --upgrade pip
sudo pip3 install tox flake8
## Helm Setup start
- name: Uninstall Helm
run: |
sudo rm -rf /usr/local/bin/helm /usr/bin/rancher-helm /usr/bin/rancher-tiller ~/.helm /usr/local/bin/helm_v3 /usr/local/bin/tiller
- name: Set Helm 2 URL
run: echo "HELM_URL_V2=https://github.com/rancher/helm/releases/download/${{ steps.env.outputs.CATTLE_HELM_VERSION }}/rancher-helm" >> $GITHUB_ENV
- name: Set Tiller URL
run: echo "TILLER_URL=https://github.com/rancher/helm/releases/download/${{ steps.env.outputs.CATTLE_HELM_VERSION }}/rancher-tiller" >> $GITHUB_ENV
- name: Download Rancher Helm
run: sudo curl -sLf ${{ env.HELM_URL_V2 }} -o /usr/bin/rancher-helm-v2
- name: Download Rancher Tiller
run: sudo curl -sLf ${{ env.TILLER_URL }} -o /usr/bin/rancher-tiller
- name: Set permissions for Helm and Tiller
run: sudo chmod +x /usr/bin/rancher-helm-v2 /usr/bin/rancher-tiller
- name: Create symlink for Helm
run: sudo ln -s /usr/bin/rancher-helm-v2 /usr/bin/helm
- name: Create symlink for Tiller
run: sudo ln -s /usr/bin/rancher-tiller /usr/bin/tiller
- name: Initialize Helm
run: helm init -c --stable-repo-url https://charts.helm.sh/stable/
- name: Set Helm 3 URL
run: echo "HELM_URL_V3=https://get.helm.sh/helm-${{ steps.env.outputs.HELM_VERSION }}-linux-${{ env.HOST_ARCH }}.tar.gz" >> $GITHUB_ENV
- name: Create temporary directory for Helm 3
run: sudo mkdir /usr/tmp
- name: Download and extract Helm 3
run: curl ${{ env.HELM_URL_V3 }} | sudo tar xvzf - --strip-components=1 -C /usr/tmp/
- name: Move Helm 3 binary
run: sudo mv /usr/tmp/helm /usr/bin/helm_v3
- name: KDM data
run: |
mkdir -p bin
curl -sLf https://releases.rancher.com/kontainer-driver-metadata/${{ steps.env.outputs.CATTLE_KDM_BRANCH }}/data.json > bin/data.json
## Helm Setup end
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "${{ env.GOLANG_VERSION }}"
- name: Build Integration Setup
shell: bash
run: |
./tests/v2/integration/scripts/build-integration-setup
- name: Run Tests
shell: bash
run: sudo --preserve-env GOBIN=$(which go) ./scripts/gha/tests