diff --git a/.github/workflows/delete-workflow-runs.yml b/.github/workflows/delete-workflow-runs.yml new file mode 100644 index 00000000..e7582882 --- /dev/null +++ b/.github/workflows/delete-workflow-runs.yml @@ -0,0 +1,37 @@ +name: Delete workflow runs + +on: + schedule: + - cron: '0 0 1 * *' + workflow_dispatch: + +jobs: + del_runs: + name: Delete workflow runs + runs-on: ubuntu-latest + steps: + - name: Delete skipped + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 0 + keep_minimum_runs: 0 + delete_run_by_conclusion_pattern: skipped + + - name: Delete cancelled + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 0 + keep_minimum_runs: 0 + delete_run_by_conclusion_pattern: cancelled + + - name: Delete workflow runs(older than a month) + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 30 + keep_minimum_runs: 6 \ No newline at end of file diff --git a/.github/workflows/development-docker.yml b/.github/workflows/development-docker.yml index 9822e22d..1d4bf7ad 100644 --- a/.github/workflows/development-docker.yml +++ b/.github/workflows/development-docker.yml @@ -35,15 +35,18 @@ jobs: if [[ "${ENABLED,,}" != "true" ]]; then echo "enabled=0" >> $GITHUB_OUTPUT - echo "Workflow is disabled" echo "### Workflow is disabled" >> $GITHUB_STEP_SUMMARY echo "To enable this workflow by creating a secret 'DEVELOPMENT_DOCKER' with the value 'true'" >> $GITHUB_STEP_SUMMARY else - echo "enabled=1" >> $GITHUB_OUTPUT - - echo "Workflow is enabled" + if [[ "${{ github.repository_owner }}" != "0xERR0R" && "${GITHUB_REF#refs/heads/}" == "main" ]]; then + echo "enabled=0" >> $GITHUB_OUTPUT + echo "Workflow is disabled for main branch on forks" + else + echo "enabled=1" >> $GITHUB_OUTPUT + echo "Workflow is enabled" + fi fi docker: diff --git a/.github/workflows/fork-sync.yml b/.github/workflows/fork-sync.yml new file mode 100644 index 00000000..e66f1356 --- /dev/null +++ b/.github/workflows/fork-sync.yml @@ -0,0 +1,36 @@ +name: Sync Fork + +on: + schedule: + - cron: '*/30 * * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }} + +jobs: + sync: + name: Sync with Upstream + runs-on: ubuntu-latest + if: github.repository_owner != '0xERR0R' + steps: + - name: Enabled Check + id: check + shell: bash + run: | + if [[ "${{ secrets.FORK_SYNC_TOKEN }}" != "" ]]; then + echo "enabled=1" >> $GITHUB_OUTPUT + + echo "Workflow is enabled" + else + echo "enabled=0" >> $GITHUB_OUTPUT + + echo "Workflow is disabled(create FORK_SYNC_TOKEN secret with repo write permission to enable it)" + fi + - name: Sync + if: ${{ steps.check.outputs.enabled == 1 }} + env: + GH_TOKEN: ${{ secrets.FORK_SYNC_TOKEN }} + shell: bash + run: | + gh repo sync ${{ github.repository }} -b main diff --git a/cache/stringcache/chained_grouped_cache_test.go b/cache/stringcache/chained_grouped_cache_test.go index 5823f6f2..e83f9560 100644 --- a/cache/stringcache/chained_grouped_cache_test.go +++ b/cache/stringcache/chained_grouped_cache_test.go @@ -89,6 +89,5 @@ var _ = Describe("Chained grouped cache", func() { Expect(cache.Contains("both", []string{"group1", "group2"})).Should(ConsistOf("group2")) }) }) - }) }) diff --git a/cache/stringcache/in_memory_grouped_cache_test.go b/cache/stringcache/in_memory_grouped_cache_test.go index 71bf5ef1..7692935a 100644 --- a/cache/stringcache/in_memory_grouped_cache_test.go +++ b/cache/stringcache/in_memory_grouped_cache_test.go @@ -32,7 +32,6 @@ var _ = Describe("In-Memory grouped cache", func() { Expect(cache.Contains("searchString", []string{"group1"})).Should(BeEmpty()) }) }) - }) Describe("Cache creation", func() { When("cache with 1 group was created", func() { @@ -127,6 +126,5 @@ var _ = Describe("In-Memory grouped cache", func() { Expect(cache.Contains("both", []string{"group1", "group2"})).Should(ConsistOf("group2")) }) }) - }) }) diff --git a/config/blocking_test.go b/config/blocking_test.go index b806b028..59258525 100644 --- a/config/blocking_test.go +++ b/config/blocking_test.go @@ -10,9 +10,7 @@ import ( ) var _ = Describe("BlockingConfig", func() { - var ( - cfg BlockingConfig - ) + var cfg BlockingConfig suiteBeforeEach() diff --git a/config/caching_test.go b/config/caching_test.go index a295d0c9..1b80c7ac 100644 --- a/config/caching_test.go +++ b/config/caching_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("CachingConfig", func() { - var ( - cfg CachingConfig - ) + var cfg CachingConfig suiteBeforeEach() diff --git a/config/client_lookup_test.go b/config/client_lookup_test.go index bdf169b7..a388dd95 100644 --- a/config/client_lookup_test.go +++ b/config/client_lookup_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("ClientLookupConfig", func() { - var ( - cfg ClientLookupConfig - ) + var cfg ClientLookupConfig suiteBeforeEach() diff --git a/config/conditional_upstream_test.go b/config/conditional_upstream_test.go index 7016a14c..9f8d6eb3 100644 --- a/config/conditional_upstream_test.go +++ b/config/conditional_upstream_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("ConditionalUpstreamConfig", func() { - var ( - cfg ConditionalUpstreamConfig - ) + var cfg ConditionalUpstreamConfig suiteBeforeEach() diff --git a/config/custom_dns_test.go b/config/custom_dns_test.go index 0361bf20..a96061cd 100644 --- a/config/custom_dns_test.go +++ b/config/custom_dns_test.go @@ -10,9 +10,7 @@ import ( ) var _ = Describe("CustomDNSConfig", func() { - var ( - cfg CustomDNSConfig - ) + var cfg CustomDNSConfig suiteBeforeEach() diff --git a/config/filtering_test.go b/config/filtering_test.go index 648cd186..4b4ce168 100644 --- a/config/filtering_test.go +++ b/config/filtering_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("FilteringConfig", func() { - var ( - cfg FilteringConfig - ) + var cfg FilteringConfig suiteBeforeEach() diff --git a/config/hosts_file_test.go b/config/hosts_file_test.go index aa112080..5f67feb8 100644 --- a/config/hosts_file_test.go +++ b/config/hosts_file_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("HostsFileConfig", func() { - var ( - cfg HostsFileConfig - ) + var cfg HostsFileConfig suiteBeforeEach() diff --git a/config/metrics_test.go b/config/metrics_test.go index afedbe77..b5f968b2 100644 --- a/config/metrics_test.go +++ b/config/metrics_test.go @@ -7,9 +7,7 @@ import ( ) var _ = Describe("MetricsConfig", func() { - var ( - cfg MetricsConfig - ) + var cfg MetricsConfig suiteBeforeEach() diff --git a/config/parallel_best_test.go b/config/parallel_best_test.go index 1f8f6e95..9acef009 100644 --- a/config/parallel_best_test.go +++ b/config/parallel_best_test.go @@ -7,9 +7,7 @@ import ( ) var _ = Describe("ParallelBestConfig", func() { - var ( - cfg ParallelBestConfig - ) + var cfg ParallelBestConfig suiteBeforeEach() diff --git a/config/query_log_test.go b/config/query_log_test.go index 208f755c..582fa34b 100644 --- a/config/query_log_test.go +++ b/config/query_log_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("QueryLogConfig", func() { - var ( - cfg QueryLogConfig - ) + var cfg QueryLogConfig suiteBeforeEach() diff --git a/config/rewriter_test.go b/config/rewriter_test.go index 5b92083e..a7414d56 100644 --- a/config/rewriter_test.go +++ b/config/rewriter_test.go @@ -7,9 +7,7 @@ import ( ) var _ = Describe("RewriterConfig", func() { - var ( - cfg RewriterConfig - ) + var cfg RewriterConfig suiteBeforeEach() diff --git a/docs/additional_information.md b/docs/additional_information.md index 59e0b329..d54800cd 100644 --- a/docs/additional_information.md +++ b/docs/additional_information.md @@ -108,4 +108,16 @@ Main: [:material-docker:Docker Hub](https://hub.docker.com/r/spx01/blocky) Mirror: [:material-github:GitHub Container Registry](https://ghcr.io/0xerr0r/blocky) +## Developer Information + +### Docker Images + +To enable Docker image creation on a GitHub fork create a secret with the name `DEVELOPMENT_DOCKER` and the value `true`. +This will trigger a workflow on every push of a branch starting with `fb-` and create an image with the branch name. + +### Automatic fork sync + +To enable automatic fork synchronisation create a secret with the name `FORK_SYNC_TOKEN` with an access token that has write permission to the fork repository. +The enabled workflow will sync the main branch every 30 minutes with its upstream. + --8<-- "docs/includes/abbreviations.md" diff --git a/lists/parsers/adapt.go b/lists/parsers/adapt.go index 8f6ce355..6c08fc69 100644 --- a/lists/parsers/adapt.go +++ b/lists/parsers/adapt.go @@ -16,7 +16,7 @@ func TryAdapt[From, To any](inner SeriesParser[From], adapt func(From) (To, erro // TryAdaptMethod returns a parser that wraps `inner` and tries to convert each parsed value // using the given method with pointer receiver of `To`. -func TryAdaptMethod[ToPtr *To, From any, To any]( +func TryAdaptMethod[ToPtr *To, From, To any]( inner SeriesParser[From], method func(ToPtr, From) error, ) SeriesParser[*To] { return TryAdapt(inner, func(from From) (*To, error) { diff --git a/lists/parsers/filtererrors_test.go b/lists/parsers/filtererrors_test.go index 2c3fc7d1..001552e6 100644 --- a/lists/parsers/filtererrors_test.go +++ b/lists/parsers/filtererrors_test.go @@ -11,9 +11,7 @@ import ( var _ = Describe("errorFilter", func() { Describe("AllowErrors", func() { - var ( - parser SeriesParser[struct{}] - ) + var parser SeriesParser[struct{}] BeforeEach(func() { parser = newMockParser(func(res chan<- struct{}, err chan<- error) { diff --git a/lists/parsers/hosts_test.go b/lists/parsers/hosts_test.go index fcbe316d..f9b00f5f 100644 --- a/lists/parsers/hosts_test.go +++ b/lists/parsers/hosts_test.go @@ -86,9 +86,7 @@ var _ = Describe("Hosts", func() { }) Describe("HostsIterator.ForEachHost", func() { - var ( - entry *HostsIterator - ) + var entry *HostsIterator BeforeEach(func() { sutReader = linesReader( @@ -227,9 +225,7 @@ var _ = Describe("HostsFile", func() { }) Describe("HostsFileEntry.forEachHost", func() { - var ( - entry *HostsFileEntry - ) + var entry *HostsFileEntry BeforeEach(func() { sutReader = linesReader( @@ -374,9 +370,7 @@ var _ = Describe("HostList", func() { }) Describe("HostListEntry.forEachHost", func() { - var ( - entry *HostListEntry - ) + var entry *HostListEntry BeforeEach(func() { sutReader = linesReader( diff --git a/lists/parsers/parser_test.go b/lists/parsers/parser_test.go index 45db523b..25565f78 100644 --- a/lists/parsers/parser_test.go +++ b/lists/parsers/parser_test.go @@ -11,9 +11,7 @@ import ( ) var _ = Describe("ForEach", func() { - var ( - lines SeriesParser[string] - ) + var lines SeriesParser[string] BeforeEach(func() { lines = Lines(linesReader( diff --git a/util/arpa.go b/util/arpa.go index ee69b694..f1bc4ab4 100644 --- a/util/arpa.go +++ b/util/arpa.go @@ -15,9 +15,7 @@ const ( byteBits = 8 ) -var ( - ErrInvalidArpaAddrLen = errors.New("arpa hostname is not of expected length") -) +var ErrInvalidArpaAddrLen = errors.New("arpa hostname is not of expected length") func ParseIPFromArpaAddr(arpa string) (net.IP, error) { if strings.HasSuffix(arpa, IPv4PtrSuffix) {