Skip to content
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
89 changes: 80 additions & 9 deletions .github/workflows/medcat-trainer_ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: medcat-trainer ci-build

on:
push:
branches: [main]
tags:
- "medcat-trainer/v*.*.*"
pull_request:
paths:
- "medcat-trainer/**"
- ".github/workflows/medcat-trainer**"

permissions:
id-token: write

defaults:
run:
working-directory: ./medcat-trainer
Expand Down Expand Up @@ -45,6 +52,23 @@ jobs:
cd client
python -m build

- name: Bump version for TestPyPI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - this was on the todo list!

if: github.ref == 'refs/heads/main'
run: sed -i "s/^version = .*/version = \"1.0.0.dev$(date +%s)\"/" client/pyproject.toml

- name: Publish dev distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.ref == 'refs/heads/main'
with:
repository_url: https://test.pypi.org/legacy/
packages_dir: medcat-trainer/client/dist

- name: Publish production distribution to PyPI
if: startsWith(github.ref, 'refs/tags') && ! github.event.release.prerelease
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: medcat-trainer/client/dist

test-frontend:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -115,20 +139,67 @@ jobs:
- test-client
- test-frontend
- test-backend
outputs:
image_version: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout main
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}

- name: Build
env:
IMAGE_TAG: ${{ env.RELEASE_VERSION }}
run: |
docker build -t cogstacksystems/medcat-trainer:dev-latest webapp/.
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

- name: Extract metadata (tags, labels) for Docker MedCATtrainer
id: meta
uses: docker/metadata-action@v5
with:
images: cogstacksystems/medcat-trainer
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# Include all default tags
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
# Create version tag based on tag prefix
type=match,pattern=medcat-trainer/v(\d+\.\d+\.\d+),group=1
flavor: latest=false

- name: Build Docker MedCATtrainer image for testing
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./medcat-trainer/webapp/
load: true # https://docs.docker.com/build/ci/github-actions/test-before-push/
tags: cogstacksystems/medcat-trainer:test
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=cogstacksystems/medcat-trainer:buildcache
cache-to: type=registry,ref=cogstacksystems/medcat-trainer:buildcache,mode=max

- name: Run Django Tests
env:
IMAGE_TAG: ${{ env.RELEASE_VERSION }}
run: |
# run tests
docker run --rm cogstacksystems/medcat-trainer:dev-latest python manage.py test
# run tests using the built image
docker run --rm cogstacksystems/medcat-trainer:test python manage.py test

- name: Push Docker MedCATtrainer image
id: docker_build_push
uses: docker/build-push-action@v6
with:
context: ./medcat-trainer/webapp/
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=cogstacksystems/medcat-trainer:buildcache
cache-to: type=registry,ref=cogstacksystems/medcat-trainer:buildcache,mode=max

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
153 changes: 0 additions & 153 deletions .github/workflows/medcat-trainer_qa.yml

This file was deleted.

Loading