1
1
_all : dist build
2
2
3
- GITHUB_REF := $(shell echo "refs/heads/"`git rev-parse --abbrev-ref HEAD`)
4
- GITHUB_SHA := $(shell echo `git rev-parse --verify HEAD^{commit}`)
3
+ GIT_REF := $(shell echo "refs/heads/"`git rev-parse --abbrev-ref HEAD`)
4
+ GIT_SHA := $(shell echo `git rev-parse --verify HEAD^{commit}`)
5
5
6
6
dist :
7
- docker build -t actions_build_artifacts:$(GITHUB_SHA ) .github/actions/build_artifacts/
8
- docker run --rm -e GITHUB_REF=$(GITHUB_REF ) -e GITHUB_SHA=$(GITHUB_SHA ) -v ` pwd` /quickstart:/opt/quickstart:z actions_build_artifacts:$(GITHUB_SHA )
7
+ rm -rf quickstart/_dist
9
8
10
- build : dist
11
- docker build --file oci/Dockerfile --progress plain -t kubestack/framework:local-$(GITHUB_SHA ) .
9
+ docker build \
10
+ --build-arg GIT_REF=${GIT_REF} \
11
+ --build-arg GIT_SHA=${GIT_SHA} \
12
+ --file oci/Dockerfile \
13
+ --progress plain \
14
+ -t dist-helper:latest \
15
+ --target dist-helper \
16
+ .
12
17
13
- test :
14
- cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS} ,_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD} ,_KBST_AUTH_AZ=${KBST_AUTH_AZ} ,_GITHUB_REF=$(GITHUB_REF ) ,_GITHUB_SHA=$(GITHUB_SHA ) --dryrun=false --config cloudbuild-test.yaml .
18
+ docker run \
19
+ --detach \
20
+ --name dist-helper \
21
+ --rm dist-helper:latest \
22
+ sleep 600
15
23
16
- test-cleanup :
17
- cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS} ,_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD} ,_KBST_AUTH_AZ=${KBST_AUTH_AZ} ,_GITHUB_REF=$(GITHUB_REF ) ,_GITHUB_SHA=$(GITHUB_SHA ) --dryrun=false --config cloudbuild-cleanup.yaml .
24
+ docker cp dist-helper:/quickstart/_dist quickstart/_dist
25
+ docker stop dist-helper
26
+
18
27
19
- providers :
20
- cloud-build-local --substitutions=_KBST_AUTH_AWS=${KBST_AUTH_AWS} ,_KBST_AUTH_GCLOUD=${KBST_AUTH_GCLOUD} ,_KBST_AUTH_AZ=${KBST_AUTH_AZ} ,_GITHUB_REF=$(GITHUB_REF ) ,_GITHUB_SHA=$(GITHUB_SHA ) --dryrun=false --config cloudbuild-providers.yaml .
28
+ build :
29
+ docker build \
30
+ --build-arg GIT_REF=${GIT_REF} \
31
+ --build-arg GIT_SHA=${GIT_SHA} \
32
+ --file oci/Dockerfile \
33
+ --progress plain \
34
+ -t kubestack/framework:local-$(GIT_SHA ) \
35
+ .
21
36
22
- shell : build
23
- docker run -ti --rm -e KBST_AUTH_AWS -e KBST_AUTH_AZ -e KBST_AUTH_GCLOUD -e HOME=/infra/tests/.user -v ` pwd` :/infra:z --workdir /infra/tests kubestack/framework:local-$(GITHUB_SHA ) bash
37
+ validate : .init
38
+ docker exec \
39
+ test-container-$(GIT_SHA ) \
40
+ entrypoint terraform validate
41
+
42
+ test : validate
43
+ docker exec \
44
+ test-container-$(GIT_SHA ) \
45
+ entrypoint terraform apply --input=false --auto-approve
46
+
47
+ cleanup : .init
48
+ docker exec \
49
+ -ti \
50
+ test-container-$(GIT_SHA ) \
51
+ entrypoint terraform destroy --input=false --auto-approve
52
+ $(MAKE ) .stop-container
53
+
54
+ shell : .init
55
+ docker exec \
56
+ -ti \
57
+ test-container-$(GIT_SHA ) \
58
+ entrypoint bash
59
+
60
+ .check-container :
61
+ docker inspect test-container-${GIT_SHA} > /dev/null || $(MAKE ) .run-container
62
+
63
+ .run-container : build
64
+ docker run \
65
+ --detach \
66
+ --name test-container-${GIT_SHA} \
67
+ --rm \
68
+ -v ` pwd` :/infra:z \
69
+ -e KBST_AUTH_AWS \
70
+ -e KBST_AUTH_AZ \
71
+ -e KBST_AUTH_GCLOUD \
72
+ -e HOME=/infra/tests/.user \
73
+ --workdir /infra/tests \
74
+ kubestack/framework:local-$(GIT_SHA ) \
75
+ sleep infinity
76
+
77
+ .stop-container :
78
+ docker stop test-container-${GIT_SHA} || true
79
+
80
+ .init : .check-container
81
+ docker exec \
82
+ test-container-$(GIT_SHA ) \
83
+ entrypoint terraform init
84
+ docker exec \
85
+ test-container-$(GIT_SHA ) \
86
+ entrypoint terraform workspace select ops
0 commit comments