Skip to content

Commit 5c78ae5

Browse files
authored
Enforce gradle check in workflow (#948)
1 parent 4d0a7b1 commit 5c78ae5

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

.github/workflows/workflow.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Validate Gradle wrapper
2626
uses: gradle/actions/wrapper-validation@v4
2727

28+
- name: Check
29+
run: ./gradlew check
30+
2831
- name: Set up Docker Buildx
2932
uses: docker/setup-buildx-action@v3
3033

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
.DS_Store
55
uploads/
66
.run
7+
build
78

89
.pnpm-store

app/src/main/java/it/chalmers/gamma/adapter/primary/web/ThymeleafAdvice.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import jakarta.servlet.http.HttpServletRequest;
77
import jakarta.servlet.http.HttpServletResponse;
88
import java.io.IOException;
9-
109
import org.slf4j.Logger;
1110
import org.slf4j.LoggerFactory;
1211
import org.springframework.http.HttpStatus;
@@ -33,9 +32,12 @@ public boolean isAdmin() {
3332
}
3433
}
3534

36-
@ExceptionHandler(IllegalArgumentException.class)
37-
public ModelAndView handleIllegalArgumentException(HttpServletRequest request, IllegalArgumentException ex) {
38-
LOGGER.error("Caught IllegalArgumentException. This shouldn't happen as validators should catch these issues:", ex);
35+
@ExceptionHandler(IllegalArgumentException.class)
36+
public ModelAndView handleIllegalArgumentException(
37+
HttpServletRequest request, IllegalArgumentException ex) {
38+
LOGGER.error(
39+
"Caught IllegalArgumentException. This shouldn't happen as validators should catch these issues:",
40+
ex);
3941
return new ModelAndView("redirect:/error");
4042
}
4143

app/src/main/java/it/chalmers/gamma/adapter/secondary/jpa/apikey/settings/ApiKeySettingsRepositoryAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ public void setAccountScaffoldSettings(
138138

139139
for (var row : settings.superGroupTypes()) {
140140
var pk = new AccountScaffoldRequiresManagedPK(apiKeySettingsEntity.id, row.type().value());
141-
var superGroupTypeRequiresManagedOptional = accountScaffoldRequiresManagedJpaRepository.findById(pk);
141+
var superGroupTypeRequiresManagedOptional =
142+
accountScaffoldRequiresManagedJpaRepository.findById(pk);
142143
if (row.requiresManaged() && superGroupTypeRequiresManagedOptional.isEmpty()) {
143144
accountScaffoldRequiresManagedJpaRepository.save(
144145
new AccountScaffoldRequiresManagedEntity(apiKeySettingsEntity.id, row.type().value()));

app/src/main/java/it/chalmers/gamma/app/accountscaffold/AccountScaffoldFacade.java

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public AccountScaffoldFacade(
4141

4242
/**
4343
* Get all super groups that have the provided types and their "sub" groups with their members.
44-
* For groups that require managed accounts, only users that have participated in gdpr training are included.
44+
* For groups that require managed accounts, only users that have participated in gdpr training
45+
* are included.
4546
*/
4647
public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
4748
this.accessGuard.require(isApi(ApiKeyType.ACCOUNT_SCAFFOLD));
@@ -63,9 +64,10 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
6364
group -> {
6465
List<AccountScaffoldUserPostDTO> activeGroupMember =
6566
group.groupMembers().stream()
66-
.filter(groupMember ->
67-
gdprTrained.contains(groupMember.user().id()) ||
68-
!isGroupWithManagedAccounts(group, settings))
67+
.filter(
68+
groupMember ->
69+
gdprTrained.contains(groupMember.user().id())
70+
|| !isGroupWithManagedAccounts(group, settings))
6971
.map(AccountScaffoldUserPostDTO::new)
7072
.toList();
7173

@@ -74,9 +76,15 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
7476
superGroupMap.put(
7577
superGroupId,
7678
new SuperGroupWithGroups(
77-
group.superGroup(), new ArrayList<>(List.of(new GroupWithMembers(group, new HashSet<>(activeGroupMember))))));
79+
group.superGroup(),
80+
new ArrayList<>(
81+
List.of(
82+
new GroupWithMembers(group, new HashSet<>(activeGroupMember))))));
7883
} else {
79-
superGroupMap.get(superGroupId).groups.add(new GroupWithMembers(group, new HashSet<>(activeGroupMember)));
84+
superGroupMap
85+
.get(superGroupId)
86+
.groups
87+
.add(new GroupWithMembers(group, new HashSet<>(activeGroupMember)));
8088
}
8189
});
8290

@@ -85,7 +93,12 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
8593
superGroupWithGroups ->
8694
new AccountScaffoldSuperGroupDTO(
8795
superGroupWithGroups.superGroup,
88-
superGroupWithGroups.groups.stream().map(group -> new AccountScaffoldGroupDTO(group.group, new ArrayList<>(group.members))).toList(),
96+
superGroupWithGroups.groups.stream()
97+
.map(
98+
group ->
99+
new AccountScaffoldGroupDTO(
100+
group.group, new ArrayList<>(group.members)))
101+
.toList(),
89102
settings.superGroupTypes().stream()
90103
.anyMatch(
91104
row ->
@@ -96,8 +109,8 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
96109

97110
/**
98111
* Returns the users that are active right now. Takes in a list of super group types to help
99-
* determine what kinds of groups that are deemed active. User must have
100-
* participated in gdpr training.
112+
* determine what kinds of groups that are deemed active. User must have participated in gdpr
113+
* training.
101114
*/
102115
public List<AccountScaffoldUserDTO> getActiveUsers() {
103116
this.accessGuard.require(isApi(ApiKeyType.ACCOUNT_SCAFFOLD));
@@ -152,19 +165,9 @@ public AccountScaffoldUserDTO(GammaUser user) {
152165
}
153166

154167
public record AccountScaffoldGroupDTO(
155-
String name,
156-
String prettyName,
157-
List<AccountScaffoldUserPostDTO> members
158-
) {
159-
public AccountScaffoldGroupDTO(
160-
Group group,
161-
List<AccountScaffoldUserPostDTO> members
162-
) {
163-
this(
164-
group.name().value(),
165-
group.prettyName().value(),
166-
members
167-
);
168+
String name, String prettyName, List<AccountScaffoldUserPostDTO> members) {
169+
public AccountScaffoldGroupDTO(Group group, List<AccountScaffoldUserPostDTO> members) {
170+
this(group.name().value(), group.prettyName().value(), members);
168171
}
169172
}
170173

@@ -175,9 +178,7 @@ public record AccountScaffoldSuperGroupDTO(
175178
List<AccountScaffoldGroupDTO> groups,
176179
boolean useManagedAccount) {
177180
public AccountScaffoldSuperGroupDTO(
178-
SuperGroup superGroup,
179-
List<AccountScaffoldGroupDTO> groups,
180-
boolean useManagedAccount) {
181+
SuperGroup superGroup, List<AccountScaffoldGroupDTO> groups, boolean useManagedAccount) {
181182
this(
182183
superGroup.name().value(),
183184
superGroup.prettyName().value(),
@@ -187,7 +188,6 @@ public AccountScaffoldSuperGroupDTO(
187188
}
188189
}
189190

190-
191191
private static class GroupWithMembers {
192192
private final Group group;
193193
private final Set<AccountScaffoldUserPostDTO> members;
@@ -210,11 +210,6 @@ private SuperGroupWithGroups(SuperGroup superGroup, List<GroupWithMembers> group
210210

211211
private boolean isGroupWithManagedAccounts(Group group, ApiKeyAccountScaffoldSettings settings) {
212212
return settings.superGroupTypes().stream()
213-
.anyMatch(
214-
row ->
215-
row.type().equals(group.superGroup().type())
216-
&& row.requiresManaged());
213+
.anyMatch(row -> row.type().equals(group.superGroup().type()) && row.requiresManaged());
217214
}
218-
219-
220215
}

app/src/main/java/it/chalmers/gamma/app/authentication/UserAccessGuard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private boolean haveAcceptedClient(UserId userId) {
133133
}
134134

135135
if (SecurityContextHolder.getContext().getAuthentication()
136-
instanceof OAuth2ClientAuthenticationToken token) {
136+
instanceof OAuth2ClientAuthenticationToken token) {
137137
var client = token.getRegisteredClient();
138138

139139
if (client == null) {

app/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spring:
2222
open-in-view: false
2323
servlet:
2424
multipart:
25-
max-file-size: 50MB
25+
max-file-size: "50MB"
2626
data:
2727
redis:
2828
host: "${REDIS_HOST:redis}"

0 commit comments

Comments
 (0)