2021-10-12 06:32:06 +08:00
version : 2.1
2021-12-17 20:14:27 +08:00
parameters :
cache-key :
type : integer
default : 1639697695
description : Change to force cache reset `pwsh > Get-Date -UFormat %s`
gover :
type : string
2022-03-25 00:53:42 +08:00
default : "1.18" # https://circleci.com/developer/images/image/cimg/go#image-tags
2021-12-17 20:14:27 +08:00
description : Go Version to use
2021-10-12 06:32:06 +08:00
jobs :
2021-12-17 20:14:27 +08:00
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 >>
2022-06-18 20:56:04 +08:00
- run :
name : Enforce Go Formatted Code
command : "[ `go fmt ./... 2>&1 | wc -l` -eq 0 ]"
2021-12-17 20:14:27 +08:00
- 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
- 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
2021-12-22 01:23:11 +08:00
HEXONET_DOMAIN : a-b-c-music.com
2021-12-17 20:14:27 +08:00
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
2022-02-02 03:47:27 +08:00
no_output_timeout : 32m
2021-12-17 20:14:27 +08:00
command : |
if [ -n "$<< parameters.provider >>_DOMAIN" ] ; then
2022-02-02 03:47:27 +08:00
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- -timeout 30m -v -verbose -provider << parameters.provider >> -cfworkers=false
2021-12-17 20:14:27 +08:00
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
2021-10-12 06:32:06 +08:00
workflows :
2021-12-17 20:14:27 +08:00
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]+)*(-.*)*/