packer-cn/.circleci/config.yml

243 lines
6.9 KiB
YAML
Raw Normal View History

orbs:
win: circleci/windows@1.0.0
2020-03-12 05:36:10 -04:00
codecov: codecov/codecov@1.0.5
version: 2.1
executors:
golang:
docker:
- image: docker.mirror.hashicorp.services/circleci/golang:1.16
2020-06-29 09:12:03 -04:00
resource_class: medium+
darwin:
macos:
xcode: "12.0.0"
commands:
install-go-run-tests-unix:
parameters:
GOOS:
type: string
GOVERSION:
type: string
steps:
- checkout
- run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.<< parameters.GOOS >>-amd64.tar.gz | tar -C ~/ -xz
2020-03-12 05:36:10 -04:00
- run: ~/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic
install-go-run-tests-windows:
parameters:
GOVERSION:
type: string
steps:
- checkout
- run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.windows-amd64.zip --output ~/go<< parameters.GOVERSION >>.windows-amd64.zip
- run: unzip ~/go<< parameters.GOVERSION >>.windows-amd64.zip -d ~/
2020-03-12 05:36:10 -04:00
- run: ~/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic
build-and-persist-packer-binary:
parameters:
GOOS:
type: string
GOARCH:
default: "amd64"
type: string
steps:
- checkout
- run: GOOS=<< parameters.GOOS >> GOARCH=<<parameters.GOARCH>> go build -ldflags="-s -w -X github.com/hashicorp/packer/version.GitCommit=${CIRCLE_SHA1}" -o ./pkg/packer_<< parameters.GOOS >>_<< parameters.GOARCH >> .
- run: zip ./pkg/packer_<< parameters.GOOS >>_<< parameters.GOARCH >>.zip ./pkg/packer_<< parameters.GOOS >>_<< parameters.GOARCH >>
- run: rm ./pkg/packer_<< parameters.GOOS >>_<< parameters.GOARCH >>
- persist_to_workspace:
root: .
paths:
- ./pkg/
2018-11-14 12:37:31 -05:00
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
jobs:
test-linux:
executor: golang
resource_class: large
working_directory: /go/src/github.com/hashicorp/packer
2018-11-14 12:37:31 -05:00
steps:
- checkout
2020-03-12 05:36:10 -04:00
- run: TESTARGS="-coverprofile=coverage.txt -covermode=atomic" make ci
- codecov/upload:
file: coverage.txt
test-darwin:
executor: darwin
working_directory: ~/go/github.com/hashicorp/packer
steps:
- install-go-run-tests-unix:
GOOS: darwin
GOVERSION: "1.16"
2020-03-12 05:36:10 -04:00
- codecov/upload:
file: coverage.txt
test-windows:
executor:
name: win/vs2019
shell: bash.exe
steps:
- install-go-run-tests-windows:
GOVERSION: "1.16"
2020-03-12 05:36:10 -04:00
- codecov/upload:
file: coverage.txt
check-lint:
executor: golang
resource_class: xlarge
2020-03-12 05:36:10 -04:00
steps:
- checkout
- run: git fetch --all
2020-03-12 05:36:10 -04:00
- run:
command: make ci-lint
no_output_timeout: 30m
check-vendor-vs-mod:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
environment:
GO111MODULE: "off"
steps:
- checkout
- run: GO111MODULE=on go run . --help
- run: make check-vendor-vs-mod
check-fmt:
executor: golang
steps:
- checkout
- run: make fmt-check
check-generate:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- checkout
- run: make generate-check
build_linux:
executor: golang
steps:
- build-and-persist-packer-binary:
GOOS: linux
build_windows:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: windows
build_darwin:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: darwin
build_darwin_arm64:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: darwin
GOARCH: arm64
build_freebsd:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: freebsd
build_solaris:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: solaris
build_openbsd:
executor: golang
working_directory: /go/src/github.com/hashicorp/packer
steps:
- build-and-persist-packer-binary:
GOOS: openbsd
2019-05-09 04:40:57 -04:00
store_artifacts:
executor: golang
2019-05-09 04:40:57 -04:00
steps:
- attach_workspace:
at: .
- store_artifacts:
path: ./pkg/
2019-05-09 05:37:34 -04:00
destination: /
2020-04-02 13:05:20 -04:00
build-website-docker-image:
docker:
2020-10-29 14:05:41 -04:00
- image: docker.mirror.hashicorp.services/circleci/buildpack-deps
2020-04-02 13:05:20 -04:00
shell: /usr/bin/env bash -euo pipefail -c
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker Image if Necessary
command: |
IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
echo "Using $IMAGE_TAG"
if curl https://hub.docker.com/v2/repositories/hashicorp/packer-website/tags/$IMAGE_TAG -fsL > /dev/null; then
echo "Dependencies have not changed, not building a new website docker image."
else
cd website/
2020-10-29 14:05:41 -04:00
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_DOCKER_PASS
2020-04-02 13:05:20 -04:00
docker build -t hashicorp/packer-website:$IMAGE_TAG .
docker tag hashicorp/packer-website:$IMAGE_TAG hashicorp/packer-website:latest
docker push hashicorp/packer-website
fi
2020-06-29 15:43:35 -04:00
algolia-index:
docker:
2020-10-29 14:05:41 -04:00
- image: docker.mirror.hashicorp.services/node:12
2020-06-29 15:43:35 -04:00
steps:
- checkout
- run:
name: Push content to Algolia Index
command: |
if [ "$CIRCLE_REPOSITORY_URL" != "git@github.com:hashicorp/packer.git" ]; then
echo "Not Packer OSS Repo, not indexing Algolia"
exit 0
fi
cd website/
npm install
node scripts/index_search_content.js
2020-04-02 13:05:20 -04:00
workflows:
version: 2
test:
jobs:
- test-linux
- test-darwin
- test-windows
check-code:
jobs:
2020-03-12 05:36:10 -04:00
- check-lint
- check-vendor-vs-mod
- check-fmt
- check-generate
build_packer_binaries:
jobs:
- build_linux
- build_darwin
- build_darwin_arm64
- build_windows
- build_freebsd
- build_openbsd
- build_solaris
- store_artifacts:
2019-05-09 04:40:57 -04:00
requires:
- build_linux
- build_darwin
- build_darwin_arm64
2019-05-09 04:40:57 -04:00
- build_windows
- build_freebsd
- build_openbsd
- build_solaris
2020-06-29 15:43:35 -04:00
website:
2020-04-02 13:05:20 -04:00
jobs:
- build-website-docker-image:
filters:
branches:
only:
- master
2020-06-29 15:43:35 -04:00
- algolia-index:
filters:
branches:
only:
- stable-website