Skip to content

Commit

Permalink
ci: re-introduce CircleCI with updated implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Oct 13, 2021
1 parent 13c9028 commit 59c6b62
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .circleci/circleci-readme.md
@@ -0,0 +1,28 @@
CI Debug Notes
================
To validate some circleci stuff, I was able to run a “build locally” using the steps below.
The local build runs in a docker container.

* (Once) Install circleci client (`brew install circleci`)

* Convert the “real” config.yml into a self contained (non-workspace) config via:

circleci config process .circleci/config.yml > .circleci/local-config.yml

* Run a local build with the following command:

circleci local execute -c .circleci/local-config.yml --job 'build'

Typically, both commands are run together:

circleci config process .circleci/config.yml > .circleci/local-config.yml && circleci local execute -c .circleci/local-config.yml --job 'build'

With the above command, operations that cannot occur during a local build will show an error like this:

```
... Error: FAILED with error not supported
```

However, the build will proceed and can complete “successfully”, which allows you to verify scripts in your config, etc.

If the build does complete successfully, you should see a happy yellow `Success!` message.
125 changes: 125 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,125 @@
# Copyright 2019-present Sonatype Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 2.1

commands:
ensure_poetry_installed:
description: "Installs Poetry ready for use"
steps:
- run: |
python -m ensurepip --default-pip
pip install --upgrade pip
pip install poetry
executors:
python39:
docker:
- image: cimg/python:3.9
python38:
docker:
- image: cimg/python:3.8
python37:
docker:
- image: cimg/python:3.7
python36:
docker:
- image: cimg/python:3.6

jobs:
build_and_test:
parameters:
python_version:
type: string
executor: python<< parameters.python_version >>
steps:
- ensure_poetry_installed
- checkout
- restore_cache: # ensure this step occurs *before* installing dependencies
name: "Restore any valid cache"
key: dependencies-{{ .Branch }}-{{ checksum "poetry.lock" }}
- run:
command: |
poetry install
- save_cache:
name: "Cache dependencies"
key: dependencies-{{ .Branch }}-{{ checksum "poetry.lock" }}
paths:
- /home/circleci/.cache/pypoetry/virtualenvs
- run:
command: |
poetry build
- run:
command: |
poetry run tox -e py<< parameters.python_version >>
coding_standards:
executor: python39
steps:
- ensure_poetry_installed
- checkout
- restore_cache: # ensure this step occurs *before* installing dependencies
name: "Restore any valid cache"
key: dependencies-{{ .Branch }}-{{ checksum "poetry.lock" }}
- run:
command: |
poetry install
- save_cache:
name: "Cache dependencies"
key: dependencies-{{ .Branch }}-{{ checksum "poetry.lock" }}
paths:
- /home/circleci/.cache/pypoetry/virtualenvs
- run:
command: |
poetry run tox -eflake8
release_and_pypi_publish:
executor: python39
environment:
CIRCLECI: "true"
GH_TOKEN: None
steps:
- ensure_poetry_installed
- run:
name: "Install python-semantic-release"
command: |
export
pip install python-semantic-release
- checkout
- restore_cache: # ensure this step occurs *before* installing dependencies
name: "Restore any valid cache"
key: dependencies-{{ .Branch }}-{{ checksum "poetry.lock" }}
- run:
name: "Build for release"
command: |
poetry install
poetry build
- run:
name: "Semantic Release"
command: |
git stash -u
git fetch && git reset --hard origin/main
semantic-release --noop publish
workflows:
cicd:
jobs:
- build_and_test:
matrix:
parameters:
python_version: ["39", "38", "37", "36"]
- coding_standards
release:
jobs:
- release_and_pypi_publish

0 comments on commit 59c6b62

Please sign in to comment.