-
-
Notifications
You must be signed in to change notification settings - Fork 26
183 lines (154 loc) · 5.26 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Build and test Docker image
on:
pull_request:
branches:
- main
paths-ignore:
- "./**/*.md"
- "docs/"
- "social/"
- ".editorconfig"
- ".gitignore"
- ".shellcheckrc"
- "compose.yml"
- "LICENSE"
- "Makefile"
env:
IMAGE_NAME: localhost:5000/${{ github.repository }}:${{ github.sha }}
REGISTRY_PATH: ${{ github.workspace }}/registry
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Start Docker registry
run: |
docker run --rm --detach --publish 5000:5000 \
--volume ${REGISTRY_PATH}:/var/lib/registry \
--name registry registry:2
- name: Build docker-salt-master image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
outputs: |
type=image,annotation-index.org.opencontainers.image.description=salt-master latest containerized
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
push: true
tags: ${{ env.IMAGE_NAME }}
- name: Stop Docker registry
run: docker stop registry
- name: Upload Docker registry data for testing
uses: actions/upload-artifact@v4
with:
name: docker-registry-data
path: ${{ env.REGISTRY_PATH }}/
test:
name: Test
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
env:
DOCKER_CLI_EXPERIMENTAL: enabled
PLATFORM: ${{ matrix.platform }}
BOOTUP_WAIT_SECONDS: ${{ matrix.platform == 'linux/amd64' && 30 || 90 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Docker registry data from build job
uses: actions/download-artifact@v4
with:
name: docker-registry-data
path: ${{ env.REGISTRY_PATH }}
- name: Enable Docker experimental
run: |
# Enable docker daemon experimental support.
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
# Install QEMU multi-architecture support for docker buildx.
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Start Docker registry
run: |
docker run --rm --detach --publish 5000:5000 \
--volume ${REGISTRY_PATH}:/var/lib/registry \
--name registry registry:2
sleep 10
- name: Import Docker images
run: docker pull --platform ${{ env.PLATFORM }} ${IMAGE_NAME}
- name: Docker inspect
run: docker buildx imagetools inspect ${IMAGE_NAME} | grep '${{ env.PLATFORM }}'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install and configure salt-minion
run: |
# Install salt-minion from salt repos
salt_bootstrap_url="https://github.com/saltstack/salt-bootstrap/releases/latest/download/bootstrap-salt.sh"
curl -o bootstrap-salt.sh -L "${salt_bootstrap_url}"
sudo sh bootstrap-salt.sh -dXP stable
sudo systemctl stop salt-minion
sudo systemctl disable salt-minion
sudo rm -f /var/log/salt/minion
- name: Install tests utils
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Execute basic tests
if: always()
run: tests/basic/test.sh
- name: Execute keys mount point tests
if: always()
run: tests/keys-mount-point/test.sh
- name: Execute healthcheck tests
if: always()
run: tests/healthcheck/test.sh
- name: Execute salt-api tests
if: always()
run: |
tests/salt-api/test.sh
tests/salt-api/salt-api-ldap.sh
- name: Execute salt-minion tests
if: always()
run: tests/salt-minion/test.sh
- name: Execute gitfs tests
if: always()
env:
GITFS_KEYS_DIR: tests/gitfs/data/keys/gitfs
SSH_PRIVATE_KEY: ${{ secrets.TESTS_REPO_PRIVATE_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.TESTS_REPO_PUBLIC_KEY }}
run: |
mkdir -p "${GITFS_KEYS_DIR}"
echo "${SSH_PRIVATE_KEY}" | base64 -d > "${GITFS_KEYS_DIR}"/gitfs_ssh
chmod 600 "${GITFS_KEYS_DIR}"/gitfs_ssh
echo "${SSH_PUBLIC_KEY}" | base64 -d > "${GITFS_KEYS_DIR}"/gitfs_ssh.pub
chmod 644 "${GITFS_KEYS_DIR}"/gitfs_ssh.pub
tests/gitfs/test.sh
- name: Execute config-reloader tests
if: always()
run: tests/config-reloader/test.sh
- name: Execute GPG tests
if: always()
run: tests/gpg/test.sh
- name: Python Extra Packages tests
if: always()
run: tests/python-extra-packages/test.sh
- name: Cleanup
if: always()
run: |
docker rm --force registry