Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
matbun committed Nov 6, 2024
1 parent dd36593 commit dddad31
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: integration-tests

on:
push:
#branches: [main,next,next2next]
pull_request:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Integration Test
uses: dagger/dagger-for-github@v6
with:
workdir: ci
verb: call
args: build-container --context=.. --dockerfile=../env-files/torch/Dockerfile publish
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
version: "latest"
8 changes: 6 additions & 2 deletions ci/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Example of running dagger pipeline of build and local test for torch container
dagger call \
build-torch --context=.. --dockerfile=../env-files/torch/Dockerfile \
test-torch
build-container --context=.. --dockerfile=../env-files/torch/Dockerfile \
test-local

dagger call \
build-container --context=.. --dockerfile=../env-files/torch/Dockerfile \
publish
32 changes: 24 additions & 8 deletions ci/src/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from typing import Annotated, Optional, Self
import dataclasses
import random

import dagger
from dagger import dag, function, object_type, Doc
Expand All @@ -31,10 +32,10 @@
@object_type
class Itwinai:

torch_container: Optional[dagger.Container] = dataclasses.field(default=None, init=False)
container: Optional[dagger.Container] = dataclasses.field(default=None, init=False)

@function
def build_torch(
def build_container(
self,
context: Annotated[
dagger.Directory,
Expand All @@ -45,25 +46,40 @@ def build_torch(
Doc("location of Dockerfile"),
],
) -> Self:
"""Build itwinai torch container image from existing Dockerfile"""
self.torch_container = (
"""Build itwinai container image from existing Dockerfile"""
self.container = (
dag.container()
.build(context=context, dockerfile=dockerfile)
)
return self

@function
async def test_torch(self) -> str:
"""Test itwinai torch container image with pytest on non-HPC environments."""
async def test_local(self) -> str:
"""Test itwinai container image with pytest on non-HPC environments."""
test_cmd = [
"pytest",
"-v",
"-m",
"not hpc",
"not hpc and not functional",
"tests"
]
return await (
self.torch_container
self.container
.with_exec(test_cmd)
.stdout()
)

@function
async def publish(
self,
registry: str = "ghcr.io/intertwin-eu",
name: str = "itwinai-dev",
tag: Optional[str] = None
) -> str:
"""Push container to registry"""
tag = tag if tag else random.randrange(10 ** 8)

# Test locally
await self.test_local()

return await self.container.publish(f"{registry}/{name}:{tag}")

0 comments on commit dddad31

Please sign in to comment.