forked from samba-in-kubernetes/samba-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (164 loc) · 5.65 KB
/
main.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
164
165
name: CI
# Run tests on pull requests and when changes are directly
# committed to master.
on:
push:
branches: [master, release]
pull_request:
branches: [master]
jobs:
# Do a build/compile smoke test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: oldstable
- uses: actions/checkout@v4
- name: Build
run: make
# Run static/code-quality checks
check:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: oldstable
- uses: actions/checkout@v4
- name: Install revive
run: go install github.com/mgechev/revive@latest
- name: Run checks
run: make check
check-commits:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Ensure branches
run: git fetch
- name: Lint git commit messages
run: make check-gitlint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: oldstable
- uses: actions/checkout@v4
- name: run the tests
run: make test
podmanbuild:
runs-on: ubuntu-20.04
# don't run on push, since the "push" job contains the
# image build step, so no need to do it twice.
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Install fuse-overlayfs
run: sudo apt-get -y install fuse-overlayfs
- name: Setup podman config
run: |
mkdir -p /home/runner/.config/containers/
cat >/home/runner/.config/containers/storage.conf <<EOF
[storage]
driver = "overlay"
graphroot = "${HOME}/.local/share/containers/storage2"
[storage.options]
mount_program = "/usr/bin/fuse-overlayfs"
EOF
cat >/home/runner/.config/containers/containers.conf <<EOF
[containers]
netns = "host"
EOF
- name: build container image
# note: forcing use of podman here since we are
# using podman explicitly for the push job
run: make CONTAINER_CMD=podman image-build
dockerbuild:
runs-on: ubuntu-latest
# don't run on push, since the "push" job contains the
# image build step, so no need to do it twice.
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: build container image
# note: forcing use of podman here since we are
# using podman explicitly for the push job
run: make CONTAINER_CMD=docker image-build
test-kubernetes:
#runs-on: ubuntu-latest
# need to explicitly use 20.04 to avoid problems with jq...
runs-on: ubuntu-20.04
env:
CONTAINER_CMD: docker
PR_NUM: ${{ github.event.pull_request.number }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: oldstable
- name: Install k3d
run: curl -L --silent --fail "https://raw.githubusercontent.com/rancher/k3d/main/install.sh" | bash
# The TAG env var can interfere with the k3d install script.
# Env vars must be set up *after* k3d is installed.
- name: Set environment vars
run: |
tag="latest-scratch"
if [ "${PR_NUM}" ] ; then tag="pr-${PR_NUM}" ; fi
reg_base="registry.localhost"
reg_port="5000"
reg="k3d-${reg_base}:${reg_port}"
img="${reg}/samba.org/samba-operator:${tag}"
{
# registry params
echo "REG_BASE=${reg_base}"
echo "REG_PORT=${reg_port}"
echo "REGISTRY=${reg}"
# tag and image name for build+push
echo "TAG=${tag}"
echo "IMG=${img}"
# operator image for verification by test suite
echo "SMBOP_TEST_EXPECT_MANAGER_IMG=${img}"
} >> $GITHUB_ENV
- name: Create k3d registry
run: k3d registry create "${REG_BASE}" --port "${REG_PORT}"
- name: Create k3d cluster
run: k3d cluster create --wait --image docker.io/rancher/k3s:v1.21.5-k3s1 --registry-use "${REGISTRY}"
- name: Wait for cluster ready
run: |
while ! kubectl get serviceaccount default >/dev/null; do sleep 1; done
- name: get nodes
run: kubectl get nodes
- name: deploy ad server
run: ./tests/test-deploy-ad-server.sh
- name: build image
run: make image-build
- name: push image to k3d registry
run: make container-push
- name: configure kustomize
run: make set-image
- name: run tests
run: ./tests/test.sh
- name: dump logging on failure
if: ${{ failure() }}
run: ./tests/post-test-info.sh
# push the container to quay.io - only for pushes, not PRs
push:
needs: [build, check]
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: log in to quay.io
# using docker for now, since podman has an issue with space
# consumption: image build fails with no space left on device...
run: echo "${{ secrets.QUAY_PASS }}" | docker login -u "${{ secrets.QUAY_USER }}" --password-stdin quay.io
- name: build container image
# note: forcing use of docker here, since we did docker login above
run: make CONTAINER_CMD=docker image-build
- name: push container image
# note: forcing use of docker here, since we did docker login above
run: make CONTAINER_CMD=docker container-push