-
-
Notifications
You must be signed in to change notification settings - Fork 26
144 lines (121 loc) · 4.17 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
name: Build and test Docker image
on:
pull_request:
branches:
- main
paths-ignore:
- "./**/*.md"
- "LICENSE"
- 'social/'
- '.gitignore'
- 'docker-compose.yml'
- 'Makefile'
env:
IMAGE_NAME: localhost:5000/cdalvaro/docker-salt-master:${{ github.sha }}
REGISTRY_PATH: ${{ github.workspace }}/registry
CACHE_PATH: /tmp/.buildx-cache
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
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: Cache Docker layers
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build docker-salt-master image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: |
type=local,src=${{ env.CACHE_PATH }}
ghcr.io/cdalvaro/docker-salt-master:latest
cache-to: type=local,dest=${{ env.CACHE_PATH }}
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@v3
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, linux/arm/v7]
env:
DOCKER_CLI_EXPERIMENTAL: enabled
PLATFORM: ${{ matrix.platform }}
BOOTUP_WAIT_SECONDS: 90
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Docker registry data from build job
uses: actions/download-artifact@v3
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 ${{ matrix.platform }} ${IMAGE_NAME}
- name: Docker inspect
run: docker buildx imagetools inspect ${IMAGE_NAME} | grep '${{ matrix.platform }}'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Execute basic tests
run: tests/basic/test.sh
- name: Execute salt-api tests
run: tests/salt-api/test.sh
- name: Execute gitfs tests
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
run: tests/config-reloader/test.sh
- name: Cleanup
run: |
docker stop registry