forked from infrawatch/sg-core
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (79 loc) · 2.79 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: CI
env:
PROJECT_ROOT: /root/go/src/github.com/infrawatch/sg-core
LOKI_IMAGE: grafana/loki:2.1.0
LOKI_VOLUME: "--volume=${{ github.workspace }}/ci/service_configs/loki:/etc/loki:ro"
LOKI_PORT: "-p 3100:3100"
ELASTIC_IMAGE: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
ELASTIC_PORT: "-p 9200:9200 -p 9300:9300"
TEST_IMAGE: registry.access.redhat.com/ubi8
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
on: [push, pull_request]
jobs:
golangci:
name: Linting
runs-on: ubuntu-20.04
container: 'quay.io/plmr/sg-core-ci'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: tidy
run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Caching conflicts happen in GHA, so just disable for now
skip-pkg-cache: true
skip-build-cache: true
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.33
unit-tests:
name: Unit tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
# start services
- name: Start Elasticsearch service
run: |
docker run --name elastic -e "discovery.type=single-node" $ELASTIC_PORT -d $ELASTIC_IMAGE
- name: Start Loki service
run: |
docker run --name=loki $LOKI_VOLUME $LOKI_PORT -d $LOKI_IMAGE
# run unit tests
- name: Wait for services to start successfuly and print logs
run: |
echo "===================== elasticsearch ====================="
while ! curl -sX GET "http://127.0.0.1:9200/_cluster/health"
do
sleep 1
done
docker logs elastic
echo "========================== loki ========================="
while ! curl -sX GET "http://127.0.0.1:3100/loki/api/v1/ready"
do
sleep 1
done
docker logs loki
- name: Run sg-core unit test suite
run: |
docker run --name=testsuite -uroot --network host -e COVERALLS_REPO_TOKEN \
--volume ${{ github.workspace }}:$PROJECT_ROOT:z --workdir $PROJECT_ROOT \
$TEST_IMAGE bash $PROJECT_ROOT/ci/unit/run_tests.sh
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: ${{ github.workspace }}/profile.cov
image-build:
name: Image build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Verify image builds
run: |
docker build --tag infrawatch/sg-core:latest --file build/Dockerfile .
- name: List images
run: |
docker images