-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (145 loc) · 4.75 KB
/
build_dev.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
name: Build and push for dev
env:
MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }}
CI_COMMIT_REF_NAME: ${{ github.ref_name }}
MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }}
MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }}
MODULES_REGISTRY_LOGIN: ${{ vars.DEV_MODULES_REGISTRY_LOGIN }}
MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }}
on:
pull_request:
types: [ opened, edited, synchronize ]
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
jobs:
show_dev_manifest:
runs-on: ubuntu-latest
name: Show
steps:
- name: Set vars for PR
if: ${{ github.ref_name != 'main' }}
run: |
MODULES_MODULE_TAG="$(echo pr${{github.event.pull_request.number}})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
shell: bash
- name: Set vars for main
if: ${{ github.ref_name == 'main' }}
run: |
MODULES_MODULE_TAG="$(echo v0.0.0-${{ github.ref_name }})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
shell: bash
- name: Show dev config
run: |
cat << OUTER
Create ModuleConfig and ModulePullOverride resources to test this MR:
cat <<EOF | kubectl apply -f -
---
apiVersion: deckhouse.io/v1alpha1
kind: ModulePullOverride
metadata:
name: ${MODULES_MODULE_NAME}
spec:
imageTag: ${MODULES_MODULE_TAG}
source: deckhouse
---
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: ${MODULES_MODULE_NAME}
spec:
enabled: true
settings:
dvcr:
storage:
type: PersistentVolumeClaim
persistentVolumeClaim:
size: 50G
virtualMachineCIDRs:
- 10.66.10.0/24
- 10.66.20.0/24
- 10.66.30.0/24
version: 1
EOF
Or patch an existing ModulePullOverride:
kubectl patch mpo ${MODULES_MODULE_NAME} --type merge -p '{"spec":{"imageTag":"${MODULES_MODULE_TAG}"}}'
OUTER
shell: bash
lint:
runs-on: ubuntu-latest
name: Run linter
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: "1.20"
- name: Install Task
uses: arduino/setup-task@v1
- uses: actions/checkout@v4
- name: Run lint virtualization-controller
run: |
task virtualization-controller:init
task virtualization-controller:lint:go
shell: bash
continue-on-error: true
test:
runs-on: ubuntu-latest
name: Run unit test
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: "1.20"
- name: Install Task
uses: arduino/setup-task@v1
- uses: actions/checkout@v4
- name: Run test hooks
run: |
task hooks:test
shell: bash
- name: Run unit test virtualization-controller
run: |
task virtualization-controller:init
task virtualization-controller:test:unit
shell: bash
dev_setup_build:
runs-on: ubuntu-latest
name: Build and Push images
needs:
- lint
- test
steps:
- name: Set vars for PR
if: ${{ github.ref_name != 'main' }}
run: |
MODULES_MODULE_TAG="$(echo pr${{github.event.pull_request.number}})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
shell: bash
- name: Set vars for main
if: ${{ github.ref_name == 'main' }}
run: |
MODULES_MODULE_TAG="$(echo v0.0.0-${{ github.ref_name }})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
shell: bash
- name: Print vars
run: |
echo MODULES_REGISTRY=$MODULES_REGISTRY
echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME
echo MODULES_MODULE_NAME=$MODULES_MODULE_NAME
echo MODULES_MODULE_SOURCE=$MODULES_MODULE_SOURCE
echo MODULES_MODULE_TAG=$MODULES_MODULE_TAG
shell: bash
- uses: actions/checkout@v4
- uses: deckhouse/modules-actions/setup@v1
- uses: deckhouse/modules-actions/build@v1
- name: Register the module
run: |
echo "✨ Register the module ${MODULES_MODULE_NAME}"
crane append \
--oci-empty-base \
--new_layer "" \
--new_tag "${MODULES_MODULE_SOURCE}:${MODULES_MODULE_NAME}"
shell: bash