forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (81 loc) · 3.14 KB
/
cwf-operator.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
# Copyright 2022 The Magma Authors.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: cwf-operator
on:
push:
branches:
- master
- 'v1.*'
pull_request:
branches:
- master
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
# Map a step output to a job output
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
if: github.event_name == 'push'
- uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721 # pin@v2
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/cwf-operator.yml", "cwf/**", "k8s/**"]
cwf-operator-precommit:
needs: path_filter
if: ${{ needs.path_filter.outputs.should_not_skip == 'true' }}
name: cwf operator pre-commit job
runs-on: ubuntu-latest
env:
GO111MODULE: on
MAGMA_ROOT: "${{ github.workspace }}"
steps:
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
- uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # pin@v3
with:
go-version: '1.18.3'
- name: Run golang_before_install.sh script
run: ./.github/workflows/scripts/golang_before_install.sh
- name: Run go mod download with retry
uses: nick-invision/retry@e88a9994b039653512d697de1bce46b00bfe11b5 # pin@v2
with:
command: cd ${MAGMA_ROOT}/cwf/k8s/cwf_operator && go mod download
timeout_minutes: 10
- name: Run precommit
run: |
cd ${MAGMA_ROOT}/cwf/k8s/cwf_operator
make -C ${MAGMA_ROOT}/cwf/k8s/cwf_operator precommit
- name: Extract commit title
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 '"'
# Notify ci channel when failing
# Plugin info: https://github.com/marketplace/actions/slack-notify
- name: Notify failure to slack
if: failure() && github.ref == 'refs/heads/master'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # pin@v2.2.0
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "CWF-operator-precommit tests failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: "CWF workflow"
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ''