dnscontrol/.circleci/config.yml
Jan-Philipp Benecke 81d76fb164
Run go fmt after build, so deps are there (#1557)
Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>
2022-06-20 07:33:25 -04:00

169 lines
5.1 KiB
YAML

version: 2.1
parameters:
cache-key:
type: integer
default: 1639697695
description: Change to force cache reset `pwsh > Get-Date -UFormat %s`
gover:
type: string
default: "1.18" # https://circleci.com/developer/images/image/cimg/go#image-tags
description: Go Version to use
jobs:
build:
docker:
- image: cimg/go:<< pipeline.parameters.gover >>
resource_class: 2xlarge
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results
steps:
- checkout
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >>
- run:
name: Install goreleaser
command: go install github.com/goreleaser/goreleaser@latest
- run: mkdir -p "$TEST_RESULTS"
- run:
name: Run unit tests
# store the results of our tests in the $TEST_RESULTS directory
command: gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES
- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results
- run:
name: Build binaries
command: goreleaser build --snapshot
- run:
name: Enforce Go Formatted Code
command: "[ `go fmt ./... | wc -l` -eq 0 ]"
- save_cache: # restores saved cache if no changes are detected since last run
key: linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >>
paths:
- /home/circleci/go/pkg/mod
integration-tests:
docker:
- image: cimg/go:<< pipeline.parameters.gover >>
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results
GOTESTSUM_FORMAT: testname
BIND_DOMAIN: example.com
# FYI: Hexonet provides these credentials for use for public testing. They give access to a test area, not a real system. It is not a security issue to expose them.
#
# FYI: The domain name name was selected at random. If it stops working, this command will list domains to choose from:
# echo '{ "hexo": { "apientity": "OTE", "apilogin": "test.user", "apipassword": "test.passw0rd" } }' > hexo-creds.json ; dnscontrol get-zones --creds hexo-creds.json --format=nameonly hexo HEXONET all
HEXONET_DOMAIN: a-b-c-music.com
HEXONET_ENTITY: OTE
HEXONET_PW: test.passw0rd
HEXONET_UID: test.user
AZURE_DNS_RESOURCE_GROUP: DNSControl
GCLOUD_EMAIL: dnscontrol@dnscontrol-dev.iam.gserviceaccount.com
GCLOUD_PROJECT: dnscontrol-dev
GCLOUD_TYPE: service_account
NAMEDOTCOM_URL: api.name.com
NAMEDOTCOM_USER: dnscontroltest
parameters:
provider:
type: string
steps:
- checkout
- run: mkdir -p "$TEST_RESULTS"
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >>
- run:
name: Run integration tests for << parameters.provider >> provider
working_directory: integrationTest
no_output_timeout: 32m
command: |
if [ -n "$<< parameters.provider >>_DOMAIN" ] ; then
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- -timeout 30m -v -verbose -provider << parameters.provider >> -cfworkers=false
else
echo "Skip test for << parameters.provider >> provider"
fi
- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results
release:
docker:
- image: cimg/go:<< pipeline.parameters.gover >>
resource_class: 2xlarge
steps:
- checkout
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- linux-go-{{ checksum "go.sum" }}-<< pipeline.parameters.cache-key >>
- setup_remote_docker:
version: 20.10.11
- run:
name: Install goreleaser
command: go install github.com/goreleaser/goreleaser@latest
- run: goreleaser release
workflows:
version: 2
build:
jobs:
- build
- integration-tests:
requires: [build]
context: DNSProviders
matrix:
parameters:
provider:
# Providers that don't require secrets: (alphabetical)
- BIND
- HEXONET
# Providers designated "officially supported": (alphabetical)
- AZURE_DNS
- CLOUDFLAREAPI
- GCLOUD
- NAMEDOTCOM
- ROUTE53
# All others: (alphabetical)
- CLOUDNS
- DIGITALOCEAN
- GANDI_V5
- HEDNS
- INWX
- POWERDNS
- release:
requires: [integration-tests]
# Only run this job on git tag pushes
filters:
branches:
only: [main, master]
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/