зеркало из https://github.com/mozilla/crlite.git
205 строки
5.2 KiB
YAML
205 строки
5.2 KiB
YAML
version: 2.1
|
|
|
|
orbs:
|
|
python: circleci/python@1.3.4
|
|
docker: circleci/docker@2.5.0
|
|
|
|
commands:
|
|
build-and-publish-image:
|
|
description: Build and publish a single image
|
|
|
|
parameters:
|
|
tag:
|
|
default: ${CIRCLE_SHA1}
|
|
type: string
|
|
path:
|
|
default: containers
|
|
type: string
|
|
|
|
steps:
|
|
- docker/check
|
|
- run:
|
|
name: Generate version.json
|
|
command: |
|
|
# create a version.json per https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
|
|
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
|
|
"$CIRCLE_SHA1" \
|
|
"$CIRCLE_TAG" \
|
|
"$CIRCLE_PROJECT_USERNAME" \
|
|
"$CIRCLE_PROJECT_REPONAME" \
|
|
"$CIRCLE_BUILD_URL" > version.json
|
|
- docker/build:
|
|
image: ${DOCKER_IMAGE}
|
|
tag: <<parameters.tag>>
|
|
dockerfile: <<parameters.path>>/Dockerfile
|
|
step-name: build crlite container
|
|
- docker/push:
|
|
image: ${DOCKER_IMAGE}
|
|
tag: <<parameters.tag>>
|
|
step-name: push crlite container
|
|
|
|
jobs:
|
|
python-build-and-test:
|
|
executor: python/default
|
|
steps:
|
|
- checkout
|
|
- run: pip install pytest
|
|
|
|
- run:
|
|
name: Install Package
|
|
command: |
|
|
pip install --editable .
|
|
|
|
- run:
|
|
name: Run Tests
|
|
command: |
|
|
pip install pytest
|
|
mkdir test-results
|
|
python -m pytest --junitxml=test-results/junit.xml
|
|
|
|
- store_test_results:
|
|
path: test-results
|
|
- store_artifacts:
|
|
path: test-results
|
|
|
|
- run:
|
|
name: Check format with Black
|
|
command: |
|
|
pip install "black==22.3.0"
|
|
python -m black --check .
|
|
|
|
golang-build-and-test:
|
|
docker:
|
|
# specify the version
|
|
- image: circleci/golang:1.13
|
|
auth:
|
|
username: ${DOCKER_LOGIN}
|
|
password: ${DOCKER_PASSWORD}
|
|
|
|
|
|
working_directory: /go/src/github.com/mozilla.com/crlite
|
|
steps:
|
|
- checkout
|
|
|
|
# specify any bash command here prefixed with `run: `
|
|
- run:
|
|
name: Download and build
|
|
command: go get -v -t -d ./...
|
|
working_directory: /go/src/github.com/mozilla.com/crlite/go
|
|
- run:
|
|
name: gofmt
|
|
command: >
|
|
if [ -n "$(gofmt -l .)" ]; then
|
|
echo "Go code is not formatted:"; gofmt -d .; exit 1;
|
|
fi
|
|
|
|
working_directory: /go/src/github.com/mozilla.com/crlite/go
|
|
- run:
|
|
name: Test
|
|
command: go test -v ./...
|
|
working_directory: /go/src/github.com/mozilla.com/crlite/go
|
|
|
|
- run:
|
|
name: Test with race-finder
|
|
command: go test -race -short ./...
|
|
working_directory: /go/src/github.com/mozilla.com/crlite/go
|
|
|
|
rust-create-cascade-build-and-test:
|
|
docker:
|
|
- image: cimg/rust:1.82.0
|
|
environment:
|
|
RUSTFLAGS: '-D warnings'
|
|
working_directory: ~/crlite/rust-create-cascade
|
|
steps:
|
|
- checkout:
|
|
path: ~/crlite/
|
|
- run:
|
|
name: Version information
|
|
command: rustc --version; cargo --version; rustup --version
|
|
- run:
|
|
name: rustfmt
|
|
command: rustfmt --check src/*.rs
|
|
- run:
|
|
name: Run Tests
|
|
command: cargo test -r
|
|
|
|
publish-dev-image:
|
|
executor: docker/docker
|
|
steps:
|
|
- setup_remote_docker
|
|
- checkout
|
|
- build-and-publish-image:
|
|
tag: ${CIRCLE_SHA1}
|
|
|
|
publish-tagged-image:
|
|
executor: docker/docker
|
|
steps:
|
|
- setup_remote_docker
|
|
- checkout
|
|
- build-and-publish-image:
|
|
tag: ${CIRCLE_TAG}
|
|
|
|
publish-latest-image:
|
|
executor: docker/docker
|
|
steps:
|
|
- setup_remote_docker
|
|
- checkout
|
|
- build-and-publish-image:
|
|
tag: latest
|
|
|
|
workflows:
|
|
version: 2
|
|
|
|
untagged-build:
|
|
jobs:
|
|
- python-build-and-test
|
|
- golang-build-and-test
|
|
- rust-create-cascade-build-and-test
|
|
- publish-dev-image:
|
|
filters:
|
|
branches:
|
|
only: dev
|
|
requires:
|
|
- python-build-and-test
|
|
- golang-build-and-test
|
|
- rust-create-cascade-build-and-test
|
|
- publish-latest-image:
|
|
filters:
|
|
branches:
|
|
only: main
|
|
requires:
|
|
- python-build-and-test
|
|
- golang-build-and-test
|
|
- rust-create-cascade-build-and-test
|
|
|
|
tagged-build:
|
|
jobs:
|
|
- python-build-and-test:
|
|
filters:
|
|
branches:
|
|
ignore: /.*/
|
|
tags:
|
|
only: /^v.*/
|
|
- golang-build-and-test:
|
|
filters:
|
|
branches:
|
|
ignore: /.*/
|
|
tags:
|
|
only: /^v.*/
|
|
- rust-create-cascade-build-and-test:
|
|
filters:
|
|
branches:
|
|
ignore: /.*/
|
|
tags:
|
|
only: /^v.*/
|
|
- publish-tagged-image:
|
|
filters:
|
|
branches:
|
|
ignore: /.*/
|
|
tags:
|
|
only: /^v.*/
|
|
requires:
|
|
- python-build-and-test
|
|
- golang-build-and-test
|
|
- rust-create-cascade-build-and-test
|