inetmock/.gitlab-ci.yml

141 lines
3.7 KiB
YAML

image: registry.gitlab.com/inetmock/ci-image/go
stages:
- test
- build
- release
- validate
- deploy
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml
variables:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: 1
DOCKER_HOST: 'tcp://docker:2376'
DOCKER_IMAGE: registry.gitlab.com/inetmock/inetmock:$CI_COMMIT_SHORT_SHA
SAST_EXCLUDED_ANALYZERS: "eslint,nodejs-scan,bandit,flawfinder,spotbugs"
test:
stage: test
needs: [ ]
script:
- task test-all html-cover-report
- task cli-cover-report | grep "total"
artifacts:
paths:
- out/coverage.html
expire_in: 7 days
expose_as: Coverage Report
reports:
junit: out/report.xml
cobertura: out/coverage.xml
lint:
stage: test
script:
- task protobuf-lint
- golangci-lint run --issues-exit-code 0 --out-format code-climate | tee gl-code-quality-report.json | jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"'
artifacts:
expire_in: 7 days
reports:
codequality: gl-code-quality-report.json
paths:
- gl-code-quality-report.json
snapshot-release:
stage: release
services:
- docker.io/docker:20.10.12-dind-alpine3.14
needs:
- test
before_script:
- sh -c 'while ! docker info 2>/dev/null 1>&2; do echo "Waiting for Docker to become available..." && sleep 1; done'
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- task snapshot-release
- docker tag registry.gitlab.com/inetmock/inetmock:latest $DOCKER_IMAGE
- docker push $DOCKER_IMAGE
except:
- tags
release:
stage: release
services:
- docker.io/docker:20.10.12-dind-alpine3.14
needs:
- test
only:
- tags
variables:
GIT_DEPTH: 0
before_script:
- sh -c 'while ! docker info 2>/dev/null 1>&2; do echo "Waiting for Docker to become available..." && sleep 1; done'
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- task release
integration-test:
stage: validate
variables:
DOCKER_ENDPOINT: docker
needs:
- job: snapshot-release
optional: true
- job: release
optional: true
services:
- docker.io/docker:20.10.12-dind-alpine3.14
before_script:
- sh -c 'while ! docker info 2>/dev/null 1>&2; do echo "Waiting for Docker to become available..." && sleep 1; done'
script:
- |
docker run -d --name inetmock -p 80:80 -p 443:443 -p 53:53/udp -p 53:53/tcp --cap-add CAP_NET_RAW --cap-add CAP_NET_BIND_SERVICE $DOCKER_IMAGE;
for i in `seq 1 20`
do
docker exec -i inetmock /usr/lib/inetmock/bin/imctl health container 2>&1 > /dev/null || sleep 1;
done;
echo "First round of checks"
task integration-test
echo "Restarting endpoints"
docker exec -i inetmock /usr/lib/inetmock/bin/imctl endpoints restart
echo "Running checks after restart of endpoints"
task integration-test
after_script:
- docker rm -f inetmock
container_scanning:
stage: validate
artifacts:
expire_in: 7 days
variables:
GIT_STRATEGY: fetch
DOCKERFILE_PATH: build/docker/inetmock.dockerfile
needs:
- job: snapshot-release
optional: true
- job: release
optional: true
pages:
stage: deploy
image: registry.gitlab.com/inetmock/ci-image/mdbook
needs: [ ]
only:
refs:
- main
- tags
script:
- mdbook build -d ./../public ./docs
artifacts:
expire_in: 7 days
paths:
- public