Skip to content

Commit

Permalink
chore(test): Add hello-world and dep-test python projects
Browse files Browse the repository at this point in the history
The justfile now contains a `test-smoke` recipe that will start a local
registry, build hello-world, publish it and then install it into
dep-test, all using poetry.
  • Loading branch information
AllexVeldman committed Jun 10, 2024
1 parent ef1c79f commit 31e4c1b
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__/
build/
/target
node_modules/
.venv/
10 changes: 3 additions & 7 deletions py/docker/config/config.yaml → docker/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ storage:
enabled: true
cache:
blobdescriptor: inmemory
# inmemory:
filesystem:
rootdirectory: /var/lib/registry
inmemory:
# filesystem:
# rootdirectory: /var/lib/registry
#auth:
# silly:
# realm: http://localhost:5000/
# service: silly-service
http:
addr: :5000
# secret: "foobarbazqaz"
# tls:
# certificate: /etc/docker/registry/certs/tls.crt
# key: /etc/docker/registry/certs/tls.key
headers:
X-Content-Type-Options: [nosniff]
Access-Control-Allow-Origin: ['http://localhost:8080', 'http://localhost:5000', 'http://registry:5000']
Expand Down
File renamed without changes.
26 changes: 25 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[group("cli")]
cli-list:
cargo run -- -u AllexVeldman -p $GH_TOKEN list ghcr.io/allexveldman/pyoci

[group("dev")]
cf-worker *args:
NO_MINIFY=1 npx wrangler dev --port 8090 --local-upstream localhost:8090 {{args}}

[group("curl")]
local-publish:
curl -v http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman \
curl -v http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman/ \
-F ":action=file_upload" \
-F protocol_version=1 \
-F filetype=sdist \
Expand All @@ -15,8 +18,29 @@ local-publish:
-F version=0.1.0 \
-F content=@py/dist/pyoci-0.1.0.tar.gz

[group("curl")]
local-list:
curl -v http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman/hello-world/

[group("curl")]
local-download:
curl -vOJ http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman/pyoci/pyoci-0.1.0.tar.gz

[group("setup")]
refresh-registry:
docker compose -f docker/docker-compose.yaml up --force-recreate --wait registry

[group("poetry")]
poetry-local-publish version: refresh-registry
rm -rf tests/hello-world/dist
poetry version -C tests/hello-world {{version}}
cd tests/hello-world && poetry build
poetry publish -C tests/hello-world -r pyoci-local

[group("poetry")]
poetry-local-install version:
poetry add -C tests/dep-test hello-world@{{version}} --source pyoci-local --no-cache

[group("test")]
test-smoke: (poetry-local-publish "0.1.0") (poetry-local-install "0.1.0")
poetry run -C tests/dep-test python -m hello_world
29 changes: 0 additions & 29 deletions py/docker/config/tls/tls.crt

This file was deleted.

52 changes: 0 additions & 52 deletions py/docker/config/tls/tls.key

This file was deleted.

1 change: 1 addition & 0 deletions tests/dep-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry.lock
19 changes: 19 additions & 0 deletions tests/dep-test/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "dep-test"
version = "0.1.0"
description = "Test projects with pyoci published dependencies"
authors = ["Allex Veldman <[email protected]"]


[[tool.poetry.source]]
name = "pyoci-local"
url = "http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman/"
priority = "explicit"

[tool.poetry.dependencies]
python = "^3.8"
hello-world = {version = "0.1.0", source = "pyoci-local"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 2 additions & 0 deletions tests/hello-world/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if __name__ == "__main__":
print("hello world")
8 changes: 8 additions & 0 deletions tests/hello-world/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[repositories.pyoci-local]
url = "http://localhost:8090/http%3A%2F%2Flocalhost%3A5000/allexveldman/"

[repositories.pyoci-local-ghcr]
url = "http://localhost:8090/ghcr.io/allexveldman/"

[repositories.pyoci-ghcr]
url = "https://pyoci.allexveldman.nl/ghcr.io/allexveldman/"
13 changes: 13 additions & 0 deletions tests/hello-world/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "hello-world"
version = "0.1.0"
description = "demo package to demonstrate pyoci"
authors = ["Allex Veldman <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 31e4c1b

Please sign in to comment.