Skip to content

Jd test

Jd test #6

Workflow file for this run

name: avro
on:
push:
branches:
- master
- main
paths:
- '**.go'
- 'go.*'
- Makefile
pull_request:
paths:
- '**.go'
- 'go.*'
- Makefile
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
directory: "."
allow_lint_failure: "true"
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up env
uses: actions/setup-go@v3
with:
cache: true
check-latest: true
cache-dependency-path: ${{ env.directory }}/go.sum
go-version-file: ${{ env.directory }}/go.mod
- name: Build
run: |
make build
test:
runs-on: ubuntu-22.04
container:
image: ghcr.io/heetch/containers/heetch-base-testenv:1
services:
postgres:
image: public.ecr.aws/docker/library/postgres:13.6
env:
POSTGRES_HOST_AUTH_METHOD: trust
consul:
image: public.ecr.aws/hashicorp/consul:1.14
env:
CONSUL_LOCAL_CONFIG: |
{
"limits": {
"http_max_conns_per_client": 600
},
"protocol": 3
}
redis:
image: public.ecr.aws/docker/library/redis:6.2
rabbitmq:
image: ghcr.io/heetch/containers/heetch-rabbitmq:3.9.9
env:
RABBITMQ_ERLANG_COOKIE: secure_stuff_here
RABBITMQ_NODENAME: rabbit@rabbitmq
LANG: en_US.UTF-8
TZ: Europe/Paris
kafka:
image: ghcr.io/heetch/containers/heetch-kafka:6.2.7
env:
KAFKA_ADVERTISED_LISTENERS: INTERNAL://127.0.0.1:29092,PLAINTEXT://kafka:9092
tile38:
image: ghcr.io/heetch/containers/heetch-tile38:1.25.3
steps:
- name: Purge initial context
run: |
rm -rf $HOME/* $HOME/.* || true
- name: Checkout
uses: actions/checkout@v3
- name: Set up env
uses: actions/setup-go@v3
with:
cache: true
check-latest: true
cache-dependency-path: ${{ env.directory }}/go.sum
go-version-file: ${{ env.directory }}/go.mod
- id: get-bin-dir
shell: bash
run: |
echo bin_dir=.go-test-env >> $GITHUB_OUTPUT
- id: generate-cache-key
shell: bash
run: |
echo cache_key=$(md5sum ${GITHUB_ACTION_PATH}/action.yml | cut -d ' ' -f1) >> $GITHUB_OUTPUT
- id: cache-tools
uses: actions/cache/restore@v3
env:
bin_dir: ${{ steps.get-bin-dir.outputs.bin_dir }}
with:
path: |
${{ env.bin_dir }}/
key: setup-go-test-env-${{ runner.arch }}-${{ steps.generate-cache-key.outputs.cache_key }}
- shell: bash
if: ${{ !steps.cache-tools.outputs.cache-hit }}
run: |
export GOBIN=${GITHUB_WORKSPACE}/${{ steps.get-bin-dir.outputs.bin_dir }}
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/[email protected]
go install github.com/pressly/goose/cmd/[email protected]
ln -s $GOBIN/goose $GOBIN/goose-v2
go install github.com/mfridman/[email protected]
go install gotest.tools/[email protected]
go install github.com/heetch/universe/src/tools/uni@master
wget -O $GOBIN/datadog-ci https://github.com/DataDog/datadog-ci/releases/download/v2.7.0/datadog-ci_$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')-$(echo ${{ runner.arch }} | tr '[:upper:]' '[:lower:]')
chmod u+x $GOBIN/datadog-ci
- name: Add tools dir to PATH
env:
bin_dir: ${{ steps.get-bin-dir.outputs.bin_dir }}
shell: bash
run: |
echo ${GITHUB_WORKSPACE}/${{ env.bin_dir }} >> $GITHUB_PATH
- id: save-cache
if: ${{ !steps.cache-tools.outputs.cache-hit }}
uses: actions/cache/save@v3
env:
bin_dir: ${{ steps.get-bin-dir.outputs.bin_dir }}
with:
path: |
${{ env.bin_dir }}/
key: setup-go-test-env-${{ runner.arch }}-${{ steps.generate-cache-key.outputs.cache_key }}
- name: "Lint: static"
id: lint-static
continue-on-error: true
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
working-directory: ${{ env.directory }}
args: --timeout=5m
# cache managed by setup-go
skip-cache: true
# only-new-issues: true # incompatible with working-directory input
- name: "Lint: security"
id: lint-security
continue-on-error: true
working-directory: ${{ env.directory }}
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Unit tests
working-directory: ${{ env.directory }}
env:
CGO_ENABLED: "1"
POSTGRESQL_DATASOURCE: postgres://postgres:5432/postgres?user=postgres&password=heetch&sslmode=disable
KAFKA_ADDRS: kafka:9092
KAFKA_REGISTRY_ADDR: kafka:8081
REDIS_URL: redis://redis:6379/0
RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672
CONSUL_ADDR: consul:8500
PGSQL_HOST: postgres
TILE38_ADDR: tile38:9851
KAFKA_ZOOKEEPER_CONNECT: kafka:2181
run: |
make test