Compare commits

...

12 Commits

Author SHA1 Message Date
f36d807731 ISSUE-44: Hithomelabs/HomeLabDocker#44 making tests more verbose
All checks were successful
sample gradle build and test / tag (push) Successful in 6s
sample gradle build and test / build_tag_push (push) Successful in 2m4s
sample gradle build and test / Sync All Forks (push) Successful in 11s
Promote image with tag test to prod / tag (push) Successful in 7s
Promote image with tag test to prod / build_tag_push (push) Successful in 14s
Daily cloudflare API integration test / cloudflare-api-test (push) Successful in 1m33s
2025-11-14 20:03:35 +00:00
8b22064040 ISSUE-44: Hithomelabs/HomeLabDocker#44 Executing integration test every 6 hours 2025-11-14 20:03:35 +00:00
f7e4b3fd93 Merge pull request 'ISSUE-44: Adding integration tests and setting up workflow' (#88) from hitanshu/CFTunnels:ISSUE-44 into test
All checks were successful
sample gradle build and test / tag (push) Successful in 7s
sample gradle build and test / build_tag_push (push) Successful in 2m54s
sample gradle build and test / Sync All Forks (push) Successful in 12s
Daily cloudflare API integration test / cloudflare-api-test (push) Successful in 1m27s
Reviewed-on: #88
2025-11-14 19:48:28 +00:00
e87fb6d153 ISSUE-44: Hithomelabs/HomeLabDocker#44 Excluding integration tests from gradle build and runs them separately in integration tests
All checks were successful
sample gradle build and test / build (pull_request) Successful in 2m11s
2025-11-15 01:14:11 +05:30
b8bf2e8c67 ISSUE-44: Hithomelabs/HomeLabDocker#44 Fixes bug reaated to integration test running during gradle build 2025-11-14 23:38:32 +05:30
b2d58d6a61 ISSUE-44: Hithomelabs/HomeLabDocker#44 Reducing logging verbiage, excuding integration test from test profile
Some checks failed
sample gradle build and test / build (pull_request) Failing after 2m6s
2025-11-14 23:24:42 +05:30
8039945f2a ISSUE-44: Hithomelabs/HomeLabDocker#44 Minor bug fix
Some checks failed
sample gradle build and test / build (pull_request) Failing after 2m29s
2025-11-14 23:11:57 +05:30
ffb33a49e4 ISSUE-44: Hithomelabs/HomeLabDocker#44 Setting up workflow to run integration tests 2025-11-14 23:10:36 +05:30
4875392271 ISSUE-44: Hithomelabs/HomeLabDocker#44 Adding an integration test 2025-11-14 23:07:10 +05:30
46e8f614a0 [Added a script for auto syncing forks of parent repository] Beta #3
All checks were successful
sample gradle build and test / build (pull_request) Successful in 2m17s
sample gradle build and test / build_tag_push (push) Successful in 2m22s
sample gradle build and test / tag (push) Successful in 7s
sample gradle build and test / Sync All Forks (push) Successful in 8s
2025-10-28 01:12:58 +05:30
ef7b6545db [Added a script for auto syncing forks of parent repository] Beta #2
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m45s
sample gradle build and test / tag (push) Successful in 6s
sample gradle build and test / build_tag_push (push) Successful in 2m21s
sample gradle build and test / Sync All Forks (push) Successful in 8s
2025-10-28 00:46:32 +05:30
665361a4e3 [Added a script for auto syncing forks of parent repository] Beta #1
All checks were successful
sample gradle build and test / build (pull_request) Successful in 2m10s
2025-10-28 00:05:47 +05:30
8 changed files with 136 additions and 16 deletions

View File

@ -0,0 +1,24 @@
name: Daily cloudflare API integration test
on:
schedule:
- cron: '0 */6 * * *' # Every hour
workflow_dispatch:
jobs:
cloudflare-api-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: JDK setup
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Run integration tests with Cloudflare API
env:
SPRING_PROFILES_ACTIVE: integration
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_EMAIL: hitanshu98@gmail.com
run: ./gradlew integrationTestOnly

View File

@ -13,17 +13,19 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get new version - name: Get new version
id: new_version id: new_version
run: | run: |
VERSION=$(git describe --tags --abbrev=0) VERSION=$(git describe --tags --abbrev=0)
echo ${VERSION} echo "Current version: ${VERSION}"
MAJOR=$(echo ${VERSION} | cut -d "." -f 1) MAJOR=$(echo ${VERSION} | cut -d "." -f 1)
MINOR=$(echo ${VERSION} | cut -d "." -f 2) MINOR=$(echo ${VERSION} | cut -d "." -f 2)
PATCH=$(echo ${VERSION} | cut -d "." -f 3) PATCH=$(echo ${VERSION} | cut -d "." -f 3)
NEW_PATCH=$(( ${PATCH} + 1)) NEW_PATCH=$((PATCH + 1))
echo ${NEW_PATCH} NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "new_version=$(echo "${MAJOR}.${MINOR}.${NEW_PATCH}")" >> $GITHUB_OUTPUT echo "New version: ${NEW_VERSION}"
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
build_tag_push: build_tag_push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: tag needs: tag
@ -43,11 +45,11 @@ jobs:
uses: gradle/actions/wrapper-validation@v3 uses: gradle/actions/wrapper-validation@v3
- name: Create and push tag - name: Create and push tag
run: | run: |
echo "NEW_VERSION=${{ needs.tag.outputs.new_version }}" echo "New version: ${{ needs.tag.outputs.new_version }}"
git config --global user.name "${{ gitea.actor }}" git config --global user.name "${{ gitea.actor }}"
git config --global user.email "${{ gitea.actor }}@users.noreply.github.com" git config --global user.email "${{ gitea.actor }}@users.noreply.github.com"
git tag -a ${{ needs.tag.outputs.new_version }} -m "Pushing new version ${{ needs.tag.outputs.new_version }}" git tag -a "${{ needs.tag.outputs.new_version }}" -m "Pushing new version ${{ needs.tag.outputs.new_version }}"
git push origin ${{ needs.tag.outputs.new_version }} git push origin "${{ needs.tag.outputs.new_version }}"
- name: Log in to Gitea Docker Registry - name: Log in to Gitea Docker Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
@ -62,3 +64,23 @@ jobs:
run: | run: |
docker push 192.168.0.100:8928/hithomelabs/cftunnels:test docker push 192.168.0.100:8928/hithomelabs/cftunnels:test
docker push 192.168.0.100:8928/hithomelabs/cftunnels:${{ needs.tag.outputs.new_version }} docker push 192.168.0.100:8928/hithomelabs/cftunnels:${{ needs.tag.outputs.new_version }}
sync_forks:
name: Sync All Forks
runs-on: ubuntu-latest
needs: build_tag_push
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Sync all forks via Gitea API
run: |
echo "Fetching forks for Hithomelabs/CFTunnels..."
response=$(curl -s -X GET "https://gitea.hithomelabs.com/api/v1/repos/Hithomelabs/CFTunnels/forks" -H "Authorization: token ${{secrets.TOKEN}}")
filtered=$(echo "$response" | grep -o '"clone_url":"[^"]*"' | sed 's/"clone_url":"\([^"]*\)"/\1/' | grep -v "/Hithomelabs")
echo "Detected forks:"
echo "$filtered"
readarray -t forks <<< "$filtered"
for fork_url in "${forks[@]}"; do
echo "🔄 Syncing fork: $fork_url"
authed_url=$(echo "$fork_url" | sed "s#https://#https://${{secrets.TOKEN}}@#")
git push "$authed_url" test &
done

View File

@ -15,6 +15,27 @@ java {
test { test {
systemProperty 'spring.profiles.active', 'test' systemProperty 'spring.profiles.active', 'test'
useJUnitPlatform {
excludeTags 'integration'
}
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full" // shows full stack trace
showStandardStreams = true // shows println/log output
}
}
tasks.register('integrationTestOnly', Test) {
useJUnitPlatform {
includeTags 'integration'
}
description = 'Runs only integration tests tagged with @Tag("integration")'
group = 'verification'
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams = true
}
} }
repositories { repositories {

View File

@ -1 +0,0 @@
rootProject.name = 'CFTunnels'

View File

@ -5,10 +5,12 @@ import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import java.util.ArrayList; import java.util.ArrayList;
@Configuration @Configuration
@Profile("!integration")
public class OpenApiConfig { public class OpenApiConfig {
@Value("${api.baseUrl}") @Value("${api.baseUrl}")

View File

@ -0,0 +1,3 @@
cloudflare.accountId=${CLOUDFLARE_ACCOUNT_ID}
cloudflare.apiKey=${CLOUDFLARE_API_KEY}
cloudflare.email=${CLOUDFLARE_EMAIL}

View File

@ -4,12 +4,6 @@ cloudflare.apiKey=${CLOUDFLARE_API_KEY}
cloudflare.email=${CLOUDFLARE_EMAIL} cloudflare.email=${CLOUDFLARE_EMAIL}
spring.profiles.active=${ENV} spring.profiles.active=${ENV}
# set root level
logging.level.root=INFO
# package-specific
logging.level.org.springframework=TRACE
logging.level.com.myapp=INFO
/ * * Masking sure app works behind a reverse proxy / * * Masking sure app works behind a reverse proxy
server.forward-headers-strategy=framework server.forward-headers-strategy=framework

View File

@ -0,0 +1,55 @@
package com.hithomelabs.CFTunnels.Integration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hithomelabs.CFTunnels.Config.CloudflareConfig;
import com.hithomelabs.CFTunnels.Headers.AuthKeyEmailHeader;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("integration")
@Tag("integration")
public class CoudflareApiIntegrationTest {
@Autowired
TestRestTemplate restTemplate;
@Autowired
AuthKeyEmailHeader authKeyEmailHeader;
@Autowired
CloudflareConfig cloudflareConfig;
private static ObjectMapper mapper = new ObjectMapper();
@Test
@DisplayName("Calls cloudflare cfd tunnels API and checks that dev tunnel should be a part of the response")
public void getTunnelsTest(){
// * * Resource URL to hit get request at
String url = "https://api.cloudflare.com/client/v4/accounts/" + cloudflareConfig.getAccountId() + "/cfd_tunnel";
HttpEntity<String> httpEntity = new HttpEntity<>("", authKeyEmailHeader.getHttpHeaders());
ResponseEntity<Map> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, Map.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
List<Map<String, Object>> tunnelList = (List<Map<String, Object>>) response.getBody().get("result");
boolean hasName = tunnelList.stream()
.anyMatch(tunnel -> "devtunnel".equals(tunnel.get("name")));
assertTrue(hasName);
}
}