Skip to content

Merge branch 'master' into include_tenant_names #24

Merge branch 'master' into include_tenant_names

Merge branch 'master' into include_tenant_names #24

Workflow file for this run

name: CI
env:
PROJECT_ROOT: /root/go/src/github.com/infrawatch/sg-core
OPSTOOLS_REPO: https://git.centos.org/rpms/centos-release-opstools/raw/c8s-sig-opstools/f/SOURCES/CentOS-OpsTools.repo
LOKI_IMAGE: quay.io/infrawatch/loki:2.4.2
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/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v3
#- name: download libraries
# run: go mod download
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Caching conflicts happen in GHA, so just disable for now
skip-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.50
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:https://127.0.0.1:9200/_cluster/health"
do
sleep 1
done
docker logs elastic
echo "========================== loki ========================="
while ! curl -sX GET "http:https://127.0.0.1:3100/ready" | grep -q "^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 -e OPSTOOLS_REPO \
--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
- uses: actions/setup-go@v2
with:
go-version: '1.19'
- name: Verify image builds
run: |
docker build --tag infrawatch/sg-core:latest --file build/Dockerfile .
- name: List images
run: |
docker images