Skip to content

Commit 178517a

Browse files
authored
Add CI (#2)
1 parent bc173ed commit 178517a

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

.github/workflows/ci.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group:
11+
${{ github.workflow }}-${{ github.ref_name }}-${{
12+
github.event.pull_request.number || github.sha }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build:
17+
name: "build image"
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build and export
26+
uses: docker/build-push-action@v6
27+
with:
28+
tags: uv-docker-example:latest
29+
cache-from: type=gha,scope=uv-docker-example
30+
cache-to: type=gha,mode=min,scope=uv-docker-example
31+
outputs: type=docker,dest=/tmp/uv-docker-example.tar
32+
33+
- name: Upload artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: uv-docker-example
37+
path: /tmp/uv-docker-example.tar
38+
39+
test:
40+
name: "test image"
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Download artifact
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: uv-docker-example
50+
path: /tmp
51+
52+
- name: Load image
53+
run: |
54+
docker load --input /tmp/uv-docker-example.tar
55+
docker image ls -a
56+
57+
- name: Test image
58+
run: ./run.sh hello

run.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@
1212
# -it $(docker build -q .) Build the image, then use it as a run target
1313
# $@ Pass any arguments to the container
1414

15+
if [ -t 1 ]; then
16+
INTERACTIVE="-it"
17+
else
18+
INTERACTIVE=""
19+
fi
20+
1521
docker run \
1622
--rm \
1723
--volume .:/app \
1824
--volume /app/.venv \
19-
-it $(docker build -q .) \
20-
$@
25+
$INTERACTIVE \
26+
$(docker build -q .) \
27+
"$@"

src/uv_docker_example/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def hello() -> str:
2-
return "Hello from uv-docker-example!"
2+
print("Hello from uv-docker-example!")

0 commit comments

Comments
 (0)