forked from chaos-mesh/chaos-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (133 loc) · 4.08 KB
/
ci.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
# This workflow defines the go and ui related jobs.
#
# First, we use [dorny/paths-filter@v3](https://github.com/dorny/paths-filter) to
# detect changes in go and ui related files, and then run the corresponding sub-jobs
# based on the changes.
#
# Please note that due to the GitHub required checks, the `go` and `ui` jobs
# also need to run to report the status. So here we need to define an additional
# "skip" file to ensure that the status is reported. For details, please refer to:
#
# - `ci_skip.yml`
# - https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: ci
on:
pull_request:
branches:
- master
- release-*
permissions: read-all
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-20.04
# Set job outputs to values from filter step
outputs:
go: ${{ steps.filter.outputs.go }}
ui: ${{ steps.filter.outputs.ui }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
go:
- Makefile
- go.*
- '**.go'
- 'helm/**'
ui:
- 'ui/pnpm-lock.yaml'
- '**.js'
- '**.ts?(x)'
go:
needs: changes
if: ${{ needs.changes.outputs.go == 'true' }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
job:
- verify
- build
- test
runs-on: ${{ fromJson('{"amd64":"ubuntu-20.04", "arm64":["self-hosted", "Linux", "ARM64"]}')[matrix.arch] }}
steps:
- uses: actions/checkout@v4
- name: Build Chaos Mesh Build Env
env:
IMAGE_BUILD_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-build-env-image') }}
run: |
if [ "${IMAGE_BUILD_ENV_BUILD}" = "true" ] ; then
export IMAGE_BUILD_ENV_BUILD=1;
else
export IMAGE_BUILD_ENV_BUILD=0;
fi
make image-build-env
- name: Build Chaos Mesh Dev Env
env:
IMAGE_DEV_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-dev-env-image') }}
run: |
if [ "${IMAGE_DEV_ENV_BUILD}" = "true" ] ; then
export IMAGE_DEV_ENV_BUILD=1;
else
export IMAGE_DEV_ENV_BUILD=0;
fi
make image-dev-env
- name: ${{ matrix.job }}
env:
job: ${{ matrix.job }}
run: |
if [[ "$job" == "verify" ]]; then
make check
echo "Please run [make check] before creating a PR"
git diff --quiet
elif [[ "$job" == "build" ]]; then
make image
elif [[ "$job" == "test" ]]; then
make test
else
make $job
fi
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
if: matrix.job == 'test'
with:
files: ./cover.out
ui:
needs: changes
if: ${{ needs.changes.outputs.ui == 'true' }}
defaults:
run:
working-directory: ./ui
strategy:
matrix:
job:
- build
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
cache-dependency-path: "ui/pnpm-lock.yaml"
- run: pnpm install --frozen-lockfile
- name: Cache app/build
if: ${{ matrix.job == 'build' }}
uses: actions/cache@v2
with:
path: ./ui/app/build
key: ${{ runner.os }}-pnpm-${{ hashFiles('ui/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Build app
if: ${{ matrix.job == 'build' }}
run: pnpm build
- name: Run tests
if: ${{ matrix.job == 'test' }}
run: pnpm test