-
Notifications
You must be signed in to change notification settings - Fork 32
150 lines (145 loc) · 5.17 KB
/
main.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
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
get-changed-project-stack:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Git Diff
id: git-diff
uses: technote-space/get-diff-action@v6
- name: Get Changed Project and Stack
id: get-changed-project-and-stack
env:
CHANGED_PATHS: ${{ steps.git-diff.outputs.diff }}
run: |
export CHANGED_PATHS="${{ steps.git-diff.outputs.diff }}"
python3 hack/get_changed_project_stack.py
- name: Print Changed Project and Stack
run: |
echo "Changed projects: ${{ steps.get-changed-project-and-stack.outputs.changed_projects }}"
echo "Changed stacks: ${{ steps.get-changed-project-and-stack.outputs.changed_stacks }}"
outputs:
changed_projects: ${{ steps.get-changed-project-and-stack.outputs.changed_projects }}
changed_stacks: ${{ steps.get-changed-project-and-stack.outputs.changed_stacks }}
check-structure:
needs: get-changed-project-stack
runs-on: ubuntu-latest
container:
image: kusionstack/kusion:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- name: Check Structure
env:
CHANGED_PROJECTS: ${{ needs.get-changed-project-stack.outputs.changed_projects }}
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
run: python3 -m pytest -v hack/check_structure.py --junitxml ./hack/report/check-structure.xml --html ./hack/report/check-structure.html
- name: Upload Report
if: always()
uses: actions/upload-artifact@v3
with:
name: check-structure-report
path: |
hack/report/check-structure.xml
hack/report/check-structure.html
test-correctness:
needs: get-changed-project-stack
runs-on: ubuntu-latest
container:
image: kusionstack/kusion:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- name: Test Correctness
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
run: python3 -m pytest -v hack/test_correctness.py --junitxml ./hack/report/test-correctness.xml --html ./hack/report/test-correctness.html
- name: Upload Report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-correctness-report
path: |
hack/report/test-correctness.xml
hack/report/test-correctness.html
preview:
needs: [ get-changed-project-stack, check-structure, test-correctness ]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Kusion
run: curl https://www.kusionstack.io/scripts/install.sh | bash
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Setup K3d&K3s
uses: nolar/setup-k3d-k3s@v1
- name: Preview
id: preview
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
run: |
#edit the profile in the post step does not work, source kusion env file manually
source "$HOME/.kusion/.env"
python3 hack/preview_changed_stacks.py
- name: Upload Report
if: ${{ steps.preview.outputs.preview_success == 'true' }}
uses: actions/upload-artifact@v3
with:
name: preview-report
path: hack/report/preview-result.zip
apply:
needs: [get-changed-project-stack, preview]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Kusion
run: curl https://www.kusionstack.io/scripts/install.sh | bash
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Setup K3d&K3s
uses: nolar/setup-k3d-k3s@v1
- name: Apply
id: apply
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
run: |
#edit the profile in the post step does not work, source kusion env file manually
source "$HOME/.kusion/.env"
python3 hack/apply_changed_stacks.py
- name: Upload Report
if: ${{ steps.apply.outputs.apply_success == 'true' }}
uses: actions/upload-artifact@v3
with:
name: apply-report
path: hack/report/apply-result.zip