Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #2

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

concurrency:
group:
${{ github.workflow }}-${{ github.ref_name }}-${{
github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
build:
name: "build image"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v6
with:
tags: uv-docker-example:latest
cache-from: type=gha,scope=uv-docker-example
cache-to: type=gha,mode=min,scope=uv-docker-example
outputs: type=docker,dest=/tmp/uv-docker-example.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: uv-docker-example
path: /tmp/uv-docker-example.tar

test:
name: "test image"
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: uv-docker-example
path: /tmp

- name: Load image
run: |
docker load --input /tmp/uv-docker-example.tar
docker image ls -a
- name: Test image
run: ./run.sh hello
11 changes: 9 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@
# -it $(docker build -q .) Build the image, then use it as a run target
# $@ Pass any arguments to the container

if [ -t 1 ]; then
INTERACTIVE="-it"
else
INTERACTIVE=""
fi

docker run \
--rm \
--volume .:/app \
--volume /app/.venv \
-it $(docker build -q .) \
$@
$INTERACTIVE \
$(docker build -q .) \
"$@"
2 changes: 1 addition & 1 deletion src/uv_docker_example/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def hello() -> str:
return "Hello from uv-docker-example!"
print("Hello from uv-docker-example!")