Skip to content

Commit b6ebd55

Browse files
Create poetry example (#32)
* Create poetry examples * WIP: update poetry install package example. * Create example for installing dependencies * Create upload package example for Poetry * Add new line at end of file * Poetry is included with the image * Tweaking examples and adding tests * Add description to upload example * Add test-set_env_vars_for_poetry to jobs * Tweak poetry command * Tweak bash script for Poetry Command * Remove trailing spaces * Add space to if statement * Remove $'s * Update poetry parameters * Update repo name * Add verbose mode * test upload package example for poetry * Create simple package for twine, poetry and cli * Call poetry upload example in test * Rename test package * Revert back to simplepkg-py * Tweak poetry upload test * Fix indentation * Update poetry command * Update poetry auth params * Update toml file * Update toml file * Update poetry upload example * Update directory * check that poetry-package location * Update poetry install example * Update commands * Update poetry install example * Remove lock command * Remove version * Revert to previous approach * Add description and author * Change package version * Change order of tests and update url * Update poetry install command * Add simplepkg * Update poetry install test * Add a package to the toml file * Include package version * Try requests library * Remove lock * Try verbose mode for debugging issue * Try making library install more verbose * Remove authentication * Add authentication back in and remove poetry shell * Update commands * Remove add simplepkg * Update command naming and remove poetry add command * cd into poetry package * Refactor tests * Update examples to reflect changes * Update src/commands/set_env_vars_for_poetry.yml Co-authored-by: robertboulton <[email protected]> * Update src/examples/poetry_install_packages.yml Co-authored-by: robertboulton <[email protected]> * Update example * Update source url label and remove upload command * Remove superfluous directory block * Add comments to explain arbitrary label cloudsmith-source-url * Remove redundant packages * Move comment to the description section * Move comments to the description section * Remove white space * Add poetry dependency * Add lock argument * Add -q switch * Add poetry show * Update poetry install example * Update .circleci/test-deploy.yml Co-authored-by: robertboulton <[email protected]> * Update src/examples/poetry_install_packages.yml Co-authored-by: robertboulton <[email protected]> * Update src/examples/upload_package_using_poetry.yml Co-authored-by: robertboulton <[email protected]> * Update src/scripts/set_env_vars_for_poetry.sh Co-authored-by: robertboulton <[email protected]> * Update src/examples/poetry_install_packages.yml Co-authored-by: robertboulton <[email protected]> * Update src/scripts/set_env_vars_for_poetry.sh Co-authored-by: robertboulton <[email protected]> * Remove test blocks * Update orb version * Update simplepkg version --------- Co-authored-by: robertboulton <[email protected]>
1 parent c73f949 commit b6ebd55

12 files changed

+181
-19
lines changed

.circleci/simplepkg-py/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Hello
1+
Hello

.circleci/test-deploy.yml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,73 @@ jobs:
8181
verify_ssl = true
8282
name = "cloudsmith"
8383
[packages]
84-
simplepkg = "0.0.1"
84+
simplepkg = "0.4.3"
8585
[requires]
8686
python_version = "3.9"
8787
EOT
8888
- run: pipenv install
8989

90+
test-set_env_vars_for_poetry:
91+
docker:
92+
- image: cimg/python:3.9
93+
resource_class: small
94+
steps:
95+
- checkout
96+
- cloudsmith-python/set_env_vars_for_poetry:
97+
repository: "circleci-orb-testing"
98+
- run:
99+
name: Assert environment variables have been set
100+
command: |
101+
if [ $CLOUDSMITH_POETRY_USERNAME != "circleci-orb-testing" ]
102+
then
103+
echo "Test failed: CLOUDSMITH_POETRY_USERNAME has not been set correctly."
104+
exit 1
105+
fi
106+
if [ -z $CLOUDSMITH_POETRY_PASSWORD ]
107+
then
108+
echo "Test failed: CLOUDSMITH_POETRY_PASSWORD has not been set."
109+
exit 1
110+
fi
111+
echo "All tests passed."
112+
113+
test-upload_package_using_poetry:
114+
docker:
115+
- image: cimg/python:3.9
116+
resource_class: small
117+
steps:
118+
- checkout
119+
- cloudsmith-python/set_env_vars_for_poetry:
120+
repository: circleci-orb-testing
121+
- run:
122+
# cloudsmith-source-url is an arbitrary label for the Cloudsmith Source URL
123+
name: Create Poetry package and publish package
124+
command: |
125+
poetry new poetry-package
126+
cd poetry-package
127+
poetry source add --priority=default cloudsmith-source-url https://python.cloudsmith.io/financial-times/circleci-orb-testing/
128+
poetry config http-basic.cloudsmith-source-url $CLOUDSMITH_POETRY_USERNAME $CLOUDSMITH_POETRY_PASSWORD
129+
poetry build
130+
poetry publish -r cloudsmith-source-url
131+
132+
test-poetry_install_packages_example:
133+
docker:
134+
- image: cimg/python:3.9
135+
steps:
136+
- checkout
137+
- cloudsmith-python/set_env_vars_for_poetry:
138+
repository: circleci-orb-testing
139+
- run:
140+
# cloudsmith-source-url is an arbitrary label for the Cloudsmith Source URL
141+
name: Create Poetry package and install dependencies
142+
command: |
143+
poetry new poetry-package
144+
cd poetry-package
145+
poetry source add --priority=default cloudsmith-source-url https://packages.ft.com/basic/circleci-orb-testing/python/simple/
146+
poetry config http-basic.cloudsmith-source-url $CLOUDSMITH_POETRY_USERNAME $CLOUDSMITH_POETRY_PASSWORD
147+
poetry add -q simplepkg
148+
poetry install
149+
poetry show
150+
90151
test-configure_pip_example:
91152
docker:
92153
- image: cimg/python:3.9
@@ -189,6 +250,12 @@ workflows:
189250
- test-pipenv_install_package_example:
190251
context: circleci-orb-publishing
191252
filters: *filters
253+
- test-set_env_vars_for_poetry:
254+
context: circleci-orb-publishing
255+
filters: *filters
256+
- test-poetry_install_packages_example:
257+
context: circleci-orb-publishing
258+
filters: *filters
192259
- test-configure_pip_example:
193260
context: circleci-orb-publishing
194261
filters: *filters
@@ -203,6 +270,10 @@ workflows:
203270
filters: *filters
204271
requires:
205272
- test-upload_package_using_twine
273+
- test-upload_package_using_poetry:
274+
context: circleci-orb-publishing
275+
filters: *filters
276+
206277
# The orb must be re-packed for publishing, and saved to the workspace.
207278
- orb-tools/pack:
208279
filters: *release-filters
@@ -217,10 +288,13 @@ workflows:
217288
- test-pip_install_package_example
218289
- test-pip_install_requirements_example
219290
- test-pipenv_install_package_example
291+
- test-set_env_vars_for_poetry
292+
- test-poetry_install_packages_example
220293
- test-configure_pip_example
221294
- test-set_env_vars_for_twine
222295
- test-upload_package_using_twine
223296
- test-upload_package_using_cli
297+
- test-upload_package_using_poetry
224298
# Use a context to hold your publishing token.
225299
context: circleci-orb-publishing
226300
filters: *release-filters
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
description:
2+
Generate temporary Cloudsmith credentials using OIDC and construct a poetry username and password from the service account credentials. On completion the command sets the CLOUDSMITH_POETRY_USERNAME and CLOUDSMITH_POETRY_PASSWORD environment variables for use with poetry.
3+
parameters:
4+
repository:
5+
description: The identity/slug of the Cloudsmith repository
6+
type: string
7+
steps:
8+
- run:
9+
name: Cloudsmith - Configure defaults
10+
command: <<include(scripts/configure_cloudsmith_defaults.sh)>>
11+
- cloudsmith-oidc/authenticate_with_oidc
12+
- run:
13+
name: Cloudsmith - Set CLOUDSMITH_POETRY_USERNAME and CLOUDSMITH_POETRY_PASSWORD environment variables
14+
command: <<include(scripts/set_env_vars_for_poetry.sh)>>
15+
environment:
16+
CLOUDSMITH_REPOSITORY: <<parameters.repository>>

src/examples/configure_pip_index_url.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >
33
usage:
44
version: 2.1
55
orbs:
6-
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.0
6+
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.1
77
jobs:
88
build:
99
docker:

src/examples/pip_install_package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >
33
usage:
44
version: 2.1
55
orbs:
6-
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.0
6+
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.1
77
jobs:
88
build:
99
docker:

src/examples/pip_install_requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >
33
usage:
44
version: 2.1
55
orbs:
6-
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.0
6+
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.1
77
jobs:
88
build:
99
docker:

src/examples/pipenv_install_packages.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ description: >
33
usage:
44
version: 2.1
55
orbs:
6-
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.0
7-
jobs:
8-
build:
9-
docker:
10-
- image: cimg/python:3.9
11-
steps:
12-
- checkout
13-
- run: python -m ensurepip --upgrade
14-
- cloudsmith-python/set_env_vars_for_pip:
15-
repository: your-repository-id
16-
- run: python -m pip install pipenv
17-
- run: pipenv install
6+
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.1
7+
jobs:
8+
build:
9+
docker:
10+
- image: cimg/python:3.9
11+
steps:
12+
- checkout
13+
- run: python -m ensurepip --upgrade
14+
- cloudsmith-python/set_env_vars_for_pip:
15+
repository: your-repository-id
16+
- run: python -m pip install pipenv
17+
- run: pipenv install
1818

1919
workflows:
2020
main:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
description: >
2+
Install a package from Cloudsmith using poetry.
3+
The source URL in pyproject.toml must be set to https://packages.ft.com/basic/your-repository-id/python/simple/
4+
and the corresponding cloudsmith-source-url parameter is an arbitrary label for the Cloudsmith Source URL.
5+
usage:
6+
version: '2.1'
7+
orbs:
8+
cloudsmith-python: ft-circleci-orbs/[email protected]
9+
jobs:
10+
build:
11+
docker:
12+
- image: cimg/python:3.9
13+
steps:
14+
- checkout
15+
- cloudsmith-python/set_env_vars_for_poetry:
16+
repository: your-repository-id
17+
- run: >-
18+
poetry config http-basic.cloudsmith-source-url $CLOUDSMITH_POETRY_USERNAME $CLOUDSMITH_POETRY_PASSWORD
19+
poetry add -q simplepkg
20+
poetry install
21+
22+
workflows:
23+
main:
24+
jobs:
25+
- build

src/examples/upload_package_using_cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >
33
usage:
44
version: 2.1
55
orbs:
6-
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.0
6+
cloudsmith-python: ft-circleci-orbs/cloudsmith-python@1.1
77
jobs:
88
build:
99
docker:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
description: >
2+
Upload a package from Cloudsmith using poetry.
3+
For uploads, the source URL in pyproject.toml must be set to https://python.cloudsmith.io/financial-times/your-repository-id/
4+
and the corresponding parameter cloudsmith-source-url is an arbitrary label for the Cloudsmith Source URL.
5+
usage:
6+
version: '2.1'
7+
orbs:
8+
cloudsmith-python: ft-circleci-orbs/[email protected]
9+
jobs:
10+
build:
11+
docker:
12+
- image: cimg/python:3.9
13+
steps:
14+
- checkout
15+
- cloudsmith-python/set_env_vars_for_poetry:
16+
repository: your-repository-id
17+
- run:
18+
name: Create Poetry package and publish package
19+
command: |
20+
poetry config http-basic.cloudsmith-source-url $CLOUDSMITH_POETRY_USERNAME $CLOUDSMITH_POETRY_PASSWORD
21+
poetry build
22+
poetry publish -r cloudsmith-source-url
23+
24+
workflows:
25+
main:
26+
jobs:
27+
- build

0 commit comments

Comments
 (0)