crowdsec/.github/workflows/go-tests.yml

73 lines
2.1 KiB
YAML
Raw Normal View History

name: Go tests
# these env variables are for localstack, so we can emulate aws services
env:
AWS_HOST: localstack
2022-01-11 13:19:43 +00:00
SERVICES: cloudwatch,logs,kinesis
#those are to mimic aws config
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_REGION: us-east-1
#and to override our endpoint in aws sdk
2022-01-11 13:19:43 +00:00
AWS_ENDPOINT_FORCE: http://localhost:4566
KINESIS_INITIALIZE_STREAMS: "stream-1-shard:1,stream-2-shards:2"
on:
workflow_call:
jobs:
build:
name: "Build + tests"
runs-on: ubuntu-latest
services:
localstack:
2022-01-11 13:19:43 +00:00
image: localstack/localstack:0.13.3
ports:
- 4566:4566 # Localstack exposes all services on same port
env:
SERVICES: ${{ env.SERVICES }}
DEBUG: ""
DATA_DIR: ""
LAMBDA_EXECUTOR: ""
KINESIS_ERROR_PROBABILITY: ""
DOCKER_HOST: unix:///var/run/docker.sock
HOST_TMP_FOLDER: "/tmp"
2022-01-11 13:19:43 +00:00
KINESIS_INITIALIZE_STREAMS: ${{ env.KINESIS_INITIALIZE_STREAMS }}
HOSTNAME_EXTERNAL: ${{ env.AWS_HOST }} # Required so that resource urls are provided properly
# e.g sqs url will get localhost if we don't set this env to map our service
options: >-
--name=localstack
--health-cmd="curl -sS 127.0.0.1:4566 || exit 1"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: "Set up Go 1.17"
uses: actions/setup-go@v3
with:
go-version: 1.17
id: go
- name: "Clone CrowdSec"
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false
- name: Build
2022-05-23 07:50:35 +00:00
run: make build && go get -u github.com/ory/go-acc
- name: "Run tests"
run: |
go run github.com/ory/go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models
bzip2 ./coverage.out
- name: "Coverage report artifact"
uses: actions/upload-artifact@v2
with:
name: coverage.out.bz2
path: ./coverage.out.bz2