Skip to content

Commit 6c6bb93

Browse files
authored
Merge pull request #40 from allenai/henryh/setup-github_actions
add github actions workflow
2 parents f2649e7 + 49cbc5d commit 6c6bb93

File tree

5 files changed

+115
-6
lines changed

5 files changed

+115
-6
lines changed

.github/workflows/build_test.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Build, Test, and Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
SERVICE_NAME: "rslearn_projects"
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
outputs:
26+
ghcr_docker_image: ${{ steps.image-names.outputs.ghcr_image_name }}
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Log in to the Container registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels) for Docker
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: |
43+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=sha,format=long
46+
type=sha,format=short
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
- name: Build and push Docker image
50+
id: build-push
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
build-args: |
58+
GIT_USERNAME=${{ secrets.GIT_USERNAME }}
59+
GIT_TOKEN=${{ secrets.GIT_TOKEN }}
60+
61+
- name: Store Image Names
62+
# We need the docker image name downstream in test & deploy. This saves the full docker image names to outputs
63+
id: image-names
64+
run: |-
65+
GHCR_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-push.outputs.digest }}"
66+
GHCR_IMAGE=`echo ${GHCR_IMAGE} | tr '[:upper:]' '[:lower:]'` # docker requires that all image names be lowercase
67+
echo "ghcr.io Docker image name is ${GHCR_IMAGE}"
68+
echo "ghcr_image_name=\"${GHCR_IMAGE}\"" >> $GITHUB_OUTPUT
69+
70+
# TODO: Make sure skylight can grab the image tag and deploy
71+
72+
test:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
77+
- name: Log in to the Container registry
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Log in to the Container registry
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ${{ env.REGISTRY }}
88+
username: ${{ github.actor }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
- name: Build docker images
91+
run: |
92+
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -f docker-compose.yaml build
93+
94+
95+
- name: Run tests with Docker Compose
96+
run: |
97+
docker compose -f docker-compose.yaml run test pytest tests/
98+
99+
- name: Clean up
100+
if: always()
101+
run: |
102+
docker compose -f docker-compose.yaml down

.github/workflows/lint.yaml

Whitespace-only changes.

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
FROM pytorch/pytorch:2.4.0-cuda11.8-cudnn9-runtime
1+
FROM pytorch/pytorch:2.4.0-cuda11.8-cudnn9-runtime@sha256:58a28ab734f23561aa146fbaf777fb319a953ca1e188832863ed57d510c9f197
2+
3+
# TEMPORARY Until RSLEARN Is Public
4+
ARG GIT_USERNAME
5+
ARG GIT_TOKEN
26

37
RUN apt update
48
RUN apt install -y libpq-dev ffmpeg libsm6 libxext6 git
5-
COPY rslearn/requirements.txt /opt/rslearn_projects/rslearn/requirements.txt
9+
RUN git clone https://${GIT_USERNAME}:${GIT_TOKEN}@github.com/allenai/rslearn.git /opt/rslearn_projects/rslearn
610
RUN pip install -r /opt/rslearn_projects/rslearn/requirements.txt
7-
COPY rslearn/extra_requirements.txt /opt/rslearn_projects/rslearn/extra_requirements.txt
811
RUN pip install -r /opt/rslearn_projects/rslearn/extra_requirements.txt
912
COPY requirements.txt /opt/rslearn_projects/requirements.txt
1013
RUN pip install -r /opt/rslearn_projects/requirements.txt
1114

12-
# Clone and install SAM2 (Segment Anything 2)
13-
RUN git clone https://github.com/facebookresearch/segment-anything-2.git /opt/segment-anything-2
14-
RUN pip install -e /opt/segment-anything-2
15+
# We need rslp to be pip installed as well
1516

1617
ENV PYTHONPATH="${PYTHONPATH}:/opt/rslearn_projects/rslearn:."
1718

docker-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "3.9"
2+
3+
services:
4+
test:
5+
build: .

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
beaker-py
22
python-dotenv
3+
pytest

0 commit comments

Comments
 (0)