Skip to content

[SYSE-394 release-5.6] Fix test code base for Tyk-Analytics PRs #12189

[SYSE-394 release-5.6] Fix test code base for Tyk-Analytics PRs

[SYSE-394 release-5.6] Fix test code base for Tyk-Analytics PRs #12189

Workflow file for this run

# yamllint disable rule:line-length
---
name: CI tests
on:
pull_request:
branches:
- master
- release-**
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- master
- release-**
# Only have one runner per PR, and per merged commit.
#
# - As a PR gets new commits, any old run jobs get cancelled (PR number)
# - As a commit gets merged, it doesn't cancel previous running PR's (github.sha)
concurrency:
group: ${{ github.event.pull_request.number || github.sha }}-ci-tests
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
jobs:
test:
name: Go ${{ matrix.go-version }} Redis ${{ matrix.redis-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
# This workflow isn't designed to be run as a pipeline, several issues:
#
# - contains golangci-lint jobs, sonarcloud (would duplicate)
# - cache config not suitable for multiple pipelines
# - python tests should be separate job, or no job
#
# Keep it to a single job run from the matrix as configured
# until we get a chance to redesign the pipeline properly.
matrix:
redis-version: [7]
python-version: ["3.11"]
go-version: [1.22.x]
env:
REDIS_IMAGE: redis:${{ matrix.redis-version }}
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: Setup CI Tooling
uses: shrink/actions-docker-extract@v3
with:
image: tykio/ci-tools:latest
path: /usr/local/bin/.
destination: /usr/local/bin
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- 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'
task --version
task 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 "task lint made git state dirty, please run task lint locally and update PR"
echo
cat git-state.log
exit 1
fi
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: Print CPU info
run: grep '^model name' /proc/cpuinfo
- name: Print Go env
run: go env
- name: Run Gateway Tests
id: ci-tests
run: |
task test:e2e-combined args="-race -timeout=15m"
task test:coverage
# golangci-lint actions *require* issues-exit-code=0 to pass data along to sonarcloud
# rather than erroring out on github issues directly with out-format github.
- name: golangci-lint
if: ${{ github.event_name == 'pull_request' }}
run: |
golangci-lint run --out-format checkstyle --issues-exit-code=0 --new-from-rev=origin/${{ github.base_ref }} ./... > golanglint.xml
- name: golangci-lint-on-push
if: ${{ github.event_name == 'push' }}
run: |
golangci-lint run --out-format checkstyle --issues-exit-code=0 ./... > golanglint.xml
- name: SonarCloud Scan
if: always()
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_tyk
-Dsonar.sources=.
-Dsonar.exclusions=**/testdata/*,test/**,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=coverage/gateway-all.cov
-Dsonar.go.golangci-lint.reportPaths=golanglint.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}