Skip to content

Merge branch 'master' into release-prep-1.5.5 #923

Merge branch 'master' into release-prep-1.5.5

Merge branch 'master' into release-prep-1.5.5 #923

Workflow file for this run

name: CI
env:
PROJECT_ROOT: /root/go/src/github.com/infrawatch/sg-core
OPSTOOLS_REPO: https://raw.githubusercontent.com/infrawatch/sg-core/04dcb34edd2c234b378222d2f9a17e15c0dad936/build/repos/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
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/[email protected]
#- 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.51
unit-tests:
name: Unit tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/[email protected]
# 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/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/[email protected]
with:
path-to-profile: ${{ github.workspace }}/profile.cov
image-build:
name: Image build
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Verify image builds
run: |
docker build --tag infrawatch/sg-core:latest --file build/Dockerfile .
- name: List images
run: |
docker images