Skip to content

Commit 156a790

Browse files
authored
Merge pull request #46 from RobotSail/ci-workflow
add skip-build flag to run-in-kind script
2 parents a1a1881 + 2ac114d commit 156a790

File tree

2 files changed

+98
-64
lines changed

2 files changed

+98
-64
lines changed

.github/workflows/validate-ipfs.yaml

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ env:
1111
GO111MODULE: "on"
1212
OPERATOR_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator"
1313
BUNDLE_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator-bundle"
14-
TAG: v0.0.1
15-
CLUSTER_IMAGE: "quay.io/redhat-et-ipfs/cluster"
16-
CLUSTER_VERSION: v1.0.0
14+
TAG: "v0.0.1"
15+
IPFS_CLUSTER_K8S_IMAGE: "quay.io/redhat-et-ipfs/ipfs-cluster"
16+
CLUSTER_VERSION: v1.0.2
1717

1818

1919
jobs:
@@ -34,15 +34,15 @@ jobs:
3434
run: make test
3535

3636
- name: Build operator container
37-
run: make docker-build IMG=${OPERATOR_IMAGE}:${TAG}
37+
run: make docker-build IMG="${OPERATOR_IMAGE}"
3838

3939
- name: Export container image
40-
run: docker save -o /tmp/operator.tar ${OPERATOR_IMAGE}:${TAG}
40+
run: docker save -o /tmp/operator.tar ${OPERATOR_IMAGE}
4141

4242
- name: Save container as artifact
4343
uses: actions/upload-artifact@v1
4444
with:
45-
name: ipfs-operator
45+
name: ipfs-cluster-operator
4646
path: /tmp/operator.tar
4747

4848
build-bundle:
@@ -77,32 +77,30 @@ jobs:
7777
with:
7878
name: operator-bundle
7979
path: /tmp/bundle.tar
80-
81-
cluster:
82-
name: build cluster image
80+
81+
build-ipfs-cluster:
82+
name: build-image-ipfs-cluster
8383
runs-on: ubuntu-20.04
84-
steps:
85-
- uses: actions/checkout@v2
86-
with:
87-
repository: ipfs/ipfs-cluster
88-
ref: ${{ env.CLUSTER_VERSION }}
8984

90-
- name: podman build
91-
run: |
92-
podman build -t ${{ env.CLUSTER_IMAGE }}:${{ env.CLUSTER_VERSION }} .
85+
steps:
86+
- name: Checkout source
87+
uses: actions/checkout@v2
88+
89+
- name: Build IPFS Cluster Kubernetes image
90+
run: make -C ipfs-cluster-image image
9391

94-
- name: save the image
95-
run: podman save -o /tmp/cluster.tar ${{ env.CLUSTER_IMAGE }}:${{ env.CLUSTER_VERSION }}
92+
- name: Export container image
93+
run: docker save -o /tmp/image.tar "${IPFS_CLUSTER_K8S_IMAGE}"
9694

97-
- name: archive the image
95+
- name: Save container as artifact
9896
uses: actions/upload-artifact@v1
9997
with:
100-
name: cluster
101-
path: /tmp/cluster.tar
98+
name: ipfs-cluster-image
99+
path: /tmp/image.tar
102100

103-
deploy:
104-
name: Deploy Kind cluster and run tests
105-
needs: [ build-bundle, build-operator, cluster ]
101+
e2e:
102+
name: End-to-end tests
103+
needs: [ build-bundle, build-operator, build-ipfs-cluster ]
106104
runs-on: ubuntu-20.04
107105
steps:
108106
- uses: actions/checkout@v2
@@ -113,41 +111,46 @@ jobs:
113111
sudo install ./kubectl /usr/local/bin/
114112
kubectl version --short --client
115113
114+
115+
- name: Install the Kind binary
116+
run: |
117+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.12.0/kind-linux-amd64
118+
chmod +x ./kind
119+
sudo mv ./kind /usr/local/bin/kind
120+
kind version
121+
122+
- name: Create a Kind Cluster
123+
run: ./hack/setup-kind-cluster.sh
124+
116125
- name: Pull the Container Image from Artifacts
117126
uses: actions/download-artifact@v1
118127
with:
119-
name: ipfs-operator
128+
name: ipfs-cluster-operator
120129
path: /tmp
121130

122131
- name: Load the Container Image
123132
run: |
124133
docker load -i /tmp/operator.tar
125-
docker tag ${OPERATOR_IMAGE}:${TAG} ${OPERATOR_IMAGE}:latest
134+
docker inspect ${OPERATOR_IMAGE}
135+
docker tag ${OPERATOR_IMAGE} ${OPERATOR_IMAGE}:ci-build
136+
kind load docker-image ${OPERATOR_IMAGE}:ci-build
126137
127-
- name: Pull the Container Image from Artifacts
138+
- name: Load the IPFS Cluster container artifact
128139
uses: actions/download-artifact@v1
129140
with:
130-
name: cluster
141+
name: ipfs-cluster-image
131142
path: /tmp
132143

133-
- name: Load the Container Image
134-
run: |
135-
docker load -i /tmp/cluster.tar
136-
docker tag ${CLUSTER_IMAGE}:${CLUSTER_VERSION} ${CLUSTER_IMAGE}:latest
137-
docker tag ${CLUSTER_IMAGE}:${CLUSTER_VERSION} quay.io/redhat-et-ipfs/ipfs-cluster:latest
138-
139-
- name: Install the Kind binary
144+
- name: Import the IPFS Cluster container into cluster
140145
run: |
141-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.12.0/kind-linux-amd64
142-
chmod +x ./kind
143-
sudo mv ./kind /usr/local/bin/kind
144-
kind version
145-
146-
- name: Create a Kind Cluster
147-
run: ./hack/setup-kind-cluster.sh
146+
docker load -i /tmp/image.tar
147+
docker inspect ${IPFS_CLUSTER_K8S_IMAGE}
148+
docker tag ${IPFS_CLUSTER_K8S_IMAGE} ${IPFS_CLUSTER_K8S_IMAGE}:ci-build
149+
kind load docker-image "${IPFS_CLUSTER_K8S_IMAGE}:ci-build"
148150
149151
- name: Load the Operator into Kind
150-
run: ./hack/run-in-kind.sh
152+
# don't build new images to reuse existing artifacts, use ci-build tag
153+
run: KIND_TAG="ci-build" ./hack/run-in-kind.sh --skip-build --skip-tag
151154

152155
- name: run e2e tests
153156
run: |
@@ -156,7 +159,7 @@ jobs:
156159
157160
push-operator:
158161
name: Push operator container to registry
159-
needs: deploy
162+
needs: e2e
160163
if: >
161164
(github.event_name == 'push' || github.event_name == 'schedule') &&
162165
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
@@ -165,13 +168,13 @@ jobs:
165168
- name: Pull the Container Image from Artifacts
166169
uses: actions/download-artifact@v1
167170
with:
168-
name: ipfs-operator
171+
name: ipfs-cluster-operator
169172
path: /tmp
170173

171174
- name: Load the Container Image
172175
run: |
173176
docker load -i /tmp/operator.tar
174-
docker inspect ${OPERATOR_IMAGE}:${TAG}
177+
docker inspect ${OPERATOR_IMAGE}
175178
176179
- name: Login to registry
177180
# If the registry server is specified in the image name, we use that.
@@ -185,11 +188,12 @@ jobs:
185188
(github.event_name == 'push' || github.event_name == 'schedule') &&
186189
github.ref == 'refs/heads/main'
187190
run: |
191+
docker tag ${OPERATOR_IMAGE}:ci-build ${OPERATOR_IMAGE}:${TAG}
188192
docker push "${OPERATOR_IMAGE}:${TAG}"
189193
190194
push-bundle:
191195
name: Push bundle container to registry
192-
needs: deploy
196+
needs: e2e
193197
if: >
194198
(github.event_name == 'push' || github.event_name == 'schedule') &&
195199
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
@@ -223,9 +227,9 @@ jobs:
223227
echo "Pushing to ${{ env.TAG }}"
224228
docker push "${BUNDLE_IMAGE}:${{ env.TAG }}"
225229
226-
push-cluster:
230+
push-ipfs-cluster-image:
227231
name: Push cluster image to registry
228-
needs: deploy
232+
needs: e2e
229233
if: >
230234
(github.event_name == 'push' || github.event_name == 'schedule') &&
231235
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
@@ -235,13 +239,13 @@ jobs:
235239
- name: Load container artifact
236240
uses: actions/download-artifact@v1
237241
with:
238-
name: cluster
242+
name: ipfs-cluster-image
239243
path: /tmp
240244

241245
- name: Import container image
242246
run: |
243-
docker load -i /tmp/cluster.tar
244-
docker inspect "${CLUSTER_IMAGE}:${{ env.CLUSTER_VERSION }}"
247+
docker load -i /tmp/image.tar
248+
docker inspect "${IPFS_CLUSTER_K8S_IMAGE}"
245249
246250
- name: Login to registry
247251
# If the registry server is specified in the image name, we use that.
@@ -256,5 +260,5 @@ jobs:
256260
(github.event_name == 'push' || github.event_name == 'schedule') &&
257261
github.ref == 'refs/heads/main'
258262
run: |
259-
echo "Pushing to ${CLUSTER_IMAGE}:${{ env.CLUSTER_VERSION }}"
260-
docker push "${CLUSTER_IMAGE}:${{ env.CLUSTER_VERSION }}"
263+
echo "Pushing to ${IPFS_CLUSTER_K8S_IMAGE}:${{ env.CLUSTER_VERSION }}"
264+
docker push "${IPFS_CLUSTER_K8S_IMAGE}:${{ env.CLUSTER_VERSION }}"

hack/run-in-kind.sh

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,28 @@
33
set -e -o pipefail
44

55
# Declare globals
6-
KIND_TAG="local-build"
6+
if ! [[ "${KIND_TAG}" == "" ]]; then
7+
echo "❗ Using KIND_TAG: ${KIND_TAG}"
8+
fi
9+
10+
KIND_TAG="${KIND_TAG:-local-build}"
11+
12+
13+
# process arguments
14+
skipBuild="false"
15+
skipTag="false"
16+
17+
for arg in "$@"; do
18+
case "${arg}" in
19+
"--skip-build")
20+
skipBuild="true"
21+
;;
22+
"--skip-tag")
23+
skipTag="true"
24+
;;
25+
esac
26+
done
27+
728

829
################################
930
# Makes sure the given commands are installed
@@ -27,22 +48,31 @@ function check_cmd() {
2748
# make sure that helm, kind, and docker are installed
2849
check_cmd helm docker kind
2950

30-
# load them into kind
51+
# load images into kind
3152
IMAGES=(
3253
"quay.io/redhat-et-ipfs/ipfs-operator"
3354
"quay.io/redhat-et-ipfs/ipfs-cluster"
3455
)
3556

36-
# build the two images
37-
make docker-build
38-
make -C ipfs-cluster-image image
3957

58+
# build the two images
59+
if [[ "${skipBuild}" == false ]]; then
60+
make docker-build
61+
make -C ipfs-cluster-image image
62+
else
63+
echo "⏩ skipping build"
64+
fi
4065

66+
# tag the latest images
67+
if [[ "${skipTag}" == false ]]; then
68+
for i in "${IMAGES[@]}"; do
69+
docker tag "${i}:latest" "${i}:${KIND_TAG}"
70+
kind load docker-image "${i}:${KIND_TAG}"
71+
done
72+
else
73+
echo "⏩ skipping tag"
74+
fi
4175

42-
for i in "${IMAGES[@]}"; do
43-
docker tag "${i}:latest" "${i}:${KIND_TAG}"
44-
kind load docker-image "${i}:${KIND_TAG}"
45-
done
4676

4777
# using helm, install the IPFS Cluster Operator into the current cluster
4878
helm upgrade --install \

0 commit comments

Comments
 (0)