-
Notifications
You must be signed in to change notification settings - Fork 1.6k
132 lines (111 loc) · 5.45 KB
/
integration-linux.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
name: PR integration tests (linux)
# Triggers the workflow on push or pull request events
on: [push, pull_request]
permissions: read-all
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}-${{github.workflow}}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build:
name: PR integration tests (linux)
runs-on: ubuntu-latest
strategy:
matrix:
kustomize_version: [5.0.3]
ko_version: [0.4.0]
kompose_version: [1.21.0]
kpt_version: [1.0.0-beta.24]
minikube_version: [1.30.1]
gcloud_sdk_version: [410.0.0]
container_structure_tests_version: [1.8.0]
integration_test_partitions: [0, 1, 2, 3]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.*
id: go
# Retrieve build locations with `go env`
# <https://markphelps.me/posts/speed-up-your-go-builds-with-actions-cache/>
- id: go-cache-paths
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Skip integration tests for `docs`-only changes (only works for PR-based dev workflows like Skaffold's).
# NOTE: grep output is stored in env var with `|| true` as the run command cannot fail or action will fail
- name: Check if only docs changes were made in this PR
run: |
echo ${{ github.event.before }}
echo ${{ github.event.after }}
NON_DOCS_FILES_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.sha }}| grep -v '^docs/' || true)
echo "NON_DOCS_FILES_CHANGED=${#NON_DOCS_FILES_CHANGED}" >> $GITHUB_ENV # get the char len of diff output (used later)
- name: Install Kustomize
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${{ matrix.kustomize_version }}/kustomize_v${{ matrix.kustomize_version }}_linux_amd64.tar.gz
sudo tar -xvf kustomize.tar.gz -C /usr/local/bin/
- name: Install Ko
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O ko.tar.gz https://github.com/google/ko/releases/download/v${{ matrix.ko_version }}/ko_${{ matrix.ko_version }}_Linux_x86_64.tar.gz
sudo tar -xvf ko.tar.gz -C /usr/local/bin/
- name: Install Kompose
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O kompose https://github.com/kubernetes/kompose/releases/download/v${{ matrix.kompose_version }}/kompose-linux-amd64 && chmod +x kompose
sudo mv kompose /usr/local/bin/
- name: Install Kpt
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O kpt https://github.com/GoogleContainerTools/kpt/releases/download/v${{ matrix.kpt_version }}/kpt_linux_amd64 && chmod +x kpt
sudo mv kpt /usr/local/bin/
- name: Install GCloud
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O gcloud.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${{ matrix.gcloud_sdk_version }}-linux-x86_64.tar.gz
tar -xvf gcloud.tar.gz -C ${HOME}/
${HOME}/google-cloud-sdk/install.sh --usage-reporting=false --bash-completion=false --disable-installation-options
echo "${HOME}/google-cloud-sdk/bin" >> $GITHUB_PATH
- name: Configure GCloud with Docker
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: gcloud auth configure-docker
- name: Install Container Structure Test
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
wget -O container-structure-test https://storage.googleapis.com/container-structure-test/v${{ matrix.container_structure_tests_version }}/container-structure-test-linux-amd64 && chmod +x container-structure-test
sudo mv container-structure-test /usr/local/bin/
- name: Setup other files and permissions
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
sudo chown $(whoami):docker ${HOME}/.docker -R
sudo chmod g+rw ${HOME}/.docker -R
echo '{}' > ${HOME}/.docker/config.json
mkdir -p ${HOME}/.m2/ && cp ./hack/maven/settings.xml ${HOME}/.m2/settings.xml
- name: Install Minikube and start cluster
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
curl -Lo minikube https://github.com/kubernetes/minikube/releases/download/v${{ matrix.minikube_version }}/minikube-linux-amd64
sudo install minikube /usr/local/bin/minikube
minikube start --profile=minikube --driver=docker
- name: Make and install Skaffold binary from current PR
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }} # non docs files were changed, skaffold build needed
run: |
make
sudo install "${HOME}/work/skaffold/skaffold/out/skaffold" /usr/local/bin/skaffold
- name: Run integration tests
if: ${{ env.NON_DOCS_FILES_CHANGED != 0 }}
run: |
skaffold config set --global collect-metrics false
IT_PARTITION=${{ matrix.integration_test_partitions }} make integration-tests