[SYSE-394 release-5-lts] Fix test code base for Tyk-Analytics PRs #12248
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI tests | |
on: | |
pull_request: | |
branches: | |
- master | |
- release-** | |
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 }} Redis ${{ matrix.redis-version }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
redis-version: [5] | |
python-version: ['3.9'] | |
go: [1.16] | |
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 }} | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup CI Tooling | |
uses: shrink/actions-docker-extract@v3 | |
with: | |
image: tykio/ci-tools:latest | |
path: /usr/local/bin/task | |
destination: /usr/local/bin | |
- 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 | |
echo "git-state=$(sed -ze 's/%/%25/g;s/\n/%0A/g' git-state.log)" >> $GITHUB_OUTPUT | |
git_state_count=$(wc -l < git-state.log) | |
if [[ $git_state_count -ne 0 ]] | |
then | |
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 test services | |
run: task services:up | |
- 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 | tee test.log | |
result_code=${PIPESTATUS[0]} | |
echo "log=$(sed -ze 's/%/%25/g;s/\n/%0A/g' test.log)" >> $GITHUB_OUTPUT | |
exit $result_code | |
- name: Stop test services | |
run: task services:down | |
- name: Notify status | |
if: ${{ failure() && github.event.pull_request.number }} | |
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=**/testdata/*,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 }} |