2022-03-21 14:51:05 +00:00
|
|
|
name: Go tests
|
2020-07-27 10:18:55 +00:00
|
|
|
|
2022-04-13 13:44:23 +00:00
|
|
|
# these env variables are for localstack, so we can emulate aws services
|
2021-06-11 07:53:53 +00:00
|
|
|
env:
|
|
|
|
AWS_HOST: localstack
|
2022-01-11 13:19:43 +00:00
|
|
|
SERVICES: cloudwatch,logs,kinesis
|
2021-06-11 07:53:53 +00:00
|
|
|
#those are to mimic aws config
|
2022-04-01 12:12:03 +00:00
|
|
|
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
|
|
|
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
|
|
|
AWS_REGION: us-east-1
|
2021-06-11 07:53:53 +00:00
|
|
|
#and to override our endpoint in aws sdk
|
2022-01-11 13:19:43 +00:00
|
|
|
AWS_ENDPOINT_FORCE: http://localhost:4566
|
2022-04-01 12:12:03 +00:00
|
|
|
KINESIS_INITIALIZE_STREAMS: "stream-1-shard:1,stream-2-shards:2"
|
2021-06-11 07:53:53 +00:00
|
|
|
|
2020-07-27 10:18:55 +00:00
|
|
|
on:
|
2022-04-05 09:00:11 +00:00
|
|
|
workflow_call:
|
2020-07-27 10:18:55 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
build:
|
2022-04-01 12:12:03 +00:00
|
|
|
name: "Build + tests"
|
2020-07-27 10:18:55 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-06-11 07:53:53 +00:00
|
|
|
services:
|
|
|
|
localstack:
|
2022-01-11 13:19:43 +00:00
|
|
|
image: localstack/localstack:0.13.3
|
2021-06-11 07:53:53 +00:00
|
|
|
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 }}
|
2022-04-01 12:12:03 +00:00
|
|
|
HOSTNAME_EXTERNAL: ${{ env.AWS_HOST }} # Required so that resource urls are provided properly
|
2021-06-11 07:53:53 +00:00
|
|
|
# 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
|
2022-04-13 13:44:23 +00:00
|
|
|
|
2020-07-27 10:18:55 +00:00
|
|
|
steps:
|
2022-04-13 13:44:23 +00:00
|
|
|
|
|
|
|
- name: "Set up Go 1.17"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/setup-go@v3
|
2020-07-27 10:18:55 +00:00
|
|
|
with:
|
2021-12-16 10:06:31 +00:00
|
|
|
go-version: 1.17
|
2020-07-27 10:18:55 +00:00
|
|
|
id: go
|
2022-04-13 13:44:23 +00:00
|
|
|
|
|
|
|
- name: "Clone CrowdSec"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-04-13 13:44:23 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: false
|
|
|
|
|
2020-07-27 10:18:55 +00:00
|
|
|
- name: Build
|
2022-05-23 07:50:35 +00:00
|
|
|
run: make build && go get -u github.com/ory/go-acc
|
2022-04-05 09:00:11 +00:00
|
|
|
|
2022-04-13 13:44:23 +00:00
|
|
|
- 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"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/upload-artifact@v2
|
2020-07-27 10:18:55 +00:00
|
|
|
with:
|
2022-04-13 13:44:23 +00:00
|
|
|
name: coverage.out.bz2
|
|
|
|
path: ./coverage.out.bz2
|