Skip to content

[TT-16081] Use official golangci-lint-action v8 #1884

[TT-16081] Use official golangci-lint-action v8

[TT-16081] Use official golangci-lint-action v8 #1884

Workflow file for this run

name: CI tests
on:
pull_request:
push:
branches:
- master
env:
TYK_PMP_ANALYTICSSTORAGETYPE: redis
TYK_PMP_ANALYTICSSTORAGECONFIG_TYPE: redis
TYK_PMP_ANALYTICSSTORAGECONFIG_HOST: localhost
TYK_PMP_ANALYTICSSTORAGECONFIG_PORT: 6379
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Tyk Pump
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
timeout-minutes: 20
with:
version: v2.5.0
only-new-issues: ${{ github.event_name == 'pull_request' }}
# Output formats configured in .golangci.yml (v2 approach)
# Generates: text to stdout + checkstyle JSON for SonarQube
args: --issues-exit-code=0 -v ./...
skip-cache: false
skip-save-cache: false
- uses: actions/upload-artifact@v4
with:
name: golangcilint
retention-days: 1
path: |
golanglint.xml
test:
name: Go ${{ matrix.go }} tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
redis-version: [5]
mongodb-version: [4.2]
postgres-version: [15]
go: [1.24]
steps:
- name: Checkout Tyk Pump
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Install Dependencies and basic hygiene test
id: hygiene
run: |
go install golang.org/x/tools/cmd/goimports@latest
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: Start Redis
uses: supercharge/redis-github-action@1.2.0
with:
redis-version: ${{ matrix.redis-version }}
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.2.0
with:
mongodb-version: "${{ matrix.mongodb-version }}"
- name: Start PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql version: "${{ matrix.postgres-version }}"
postgresql db: "tyk_analytics"
postgresql user: "tyk"
postgresql password: "tyk123"
- name: Cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Pump Tests
id: ci-tests
env:
TYK_TEST_POSTGRES: "host=localhost user=tyk password=tyk123 dbname=tyk_analytics port=5432 sslmode=disable"
run: |
./bin/ci-test.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
aggregator-ci-test:
name: Aggregated CI Status
runs-on: ubuntu-latest
if: ${{ always() && github.event_name == 'pull_request' }}
needs: [ test ]
steps:
- name: Aggregate results
run: |
failed=()
# Get the needs context as JSON once
needs_json='${{ toJSON(needs) }}'
# Loop through all jobs in the needs context
for job in $(echo "$needs_json" | jq -r 'keys[]'); do
job_result=$(echo "$needs_json" | jq -r --arg job "$job" '.[$job].result')
if [[ "$job_result" != "success" ]]; then
failed+=("$job")
fi
done
if (( ${#failed[@]} )); then
# Join the failed job names with commas
failed_jobs=$(IFS=", "; echo "${failed[*]}")
echo "❌ Failed jobs ----- : $failed_jobs"
exit 1
fi
echo "✅ All required jobs succeeded"