forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (161 loc) · 5.93 KB
/
cloud-workflow.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
---
name: cloud-workflow
on: # yamllint disable-line rule:truthy
push:
branches:
- master
- 'v1.*'
pull_request:
branches:
- master
- 'v1.*'
types: [opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
path_filter:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@v2
if: github.event_name == 'push'
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/cloud-workflow.yml", "lte/protos/**", "cwf/cloud/**", "feg/cloud/**", "lte/cloud/**", "orc8r/**"]
- name: Save should_not_skip output
if: always()
run: |
mkdir -p ./pr
echo -n ${{ steps.changes.outputs.filesChanged == 'false' }} > ./pr/skipped
- uses: actions/upload-artifact@v2
if: always()
with:
name: pr
path: pr/
# Fail if checked-in generated code doesn't match output from
# generation command.
cloud-tests:
needs: path_filter
if: ${{ needs.path_filter.outputs.should_not_skip == 'true' }}
name: cloud-tests
runs-on: ubuntu-latest
env:
MAGMA_ROOT: "${{ github.workspace }}"
GO111MODULE: 'on'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: deploy-sync-checkin
if: always()
id: deploy-sync-checkin
run: |
cd ${MAGMA_ROOT}/orc8r/cloud/deploy/orc8r_deployer/docker
./run_deployer.bash --deploy-dir /tmp/deploy_dir --build --test check_all
- name: Lint cloud Go code
if: always()
id: cloud-lint-lint
run: |
cd ${MAGMA_ROOT}/orc8r/cloud/docker
python3 build.py --lint
- name: Generate test coverage
if: always() && steps.cloud-lint-lint.outcome=='success'
id: cloud-lint-cov
run: |
cd ${MAGMA_ROOT}/orc8r/cloud/docker
python3 build.py --coverage
- uses: codecov/codecov-action@v1
if: always() && steps.cloud-lint-cov.outcome=='success'
id: cloud-lint-codecov
with:
files: '${{ env.MAGMA_ROOT}}/orc8r/cloud/coverage/all.gocov'
flags: cloud_lint
- name: Run tests cloud Go
if: always()
id: cloud-test
run: |
cd ${MAGMA_ROOT}/orc8r/cloud/docker
python3 build.py --tests --up
ls ${MAGMA_ROOT}/orc8r/cloud/test-results
timeout-minutes: 15
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: "${{ env.MAGMA_ROOT}}/orc8r/cloud/test-results/*"
- uses: actions/setup-go@v2
if: always()
id: gateway_test_init
with:
go-version: '1.13'
- name: Download dependencies
if: always() && steps.gateway_test_init.outcome=='success'
id: gateway_test_dep
run: |
cd cwf/gateway
go mod download
- name: Gateway go tests
if: always() && steps.gateway_test_dep.outcome=='success'
id: gateway_test
run: |
cd ${MAGMA_ROOT}/orc8r/gateway/go
go test ./...
go vet ./...
- name: Extract commit title
if: failure() && github.event_name == 'push'
id: commit
run: |
str="$(jq '.head_commit.message' $GITHUB_EVENT_PATH)" # get the head_commit message
echo ::set-output name=title::${str%%\\n*} | tr -d '"'
- name: Notify failure to Slack for deploy-sync-checkin
if: steps.deploy-sync-checkin.outcome=='failure' && github.event_name == 'push'
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "Github action insync-checkin failed"
SLACK_USERNAME: "Cloud workflow"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
- name: Notify failure to Slack for cloud-test
if: steps.cloud-test.outcome=='failure' && github.event_name == 'push'
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "Github action cloud-test failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: "Cloud workflow"
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
- name: Notify failure to Slack for cloud-lint
if: ( steps.cloud-lint.outcome=='failure' || steps.cloud-lint-codecov.outcome=='failure' || steps.cloud-lint-cov.outcome=='failure' ) && github.event_name == 'push'
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "Github action cloud-test failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: "Cloud workflow"
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
- name: Notify failure to Slack for orc8r-gateway-test
if: ( steps.gateway_test_init.outcome=='failure' || steps.gateway_test_dep.outcome=='failure' || steps.gateway_test.outcome=='failure' ) && github.event_name == 'push'
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "Github action orc8r-gateway-test failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: "Cloud workflow"
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '