Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/projects/subject-access-r…
Browse files Browse the repository at this point in the history
…equests-and-delius/tech-docs/rexml-3.3.2
  • Loading branch information
marcus-bcl authored Aug 2, 2024
2 parents bbacc41 + 613601e commit 22ec694
Show file tree
Hide file tree
Showing 50 changed files with 1,618 additions and 116 deletions.
39 changes: 18 additions & 21 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "software.amazon.awssdk:*" # reduce the noise of frequent AWS SDK updates
update-types: ["version-update:semver-patch"]
interval: "weekly"
groups:
minor:
update-types:
Expand All @@ -21,7 +18,7 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
groups:
minor:
update-types:
Expand All @@ -33,79 +30,79 @@ updates:
- package-ecosystem: "github-actions"
directory: "/.github/actions/analyse"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/app-insights-to-slack"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/check-changes"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/cloud-platform-auth"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/cloud-platform-deploy"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/create-signed-pull-request"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/docker-build"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/format-code"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/get-build-info"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/get-env-details"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/merge-changes"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/.github/actions/render-project-template"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "terraform"
directory: "/templates"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "docker"
directory: "/projects/person-search-index-from-delius/container"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "docker"
directory: "/projects/redrive-dead-letter-queues/container"
schedule:
interval: "monthly" # to reduce frequency of AWS CLI updates
interval: "weekly"

- package-ecosystem: "docker"
directory: "/projects/feature-flags/container"
schedule:
interval: "daily"
interval: "weekly"
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ jobs:
name: Build
uses: ./.github/workflows/build.yml

post-build:
name: Post-build
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: Check build matrix status
if: ${{ needs.build.result != 'success' }}
run: exit 1

analyse:
name: Analyse
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,6 +56,7 @@ jobs:
VALIDATE_YAML: true
LINTER_RULES_PATH: /
FILTER_REGEX_EXCLUDE: .*templates/.*.ya?ml
BASH_SEVERITY: warning
GITHUB_ACTIONS_CONFIG_FILE: .github/actionlint.yml
GITHUB_ACTIONS_COMMAND_ARGS: -ignore=SC.+:info:.+
GITHUB_TOKEN: ${{ github.token }}
31 changes: 31 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Automated management of Dependabot PRs
name: Dependabot
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ github.token }}"

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ github.token }}

- name: Auto-approve minor or patch versions
run: gh pr review --approve "$PR_URL"
if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ jobs:
name: ${{ matrix.project }}
path: projects/${{ matrix.project }}/tech-docs/build

post-build:
name: Post-build
runs-on: ubuntu-latest
needs:
- build-index
- build-projects
if: always()
steps:
- name: Check build matrix status
if: ${{ needs.build-index.result != 'success' || needs.build-projects.result != 'success' }}
run: exit 1

deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class ApprovedPremisesCategoryCode(
)
),
OTHER("O", CategoryMappings()),
POST_RECALL("S", CategoryMappings(SentenceType.StandardDeterminate to ReleaseType.ReReleasedPostRecall)),
ORA_PSS("U", CategoryMappings(SentenceType.StandardDeterminate to ReleaseType.PostSentenceSupervision)),
RESIDENCY_REQUIREMENT(
"X",
Expand Down Expand Up @@ -88,6 +89,7 @@ enum class ReleaseType(val value: String) {
ResidencyManagement("residencyManagement"),
RiskManagement("riskManagement"),
TemporaryLicence("rotl"),
ReReleasedPostRecall("reReleasedPostRecall"),
NotApplicable("not_applicable");

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ApprovedPremisesCategoryCodeTest {
Arguments.of("communityOrder", "in_community", "residencyManagement", "X"),
Arguments.of("bailPlacement", "in_community", "bailAssessment", "A"),
Arguments.of("bailPlacement", "in_community", "bailSentence", "B"),
Arguments.of("standardDeterminate", "reReleasedPostRecall", null, "S"),
Arguments.of("nonStatutory", "not_applicable", null, "MAP"),
Arguments.of(null, null, null, "O")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DataLoader(
PersonGenerator.ETHNICITY,
PersonGenerator.NATIONALITY,
PersonGenerator.MAIN_ADDRESS,
PersonGenerator.PREVIOUS_ADDRESS,
PersonGenerator.MIN_PERSON,
PersonGenerator.FULL_PERSON,
*PersonGenerator.FULL_PERSON_ALIASES.toTypedArray(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object PersonGenerator {
val GENDER = generateReferenceData("GEN")
val NATIONALITY = generateReferenceData("NAT")
val TITLE = generateReferenceData("TIT")
val PREVIOUS_ADDRESS = generateReferenceData("P", "Previous Address")
val MAIN_ADDRESS = generateReferenceData("M", "Main Address")

val MIN_PERSON =
Expand Down Expand Up @@ -60,10 +61,11 @@ object PersonGenerator {
),
generateAddress(
FULL_PERSON.id,
MAIN_ADDRESS,
PREVIOUS_ADDRESS,
postcode = "NF1 1NF",
noFixedAbode = true,
startDate = LocalDate.now().minusDays(60)
startDate = LocalDate.now().minusDays(60),
endDate = LocalDate.now().minusDays(30)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.*
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken
import java.time.LocalDate

@AutoConfigureMockMvc
@SpringBootTest(webEnvironment = RANDOM_PORT)
Expand Down Expand Up @@ -105,12 +106,23 @@ internal class CorePersonIntegrationTest {
{
"fullAddress": "1 Main Street, London, PC1 1TS",
"postcode": "PC1 1TS",
"noFixedAbode": false
"noFixedAbode": false,
"status": {
"code": "M",
"description": "Main Address"
},
"startDate": "${LocalDate.now().minusDays(30)}"
},
{
"fullAddress": "NF1 1NF",
"postcode": "NF1 1NF",
"noFixedAbode": true
"noFixedAbode": true,
"status": {
"code": "P",
"description": "Previous Address"
},
"startDate": "${LocalDate.now().minusDays(60)}",
"endDate": "${LocalDate.now().minusDays(30)}"
}
],
"excludedFrom": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ data class CodeDescription(val code: String, val description: String)

data class Alias(val name: Name, val dateOfBirth: LocalDate)

data class Address(val fullAddress: String, val postcode: String, val noFixedAbode: Boolean)
data class Address(
val fullAddress: String,
val postcode: String,
val noFixedAbode: Boolean,
val status: CodeDescription,
val startDate: LocalDate,
val endDate: LocalDate?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.time.LocalDate
@Immutable
@Entity
@Table(name = "offender_address")
@SQLRestriction("soft_deleted = 0 and (end_date is null or end_date > current_date)")
@SQLRestriction("soft_deleted = 0")
class PersonAddress(
@Column(name = "offender_id")
val personId: Long,
Expand All @@ -27,7 +27,7 @@ class PersonAddress(
val postcode: String?,
@Convert(converter = YesNoConverter::class)
val noFixedAbode: Boolean,
val startDate: LocalDate?,
val startDate: LocalDate,
val endDate: LocalDate?,
val softDeleted: Boolean,
@Id
Expand All @@ -37,11 +37,7 @@ class PersonAddress(

interface AddressRepository : JpaRepository<PersonAddress, Long> {
@EntityGraph(attributePaths = ["status"])
fun findAllByPersonIdAndStatusCodeInOrderByStartDateDesc(
personId: Long,
statusCodes: List<String>
fun findAllByPersonIdOrderByStartDateDesc(
personId: Long
): List<PersonAddress>
}

fun AddressRepository.mainAddresses(personId: Long) =
findAllByPersonIdAndStatusCodeInOrderByStartDateDesc(personId, listOf("M"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ fun PersonAddress.asAddress() = postcode?.let {
).trimAndJoin(),
postcode = postcode,
noFixedAbode = noFixedAbode,
status = status.asCodeDescription(),
startDate = startDate,
endDate = endDate,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PersonService(

private fun Person.withDetail() = this.detail(
aliases = aliasRepository.findByPersonId(id).map(Alias::asModel),
addresses = addressRepository.mainAddresses(id).mapNotNull(PersonAddress::asAddress),
addresses = addressRepository.findAllByPersonIdOrderByStartDateDesc(id).mapNotNull(PersonAddress::asAddress),
exclusions = exclusionRepository.findByPersonId(id).exclusionsAsLimitedAccess(exclusionMessage),
restrictions = restrictionRepository.findByPersonId(id).restrictionsAsLimitedAccess(restrictionMessage),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,24 @@ object PersonGenerator {
finishDate = end,
)

fun generateDisability(personId: Long, end: LocalDate?) = Disability(
id = IdGenerator.getAndIncrement(),
personId = personId,
type = DISABILITY_TYPE_1,
startDate = LocalDate.now().minusDays(1),
lastUpdated = ZonedDateTime.now().minusDays(1),
condition = DISABILITY_CONDITION_1,
notes = null,
finishDate = end,
)
fun generateDisability(personId: Long, end: LocalDate?, condition: ReferenceData? = DISABILITY_CONDITION_1) =
Disability(
id = IdGenerator.getAndIncrement(),
personId = personId,
type = DISABILITY_TYPE_1,
startDate = LocalDate.now().minusDays(1),
lastUpdated = ZonedDateTime.now().minusDays(1),
condition = condition,
notes = null,
finishDate = end,
)

fun generateAddress(personId: Long, softDeleted: Boolean, type: ReferenceData? = DEFAULT_ADDRESS_TYPE) =
fun generateAddress(
personId: Long,
softDeleted: Boolean,
type: ReferenceData? = DEFAULT_ADDRESS_TYPE,
typeVerified: Boolean? = true
) =
PersonAddress(
id = IdGenerator.getAndIncrement(),
personId = personId,
Expand All @@ -197,7 +203,7 @@ object PersonGenerator {
district = "A District",
addressNumber = "20",
noFixedAbode = false,
typeVerified = true,
typeVerified = typeVerified,
startDate = LocalDate.now().minusDays(1),
endDate = null,
softDeleted = softDeleted,
Expand Down
Loading

0 comments on commit 22ec694

Please sign in to comment.