-
Notifications
You must be signed in to change notification settings - Fork 166
103 lines (88 loc) · 2.87 KB
/
build-and-test.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
name: Kubectl trace build and tests
on: [push, pull_request]
jobs:
build_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest]
env:
- TEST_KUBERNETES_BACKEND: minikube
- TEST_KUBERNETES_BACKEND: kind
steps:
- uses: actions/checkout@v4
- name: Initialize workflow variables
id: vars
shell: bash
run: |
if [ -n "${QUAY_TOKEN}" ];then
echo "Quay token is set, will push an image"
echo ::set-output name=QUAY_PUBLISH::true
else
echo "Quay token not set, skipping image push"
fi
git_org=$(dirname ${{ github.repository }})
echo GIT_ORG=${git_org} >> $GITHUB_ENV
env:
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
- name: Fetch Tags
run: |
git fetch --prune --unshallow
if [[ "$GIT_ORG" != iovisor ]]; then
git remote add upstream https://github.com/iovisor/kubectl-trace.git
git fetch upstream --tags
fi
- name: Run tests
run: |
make test
- name: Build kubectl trace binary
run: |
make _output/bin/kubectl-trace
- name: Build docker images
run: |
if [[ "${{ github.ref }}" == refs/heads/* ]];then
./build/scripts/ci-build-image.sh ${{ github.ref }}
else
./build/scripts/ci-build-image.sh ${{ github.head_ref }}
fi
- name: Install minikube
env: ${{matrix.env}}
if: ${{ env.TEST_KUBERNETES_BACKEND == 'minikube' }}
run: |
curl -LO https://storage.googleapis.com/minikube/releases/v1.31.2/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
- name: Run integration tests
env: ${{matrix.env}}
run: |
make integration
# - name: Debug failure over SSH
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
- name: Build cross binaries
if: github.ref == 'refs/heads/master'
run: |
go install github.com/goreleaser/goreleaser@latest
make cross
- uses: actions/upload-artifact@v1
with:
name: ${{ matrix.os }}-kubectl-trace-dist
path: _output/bin/kubectl-trace
- uses: actions/upload-artifact@v1
if: github.ref == 'refs/heads/master'
with:
name: ${{ matrix.os }}-kubectl-trace-cross-dist
path: dist
- name: Upload docker image
if: >
steps.vars.outputs.QUAY_PUBLISH
env:
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
run: |
git status --porcelain --untracked-files=no
git reset --hard
git clean -f -d
if [[ "${{ github.ref }}" == refs/heads/* ]];then
./build/scripts/ci-release-image.sh ${{ github.ref }}
else
./build/scripts/ci-release-image.sh ${{ github.head_ref }}
fi