Skip to content

Prevented that github data is injecting when executing maven command #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions InsightsBackend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<spotless.version>2.44.2</spotless.version>
<junit.version>5.11.4</junit.version>
<mockito.version>5.15.2</mockito.version>

<gitHubFetchEnabled>true</gitHubFetchEnabled>
</properties>

<dependencies>
Expand Down Expand Up @@ -137,6 +139,15 @@
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<githubFetchEnabled>false</githubFetchEnabled>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void run(String... args) {
initializeSystemData();
}

@Scheduled(cron = "0 0 0 * * *")
@Scheduled(cron = "0 0 0 * * *")
@SchedulerLock(name = "dailyGitHubUpdate", lockAtMostFor = "PT2H", lockAtLeastFor = "PT30M")
public void dailyJob() {
log.info("Daily fetch job started");
Expand All @@ -65,6 +65,12 @@ public void dailyJob() {
@SchedulerLock(name = "fetchGitHubStatistics", lockAtMostFor = "PT10M")
public void fetchGitHubStatistics() {
try {
String gitHubFetchEnabledProperty = System.getProperty("githubFetchEnabled", "true");
if (!Boolean.parseBoolean(gitHubFetchEnabledProperty)) {
log.info("Skipping GitHub fetch: skipping due to build/test configuration.");
return;
}

gitHubRepositoryStatisticsService.fetchRepositoryStatistics();
} catch (GitHubClientException e) {
log.error("Error fetching GitHub statistics", e);
Expand All @@ -74,6 +80,12 @@ public void fetchGitHubStatistics() {
@SchedulerLock(name = "initializeSystemData", lockAtMostFor = "PT2H")
public void initializeSystemData() {
try {
String gitHubFetchEnabledProperty = System.getProperty("githubFetchEnabled", "true");

Choose a reason for hiding this comment

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

Ik denk dat dit ook wel via application.properties kan en dan icm een apart profile draaien in surefire?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heb het aangepast!
Hoop dat het zo goed is :)

if (!Boolean.parseBoolean(gitHubFetchEnabledProperty)) {
log.info("Skipping GitHub fetch: skipping due to build/test configuration.");
return;
}

log.info("Start fetching all GitHub data");
labelService.injectLabels();
milestoneService.injectMilestones();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@SpringBootTest
class InsightsApplicationTests {

@Test
void contextLoads() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void should_CreateLockProvider_when_BeanIsInitialized() {

@Test
public void should_LockStartupTask_when_Executed() {
systemDataInitializer.startupTask();
systemDataInitializer.run();
LockAssert.assertLocked();
}

Expand All @@ -90,7 +90,7 @@ public void should_NotAllowStartupTaskToInterrupt_when_DailyJobIsRunning() throw

Future<?> startupFuture = executorService.submit(() -> {
latch.countDown();
systemDataInitializer.startupTask();
systemDataInitializer.run();
});

Future<?> dailyJobFuture = executorService.submit(() -> {
Expand Down Expand Up @@ -131,7 +131,7 @@ public void should_NotAllowDailyJobToInterrupt_when_StartupTaskIsRunning() throw

Future<?> startupFuture = executorService.submit(() -> {
latch.countDown();
systemDataInitializer.startupTask();
systemDataInitializer.run();
});

dailyJobFuture.get();
Expand Down