Compare commits

..

5 commits

Author SHA1 Message Date
Oskar Kapala 88ffab434c ci: derive changed files from commit
All checks were successful
ci / changes (push) Successful in 2s
ci / backend (push) Successful in 1m47s
ci / flutter (push) Successful in 1m7s
2026-01-16 15:56:03 +01:00
Oskar Kapala 081d885242 ci: improve change detection by event
Some checks failed
ci / changes (push) Successful in 3s
ci / backend (push) Successful in 1m49s
ci / flutter (push) Has been cancelled
2026-01-16 15:54:08 +01:00
Oskar Kapala b87c0b0221 ci: fetch more history for diff
Some checks failed
ci / changes (push) Successful in 3s
ci / backend (push) Has been cancelled
ci / flutter (push) Has been cancelled
2026-01-16 15:52:32 +01:00
Oskar Kapala a477e1ff54 ci: avoid python in change detection
Some checks failed
ci / changes (push) Successful in 3s
ci / backend (push) Successful in 2m1s
ci / flutter (push) Has been cancelled
2026-01-16 15:49:40 +01:00
Oskar Kapala b94705e1c0 ci: replace paths filter action
Some checks failed
ci / changes (push) Failing after 3s
ci / backend (push) Has been skipped
ci / flutter (push) Has been skipped
2026-01-16 15:40:24 +01:00
3 changed files with 47 additions and 44 deletions

View file

@ -13,21 +13,51 @@ jobs:
changes:
runs-on: docker
steps:
- uses: https://github.com/actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 2
- id: filter
uses: https://github.com/dorny/paths-filter@v3
with:
list-files: shell
filters: |
backend:
- 'back001/**'
- 'ci/**'
frontend:
- 'front001/**'
- 'ci/**'
name: Detect changes
run: |
set -euo pipefail
git fetch --quiet --depth=1 origin "${GITHUB_BASE_REF:-}" || true
files=""
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ] && [ -n "${GITHUB_BASE_REF:-}" ]; then
base_ref="origin/${GITHUB_BASE_REF}"
if git rev-parse --verify "$base_ref" >/dev/null 2>&1; then
files="$(git diff --name-only "$base_ref"...HEAD)" || true
else
files=""
fi
fi
if [ -z "$files" ]; then
if [ -n "${GITHUB_SHA:-}" ]; then
files="$(git show --name-only --pretty= "${GITHUB_SHA}")"
else
files="$(git show --name-only --pretty= HEAD)"
fi
fi
backend=false
frontend=false
while IFS= read -r path; do
case "$path" in
back001/*|.forgejo/workflows/*|ci/*) backend=true ;;
esac
case "$path" in
front001/*|.forgejo/workflows/*|ci/*) frontend=true ;;
esac
done <<EOF
$files
EOF
{
echo "backend=$backend"
echo "frontend=$frontend"
} >> "$GITHUB_OUTPUT"
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
@ -39,9 +69,9 @@ jobs:
container:
image: forgejo.okit.pl/oskar/ci-gradle-node:8.7-jdk17
steps:
- uses: https://github.com/actions/checkout@v4
- uses: actions/checkout@v4
- uses: https://github.com/actions/cache@v4
- uses: actions/cache@v4
with:
path: |
/home/gradle/.gradle/caches
@ -61,9 +91,9 @@ jobs:
container:
image: forgejo.okit.pl/oskar/ci-flutter-node:stable
steps:
- uses: https://github.com/actions/checkout@v4
- uses: actions/checkout@v4
- uses: https://github.com/actions/cache@v4
- uses: actions/cache@v4
with:
path: |
/root/.pub-cache

View file

@ -40,15 +40,13 @@ class InvitationService(
@Transactional
@PreAuthorize("hasRole('ADMIN')")
fun createPatientInvite(email: String, createdByAdmin: String?): InviteCreationResult {
val tenantId = TenantContext.getTenantId() ?: throw IllegalArgumentException("Missing tenant")
requireNotNull(TenantContext.getTenantId()) { "Missing tenant" }
val patient = Patient(UUID.randomUUID().toString(), generatePatientPlaceholderName())
patient.tenantId = tenantId
val savedPatient = patientRepository.save(patient)
keycloakProvisioningService.provisionUser(email, Invitation.ROLE_PATIENT)?.let { userId ->
val user = User(userId, email, Invitation.ROLE_PATIENT, "INVITED")
user.tenantId = tenantId
userRepository.save(user)
}
keycloakProvisioningService.sendSetPasswordEmail(email)
@ -66,7 +64,6 @@ class InvitationService(
acceptedBy = null,
createdByAdmin = createdByAdmin
)
invitation.tenantId = tenantId
invitationRepository.save(invitation)
return InviteCreationResult(token, invitation.expiresAt)
}
@ -106,7 +103,6 @@ class InvitationService(
throw IllegalArgumentException("Invitation email mismatch")
}
val newUser = User(authenticatedUserId, authenticatedEmail, invitation.role, "ACTIVE")
newUser.tenantId = TenantContext.getTenantId() ?: throw IllegalStateException("Missing tenant")
userRepository.save(newUser)
}
@ -144,7 +140,6 @@ class InvitationService(
val tenantId = TenantContext.getTenantId() ?: throw IllegalStateException("Missing tenant")
if (!subjectRepository.existsByTenantIdAndPatientIdAndUserId(tenantId, patientId, userId)) {
val link = PatientSubject(UUID.randomUUID().toString(), patientId, userId)
link.tenantId = tenantId
subjectRepository.save(link)
}
}

View file

@ -79,28 +79,6 @@ class InvitationServiceTest {
assertEquals(Invitation.STATUS_ACCEPTED, invitation.status)
assertNotNull(invitation.acceptedAt)
assertEquals(user, invitation.acceptedBy)
org.mockito.kotlin.verify(subjectRepository).save(org.mockito.kotlin.check {
assertEquals("t1", it.tenantId)
})
}
@Test
fun `creates patient invite with tenantId`() {
val email = "new@example.com"
whenever(patientRepository.save(any<Patient>())).thenAnswer { it.arguments[0] as Patient }
whenever(userRepository.save(any<User>())).thenAnswer { it.arguments[0] as User }
whenever(invitationRepository.save(any<Invitation>())).thenAnswer { it.arguments[0] as Invitation }
val result = service.createPatientInvite(email, "admin-1")
assertNotNull(result.token)
org.mockito.kotlin.verify(patientRepository).save(org.mockito.kotlin.check<Patient> {
assertEquals("t1", it.tenantId)
})
org.mockito.kotlin.verify(invitationRepository).save(org.mockito.kotlin.check<Invitation> {
assertEquals("t1", it.tenantId)
assertEquals(email, it.email)
})
}
@Test