472 lines
14 KiB
YAML
472 lines
14 KiB
YAML
version: 2.1
|
|
orbs:
|
|
aws-s3: circleci/aws-s3@2.0.0
|
|
parameters:
|
|
cross-container-tag:
|
|
# when updating the go version, should also update the go version in go.mod
|
|
description: docker tag for cross build container from quay.io . Created by https://github.com/influxdata/edge/tree/master/dockerfiles/cross-builder .
|
|
type: string
|
|
default: go1.19.10-b76a62e4c08e4a01ccfc02d6e7b7b4720ebed2ef
|
|
|
|
workflow:
|
|
type: string
|
|
default: build
|
|
|
|
commands:
|
|
install_rust:
|
|
steps:
|
|
- run:
|
|
name: Install Rust toolchain
|
|
command: |
|
|
./scripts/ci/install-rust.sh
|
|
echo 'export PATH=${HOME}/.cargo/bin:${PATH}' >> $BASH_ENV
|
|
|
|
jobs:
|
|
build_binaries:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
# We save the cache from this one, so don't restore a cache with old junk and then save new stuff alongside.
|
|
# Start either with the exact right cache, or completely fresh.
|
|
- influxdb-cache-v1-{{ checksum "go.mod" }}
|
|
- run:
|
|
name: Get InfluxDB Version
|
|
command: |
|
|
PREFIX=1.x .circleci/scripts/get-version
|
|
- run:
|
|
name: Build source tarball
|
|
command: |
|
|
set -x
|
|
|
|
printf '{
|
|
"version": "%s",
|
|
"branch": "%s",
|
|
"sha": "%s"
|
|
}' "${VERSION}" "${CIRCLE_BRANCH}" "${CIRCLE_SHA1}" >"$(pwd)/.metadata.json"
|
|
|
|
#
|
|
# Prebuild the man pages so that consumers of the source tarball don't have to build it themselves.
|
|
(cd man && make build && gzip -9 ./*.1)
|
|
|
|
mkdir -p ./tarball
|
|
TARBALL_NAME="./tarball/influxdb-src-${CIRCLE_SHA1}.tar.gz"
|
|
tar --exclude-vcs --exclude './tarball' --transform 'flags=r;s|^|influxdb/|' -vczf "${TARBALL_NAME}" .
|
|
- store_artifacts:
|
|
path: tarball/
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- tarball
|
|
- run:
|
|
name: Build binaries
|
|
command: |
|
|
export CC="$(xcc linux x86_64)"
|
|
export CGO_ENABLED=1
|
|
|
|
# linux amd64 (static build)
|
|
export GOOS=linux
|
|
export GOARCH=amd64
|
|
for cmd in github.com/influxdata/influxdb/cmd/{influxd,influx,influx_inspect}
|
|
do
|
|
go build \
|
|
-tags "netgo,osusergo,static_build" \
|
|
-buildmode=pie \
|
|
-ldflags="-s
|
|
-X \"main.version=${VERSION}\"
|
|
-X \"main.branch=${CIRCLE_BRANCH}\"
|
|
-X \"main.commit=${CIRCLE_SHA1}\"
|
|
-linkmode=external
|
|
-extld=${CC}
|
|
-extldflags \"-fno-PIC -static-pie -Wl,-z,stack-size=8388608\"" \
|
|
${cmd}
|
|
done
|
|
|
|
mkdir -p ./bins
|
|
|
|
target="bins/influxdb_bin_${GOOS}_${GOARCH}-${CIRCLE_SHA1}.tar.gz"
|
|
tar -czf "${target}" \
|
|
influx \
|
|
influx_inspect \
|
|
influxd
|
|
md5sum "${target}" > "${target}.md5"
|
|
sha256sum "${target}" > "${target}.sha256"
|
|
- store_artifacts:
|
|
path: bins/
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- bins
|
|
- save_cache:
|
|
key: influxdb-cache-v1-{{ checksum "go.mod" }}
|
|
paths:
|
|
- /go/pkg/mod
|
|
- /root/.cargo
|
|
- /root/.cache/go-build
|
|
build_packages:
|
|
machine:
|
|
enabled: true
|
|
docker_layer_caching: true
|
|
image: ubuntu-2004:202107-02
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- run: |
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
sudo -E apt-get update
|
|
sudo -E apt-get install --no-install-recommends --yes \
|
|
asciidoc \
|
|
build-essential \
|
|
git \
|
|
python3 \
|
|
rpm \
|
|
ruby-dev \
|
|
xmlto
|
|
|
|
sudo gem install fpm
|
|
|
|
( cd man ; make build ; gzip -9 ./*.1 )
|
|
|
|
python3 -m pip install -r .circleci/scripts/package/requirements.txt
|
|
|
|
# Unfortunately, this must be executed as root. This is so permission
|
|
# modifying commands (chown, chmod, etc.) succeed.
|
|
sudo --preserve-env=CIRCLE_TAG,CIRCLE_SHA1 .circleci/scripts/package/build.py
|
|
- store_artifacts:
|
|
path: packages/
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- packages
|
|
|
|
sign_packages:
|
|
circleci_ip_ranges: true
|
|
docker:
|
|
- image: quay.io/influxdb/rsign:latest
|
|
auth:
|
|
username: $QUAY_RSIGN_USERNAME
|
|
password: $QUAY_RSIGN_PASSWORD
|
|
steps:
|
|
- add_ssh_keys:
|
|
fingerpints:
|
|
- fc:7b:6e:a6:38:7c:63:5a:13:be:cb:bb:fa:33:b3:3c
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- run: |
|
|
for target in /tmp/workspace/packages/*
|
|
do
|
|
case "${target}"
|
|
in
|
|
# rsign is shipped on Alpine Linux which uses "busybox ash" instead
|
|
# of bash. ash is somewhat more posix compliant and is missing some
|
|
# extensions and niceties from bash.
|
|
*.deb|*.rpm|*.tar.gz|*.zip)
|
|
rsign "${target}"
|
|
;;
|
|
esac
|
|
|
|
if [ -f "${target}" ]
|
|
then
|
|
# Since all artifacts are present, sign them here. This saves Circle
|
|
# credits over spinning up another instance just to separate out the
|
|
# checksum job. Individual checksums are written by the
|
|
# "build_packages" script.
|
|
sha256sum "${target}" >> "/tmp/workspace/packages/influxdb.${CIRCLE_TAG}.digests"
|
|
fi
|
|
done
|
|
- persist_to_workspace:
|
|
root: /tmp/workspace
|
|
paths:
|
|
- packages
|
|
- store_artifacts:
|
|
path: /tmp/workspace/packages
|
|
|
|
test_pkgs_64bit:
|
|
machine:
|
|
enabled: true
|
|
docker_layer_caching: true
|
|
image: ubuntu-2004:202107-02
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- run:
|
|
name: Test 64 bit packages install
|
|
command: |
|
|
set -x
|
|
export WORKING_DIR=$(pwd)
|
|
# Using subshells with find to get full path of real package files, rather than predicting or hardcoding
|
|
# The glob pattern with -prune causes find to only return files rooted in packages,
|
|
# thereby avoiding files whose names would match, but are in subdirectories, i.e. packages/static.
|
|
"${WORKING_DIR}/releng/packages/spec/clean_install/run.bash" -D \
|
|
-p "$(find "/tmp/workspace/packages"/* -prune -name 'influxdb*amd64.deb')"
|
|
|
|
"${WORKING_DIR}/releng/packages/spec/clean_install/run.bash" -R \
|
|
-p "$(find "/tmp/workspace/packages"/* -prune -name 'influxdb*x86_64.rpm')"
|
|
|
|
static_code_checks:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- run:
|
|
name: checkfmt
|
|
command: ./checkfmt.sh
|
|
- run:
|
|
name: codegen
|
|
command: ./generate.sh
|
|
- run:
|
|
name: go vet
|
|
command: go vet ./...
|
|
unit_test:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- influxdb-cache-v1-{{ checksum "go.mod" }}
|
|
- influxdb-cache-v1
|
|
- run:
|
|
name: Execute tests
|
|
command: |
|
|
set -x
|
|
mkdir -p junit
|
|
gotestsum --junitfile junit/influxdb.junit.xml -- ./...
|
|
no_output_timeout: 1500s
|
|
- store_test_results:
|
|
path: junit/
|
|
unit_test_tsi:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
resource_class: large
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- influxdb-cache-v1-{{ checksum "go.mod" }}
|
|
- influxdb-cache-v1
|
|
- run:
|
|
name: Execute tests
|
|
command: |
|
|
set -x
|
|
mkdir -p junit-tsi
|
|
export INFLUXDB_DATA_INDEX_VERSION="tsi1"
|
|
gotestsum --junitfile junit-tsi/influxdb.junit.xml -- ./...
|
|
no_output_timeout: 1500s
|
|
- store_test_results:
|
|
path: junit-tsi/
|
|
unit_test_race:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
resource_class: xlarge
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- influxdb-cache-v1-{{ checksum "go.mod" }}
|
|
- influxdb-cache-v1
|
|
- run:
|
|
name: Execute tests
|
|
command: |
|
|
set -x
|
|
mkdir -p junit-race/
|
|
export GORACE="halt_on_error=1"
|
|
# "resource_class: xlarge" creates a Docker container with eight
|
|
# virtual cpu cores. However, applications like "nproc" return
|
|
# the host machine's core count (which in this case is 36).
|
|
# When less cores are available than advertised, the
|
|
# race-tests fail.
|
|
#
|
|
# We'll manually reduce the number of available cores to what
|
|
# is specified by the CircleCI documentation:
|
|
# https://circleci.com/product/features/resource-classes/
|
|
taskset -c 0-7 \
|
|
gotestsum --junitfile junit-race/influxdb.junit.xml -- -race ./...
|
|
no_output_timeout: 1500s
|
|
- store_test_results:
|
|
path: junit-race/
|
|
fluxtest:
|
|
docker:
|
|
- image: quay.io/influxdb/cross-builder:<< pipeline.parameters.cross-container-tag >>
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Execute test
|
|
command: ./test-flux.sh || exit 1
|
|
no_output_timeout: 1500s
|
|
|
|
changelog:
|
|
docker:
|
|
- image: quay.io/influxdb/changelogger:d7093c409adedd8837ef51fa84be0d0f8319177a
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Generate Changelog
|
|
command: |
|
|
PRODUCT=OSS changelogger
|
|
- store_artifacts:
|
|
path: changelog_artifacts/
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- changelog_artifacts
|
|
|
|
s3-publish-changelog:
|
|
parameters:
|
|
build_type:
|
|
type: string
|
|
docker:
|
|
- image: ubuntu:latest
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- run:
|
|
name: Publish CHANGELOG.md to S3
|
|
command: |
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update
|
|
apt-get install -y awscli
|
|
|
|
pushd /tmp/workspace/changelog_artifacts/
|
|
|
|
case "<< parameters.build_type >>"
|
|
in
|
|
nightly)
|
|
aws s3 cp CHANGELOG.md "s3://dl.influxdata.com/platform/nightlies/<< pipeline.git.branch >>/CHANGELOG.md"
|
|
;;
|
|
release)
|
|
aws s3 cp CHANGELOG.md "s3://dl.influxdata.com/influxdb/releases/CHANGELOG.<< pipeline.git.tag >>.md"
|
|
;;
|
|
esac
|
|
|
|
s3-publish-packages:
|
|
docker:
|
|
- image: ubuntu:latest
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp/workspace
|
|
- checkout
|
|
- run:
|
|
name: Publish Packages to S3
|
|
command: |
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update
|
|
apt-get install -y awscli
|
|
|
|
aws s3 sync /tmp/workspace/packages "s3://dl.influxdata.com/influxdb/releases"
|
|
|
|
release_filter: &release_filter
|
|
filters:
|
|
tags:
|
|
# This matches "semantic version" tags. These tags must start with
|
|
# a "v" and have a Major, Minor, and Patch section. After the main
|
|
# section matches, all other identifiers are matched. This allows
|
|
# for alphas, betas, and release candidates.
|
|
only: /^v(\d+).(\d+).(\d+)/
|
|
branches:
|
|
ignore: /.*/
|
|
|
|
workflows:
|
|
version: 2.1
|
|
release:
|
|
when:
|
|
equal: [ << pipeline.parameters.workflow >>, build ]
|
|
jobs:
|
|
- build_binaries:
|
|
<<: *release_filter
|
|
- build_packages:
|
|
<<: *release_filter
|
|
requires:
|
|
- build_binaries
|
|
- sign_packages:
|
|
<<: *release_filter
|
|
requires:
|
|
- build_packages
|
|
- test_pkgs_64bit:
|
|
<<: *release_filter
|
|
requires:
|
|
- build_packages
|
|
- changelog:
|
|
<<: *release_filter
|
|
- s3-publish-changelog:
|
|
<<: *release_filter
|
|
build_type: release
|
|
requires:
|
|
- changelog
|
|
- s3-publish-packages:
|
|
<<: *release_filter
|
|
requires:
|
|
- sign_packages
|
|
- static_code_checks:
|
|
<<: *release_filter
|
|
- fluxtest:
|
|
<<: *release_filter
|
|
- unit_test:
|
|
<<: *release_filter
|
|
- unit_test_tsi:
|
|
<<: *release_filter
|
|
- unit_test_race:
|
|
<<: *release_filter
|
|
on_push:
|
|
when:
|
|
equal: [ << pipeline.parameters.workflow >>, build ]
|
|
jobs:
|
|
- build_binaries
|
|
- build_packages:
|
|
requires:
|
|
- build_binaries
|
|
- test_pkgs_64bit:
|
|
requires:
|
|
- build_packages
|
|
- static_code_checks
|
|
- fluxtest
|
|
- unit_test
|
|
- unit_test_tsi
|
|
- unit_test_race
|
|
nightly:
|
|
when:
|
|
and:
|
|
# This requires a pipeline trigger with a custom "workflow" parameter
|
|
# set to "nightly". Since we want to trigger this workflow on several
|
|
# branches, we cannot use the trigger name as suggested by the
|
|
# documentation.
|
|
#
|
|
# For more information:
|
|
# https://circleci.com/docs/scheduled-pipelines/
|
|
- equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
|
|
- equal: [ << pipeline.parameters.workflow >>, nightly ]
|
|
jobs:
|
|
- changelog
|
|
- s3-publish-changelog:
|
|
build_type: nightly
|
|
requires:
|
|
- changelog
|
|
- static_code_checks
|
|
- fluxtest
|
|
- unit_test
|
|
- unit_test_tsi
|
|
- unit_test_race
|
|
- build_binaries:
|
|
requires:
|
|
- changelog
|
|
- static_code_checks
|
|
- fluxtest
|
|
- unit_test
|
|
- unit_test_tsi
|
|
- unit_test_race
|
|
- build_packages:
|
|
requires:
|
|
- build_binaries
|
|
- test_pkgs_64bit:
|
|
requires:
|
|
- build_packages
|