-
Notifications
You must be signed in to change notification settings - Fork 1.1k
134 lines (111 loc) · 4.08 KB
/
ci-tests.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
name: CI tests
on:
pull_request:
branches:
- master
- release-**
types:
- opened
- reopened
- synchronize
- ready_for_review
env:
TYK_DB_REDISHOST: localhost
TYK_GW_STORAGE_HOST: localhost
PYTHON_VERSION: '3.9'
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
jobs:
test:
name: Go ${{ matrix.go-version }} Redis ${{ matrix.redis-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
redis-version: [5]
python-version: ['3.9']
go-version: [1.19.x]
steps:
- name: Checkout Tyk
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies and basic hygiene test
id: hygiene
run: |
sudo apt-get install libluajit-5.1-dev
python -m pip install --upgrade pip
pip install setuptools
pip install google
pip install 'protobuf==4.24.4'
make lint
git add --all
git diff HEAD > git-state.log
git_state_count=$(wc -l < git-state.log)
if [[ $git_state_count -ne 0 ]]
then
echo "git-state<<EOF" >> $GITHUB_OUTPUT
cat git-state.log >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "make lint made git state dirty, please run make lint locally and update PR"
exit 1
fi
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}
- name: Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Gateway Tests
id: ci-tests
run: |
./bin/ci-tests.sh 2>&1
- name: Notify status
if: ${{ failure() && github.event.pull_request.number && !github.event.pull_request.draft }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :boom: CI tests failed :see_no_evil:
## git-state
```shellsession
${{ steps.hygiene.outputs.git-state || 'all ok' }}
```
Please look at [the run](https://github.com/TykTechnologies/tyk/pull/${{ github.event.pull_request.number }}/checks?check_run_id=${{ github.run_id }}) or in the _Checks_ tab.
- name: Download golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: golangci-lint
if: ${{ github.event_name == 'pull_request' }}
run: |
$(go env GOPATH)/bin/golangci-lint run --out-format checkstyle --issues-exit-code=0 --new-from-rev=origin/${{ github.base_ref }} ./... > golanglint.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_tyk
-Dsonar.sources=.
-Dsonar.exclusions=coprocess/**/*,ci/**,smoke-tests/**,apidef/oas/schema/schema.gen.go
-Dsonar.coverage.exclusions=**/*_test.go,**/mock/*
-Dsonar.test.inclusions=**/*_test.go
-Dsonar.tests=.
-Dsonar.go.coverage.reportPaths=*.cov
-Dsonar.go.golangci-lint.reportPaths=golanglint.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}