Skip to content

Commit

Permalink
Update build with passthrough of knotdns mounted container and tmpdir…
Browse files Browse the repository at this point in the history
… perms fixup
  • Loading branch information
Tristan971 committed Jan 9, 2025
1 parent d3d54d6 commit 14b5327
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/build-hotspot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ env:
jobs:
build-test:
runs-on: "ubuntu-latest"
services:
knotdns:
image: "cznic/knot:3.4"
ports:
- "5353:5353"
volumes:
- "${{ github.workspace }}/srv/test/resources/knotdns:/var/lib/knotd"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
Expand All @@ -27,23 +34,6 @@ jobs:
with:
distribution: "${{ inputs.JDK_VENDOR }}"
java-version: "${{ inputs.JDK_VERSION }}"
- name: "Set up QEMU"
uses: "docker/setup-qemu-action@v3"
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Log in to the Container registry"
uses: "docker/login-action@v3"
with:
registry: "${{ env.REGISTRY }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Cache Docker layers"
uses: "actions/cache@v4"
with:
path: "${{ env.DOCKER_LAYER_CACHE }}"
key: "${{ runner.os }}-hotspot-docker-${{ inputs.JDK_VENDOR }}-${{ inputs.JDK_VERSION }}-${{ github.sha }}"
restore-keys: |
${{ runner.os }}-hotspot-docker-${{ inputs.JDK_VENDOR }}-${{ inputs.JDK_VERSION }}-
- name: "Cache local Maven repository"
uses: "actions/cache@v4"
with:
Expand All @@ -55,10 +45,35 @@ jobs:
run: |
set -euo pipefail
export VERSION="git-$(date +'%Y%m%d%H%M')-$(git rev-parse --short HEAD)"
export KNOTDNS_CI="localhost:5353"
export JAVAIOTMPDIR="$(pwd)/.github/tmpdir"
chmod -v -R 0777 "$JAVAIOTMPDIR"
mvn -B -e -fae --show-version -T$(nproc)C -Drevision="$VERSION" -DsurefireTmpDir="$(pwd)/.github/tmpdir" verify package
awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv
- name: "Archive jarfile"
uses: "actions/upload-artifact@v4"
with:
name: "mcw.jar"
path: "target/mcw.jar"


# - name: "Set up QEMU"
# uses: "docker/setup-qemu-action@v3"
# - name: "Set up Docker Buildx"
# uses: "docker/setup-buildx-action@v3"
# - name: "Log in to the Container registry"
# uses: "docker/login-action@v3"
# with:
# registry: "${{ env.REGISTRY }}"
# username: "${{ github.actor }}"
# password: "${{ secrets.GITHUB_TOKEN }}"
# - name: "Cache Docker layers"
# uses: "actions/cache@v4"
# with:
# path: "${{ env.DOCKER_LAYER_CACHE }}"
# key: "${{ runner.os }}-hotspot-docker-${{ inputs.JDK_VENDOR }}-${{ inputs.JDK_VERSION }}-${{ github.sha }}"
# restore-keys: |
# ${{ runner.os }}-hotspot-docker-${{ inputs.JDK_VENDOR }}-${{ inputs.JDK_VERSION }}-
19 changes: 12 additions & 7 deletions src/test/java/org/mangadex/mcw/dns/KnotSidecar.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.mangadex.mcw.dns;

import static java.lang.System.getenv;

import java.io.File;
import java.nio.file.Paths;
import java.util.List;
Expand All @@ -11,9 +13,6 @@
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
import org.testcontainers.junit.jupiter.Container;

import org.mangadex.mcw.dns.DnsProperties.DnsDiscovery;
import org.mangadex.mcw.dns.DnsProperties.DnsOptions;

@TestConfiguration(proxyBeanMethods = false)
public class KnotSidecar {

Expand All @@ -28,12 +27,18 @@ public class KnotSidecar {

@DynamicPropertySource
static void testNameservers(DynamicPropertyRegistry registry) {
if (getenv("KNOTDNS_CI") != null) {
registry.add("org.mangadex.mcw.dns.nameservers", () -> List.of(getenv("KNOTDNS_CI")));
} else {
var knotdns = startContainerAndGetHostname() + ":" + KNOTDNS_PORT_DNS;
registry.add("org.mangadex.mcw.dns.nameservers", () -> List.of(knotdns));
}
}

private static String startContainerAndGetHostname() {
knotdns.start();
knotdns.waitingFor("knotdns", new HostPortWaitStrategy());
var host = knotdns.getServiceHost("knotdns", KNOTDNS_PORT_DNS);
registry.add("org.mangadex.mcw.dns.discovery", () -> DnsDiscovery.STATIC);
registry.add("org.mangadex.mcw.dns.nameservers", () -> List.of("%s:%d".formatted(host, KNOTDNS_PORT_DNS)));
registry.add("org.mangadex.mcw.dns.options", () -> List.of(DnsOptions.FORCE_TCP));
return knotdns.getServiceHost("knotdns", KNOTDNS_PORT_DNS);
}

}

0 comments on commit 14b5327

Please sign in to comment.