Compare commits

..

10 Commits

Author SHA1 Message Date
4de4f1745f fix ci
All checks were successful
Build and Package OPKG / Build for "armv5-3.2" (push) Successful in 1m1s
Build and Package OPKG / Build for "armv7-2.6" (push) Successful in 1m0s
Build and Package OPKG / Build for "armv7-3.2" (push) Successful in 1m0s
Build and Package OPKG / Build for "armv5-3.2" (release) Successful in 1m21s
Build and Package OPKG / Build for "armv7-2.6" (release) Successful in 1m20s
Build and Package OPKG / Build for "armv7-3.2" (release) Successful in 1m18s
Build and Package OPKG / Build for "aarch64-3.10" (release) Successful in 1m20s
Build and Package OPKG / Build for "mips-3.4" (release) Successful in 1m22s
Build and Package OPKG / Build for "mipsel-3.4" (release) Successful in 1m17s
Build and Package OPKG / Build for "aarch64-3.10" (push) Successful in 59s
Build and Package OPKG / Build for "mipsel-3.4" (push) Successful in 59s
Build and Package OPKG / Build for "mips-3.4" (push) Successful in 58s
2025-02-15 06:25:47 +03:00
87ee5f5f9b Merge pull request 'Исправление CI сборок' (#2) from feature/pr_ci into main
All checks were successful
Build and Package OPKG / Build for aarch64-3.10 (release) Successful in 1m10s
Build and Package OPKG / Build for armv5-3.2 (release) Successful in 1m4s
Build and Package OPKG / Build for armv7-2.6 (release) Successful in 1m10s
Build and Package OPKG / Build for armv7-3.2 (release) Successful in 1m10s
Build and Package OPKG / Build for mips-3.4 (release) Successful in 1m10s
Build and Package OPKG / Build for mipsel-3.4 (release) Successful in 1m4s
2025-02-14 17:35:59 -05:00
e8d53872b0 upload only for releases 2025-02-15 01:35:01 +03:00
c7dac46d67 fix arch name 2025-02-15 01:18:24 +03:00
cc8d3ede3c place version in filename
Some checks failed
Build and Package OPKG / Build for aarch64-3.10 (push) Failing after 50s
Build and Package OPKG / Build for armv5-3.2 (push) Failing after 43s
Build and Package OPKG / Build for armv7-2.6 (push) Failing after 44s
Build and Package OPKG / Build for armv7-3.2 (push) Failing after 41s
Build and Package OPKG / Build for mips-3.4 (push) Failing after 49s
Build and Package OPKG / Build for mipsel-3.4 (push) Failing after 46s
2025-02-15 01:10:28 +03:00
867788dc4c ignore tags
Some checks failed
Build and Package OPKG / Build for armv5-3.2 (push) Has been cancelled
Build and Package OPKG / Build for aarch64-3.10 (push) Has been cancelled
Build and Package OPKG / Build for armv7-2.6 (push) Has been cancelled
Build and Package OPKG / Build for armv7-3.2 (push) Has been cancelled
Build and Package OPKG / Build for mips-3.4 (push) Has been cancelled
Build and Package OPKG / Build for mipsel-3.4 (push) Has been cancelled
2025-02-15 01:05:46 +03:00
1ab11fa899 test release
Some checks failed
Build and Package OPKG / Build for aarch64-3.10 (push) Successful in 51s
Build and Package OPKG / Build for armv7-2.6 (push) Has been cancelled
Build and Package OPKG / Build for armv7-3.2 (push) Has been cancelled
Build and Package OPKG / Build for armv5-3.2 (push) Has been cancelled
Build and Package OPKG / Build for mips-3.4 (push) Has been cancelled
Build and Package OPKG / Build for mipsel-3.4 (push) Has been cancelled
Build and Package OPKG / Build for aarch64-3.10 (release) Successful in 1m17s
Build and Package OPKG / Build for armv7-2.6 (release) Has been cancelled
Build and Package OPKG / Build for armv7-3.2 (release) Has been cancelled
Build and Package OPKG / Build for mips-3.4 (release) Has been cancelled
Build and Package OPKG / Build for mipsel-3.4 (release) Has been cancelled
Build and Package OPKG / Build for armv5-3.2 (release) Has been cancelled
2025-02-15 00:58:29 +03:00
9926cfa0fb downgrading actions/setup-go
All checks were successful
Build and Package OPKG / Build for aarch64-3.10 (push) Successful in 57s
Build and Package OPKG / Build for armv5-3.2 (push) Successful in 49s
Build and Package OPKG / Build for armv7-2.6 (push) Successful in 45s
Build and Package OPKG / Build for armv7-3.2 (push) Successful in 45s
Build and Package OPKG / Build for mips-3.4 (push) Successful in 43s
Build and Package OPKG / Build for mipsel-3.4 (push) Successful in 43s
2025-02-15 00:48:11 +03:00
7833bc3db4 build nightly versions
All checks were successful
Build and Package OPKG / Build for aarch64-3.10 (push) Successful in 55s
Build and Package OPKG / Build for armv5-3.2 (push) Successful in 46s
Build and Package OPKG / Build for armv7-2.6 (push) Successful in 44s
Build and Package OPKG / Build for armv7-3.2 (push) Successful in 46s
Build and Package OPKG / Build for mips-3.4 (push) Successful in 46s
Build and Package OPKG / Build for mipsel-3.4 (push) Successful in 48s
2025-02-15 00:40:06 +03:00
965b4e6718 fix tests 2025-02-15 00:03:02 +03:00
5 changed files with 126 additions and 93 deletions

86
.github/workflows/build-for-release.yml vendored Normal file
View File

@ -0,0 +1,86 @@
name: Build and Package OPKG
on:
push:
branches:
- develop
- main
release:
types: [published]
jobs:
build:
name: Build for "${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: mipsel-3.4
goos: linux
goarch: mipsle
gomips: softfloat
- target: mips-3.4
goos: linux
goarch: mips
gomips: softfloat
- target: aarch64-3.10
goos: linux
goarch: arm64
- target: armv7-3.2
goos: linux
goarch: arm
goarm: 7
- target: armv7-2.6
goos: linux
goarch: arm
goarm: 7
- target: armv5-3.2
goos: linux
goarch: arm
goarm: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y fakeroot
- name: Build and Package
run: |
TARGET=${{ matrix.target }} GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} GOMIPS=${{ matrix.gomips }} GOARM=${{ matrix.goarm }} make
- name: Fetching file list for artifact
if: ${{ github.event_name != 'release' }}
id: create_file_list
run: |
echo 'file_list<<EOF' >> $GITHUB_OUTPUT
find . -name "magitrickle_*_${{ matrix.target }}.ipk" -print >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Upload artifact
if: ${{ github.event_name != 'release' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: ${{ steps.create_file_list.outputs.file_list }}
if-no-files-found: error
- name: Upload asset to release
if: ${{ github.event_name == 'release' }}
uses: https://gitea.com/actions/release-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |-
./.build/magitrickle_*_${{ matrix.target }}.ipk
api_key: '${{secrets.RELEASE_TOKEN}}'

View File

@ -1,66 +0,0 @@
name: Build and Package OPKG
on:
push:
branches:
- main
jobs:
build:
name: Build for ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: mipsel-3.4
goos: linux
goarch: mipsle
gomips: softfloat
- arch: mips-3.4
goos: linux
goarch: mips
gomips: softfloat
- arch: aarch64-3.10
goos: linux
goarch: arm64
- arch: armv7-3.2
goos: linux
goarch: arm
goarm: 7
- arch: armv7-2.6
goos: linux
goarch: arm
goarm: 7
- arch: armv5-3.2
goos: linux
goarch: arm
goarm: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y fakeroot
- name: Build and Package
run: |
ARCH=${{ matrix.arch }} GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} GOMIPS=${{ matrix.gomips }} GOARM=${{ matrix.goarm }} make
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: magitrickle_${{ matrix.arch }}.ipk.zip
path: .build/magitrickle_${{ matrix.arch }}.ipk
if-no-files-found: error
compression-level: 0

View File

@ -2,25 +2,37 @@ APP_NAME = magitrickle
APP_DESCRIPTION = DNS-based routing application APP_DESCRIPTION = DNS-based routing application
APP_MAINTAINER = Vladimir Avtsenov <vladimir.lsk.cool@gmail.com> APP_MAINTAINER = Vladimir Avtsenov <vladimir.lsk.cool@gmail.com>
TAG = $(shell git describe --tags --abbrev=0 2> /dev/null || git rev-parse --short HEAD)
COMMIT = $(shell git rev-parse --short HEAD) COMMIT = $(shell git rev-parse --short HEAD)
COMMITS_SINCE_TAG = $(shell git rev-list ${TAG}..HEAD --count || echo "0") UPSTREAM_VERSION = $(shell git describe --tags --abbrev=0 2> /dev/null || echo "0.0.0")
VERSION ?= $(TAG) PKG_REVISION ?= 1
ARCH ?= mipsel TAG = $(shell git describe --tags --abbrev=0 2> /dev/null)
COMMITS_SINCE_TAG = $(shell git rev-list ${TAG}..HEAD --count 2>/dev/null)
PRERELEASE_POSTFIX =
PRERELEASE_DATE = $(shell date +%Y%m%d)
ifneq ($(TAG),)
ifneq ($(COMMITS_SINCE_TAG), 0)
PRERELEASE_POSTFIX = ~git$(PRERELEASE_DATE).$(COMMIT)
endif
else
PRERELEASE_POSTFIX = ~git$(PRERELEASE_DATE).$(COMMIT)
endif
TARGET ?= mipsel-3.4
GOOS ?= linux GOOS ?= linux
GOARCH ?= mipsle GOARCH ?= mipsle
GOMIPS ?= softfloat GOMIPS ?= softfloat
GOARM ?= GOARM ?=
BUILD_DIR = ./.build BUILD_DIR = ./.build
PKG_DIR = $(BUILD_DIR)/$(ARCH) PKG_DIR = $(BUILD_DIR)/$(TARGET)
BIN_DIR = $(PKG_DIR)/data/opt/bin BIN_DIR = $(PKG_DIR)/data/opt/bin
PARAMS = -v -a -trimpath -ldflags="-X 'magitrickle/constant.Version=$(VERSION)' -X 'magitrickle/constant.Commit=$(COMMIT)' -w -s" PARAMS = -v -a -trimpath -ldflags="-X 'magitrickle/constant.Version=$(UPSTREAM_VERSION)$(PRERELEASE_POSTFIX)' -X 'magitrickle/constant.Commit=$(COMMIT)' -w -s"
all: clear build_daemon package all: clear build_daemon package
clear: clear:
echo $(shell git rev-parse --abbrev-ref HEAD)
rm -rf $(PKG_DIR) rm -rf $(PKG_DIR)
build_daemon: build_daemon:
@ -30,8 +42,8 @@ package:
@mkdir -p $(PKG_DIR)/control @mkdir -p $(PKG_DIR)/control
@echo '2.0' > $(PKG_DIR)/debian-binary @echo '2.0' > $(PKG_DIR)/debian-binary
@echo 'Package: $(APP_NAME)' > $(PKG_DIR)/control/control @echo 'Package: $(APP_NAME)' > $(PKG_DIR)/control/control
@echo 'Version: $(VERSION)-$(COMMITS_SINCE_TAG)' >> $(PKG_DIR)/control/control @echo 'Version: $(UPSTREAM_VERSION)$(PRERELEASE_POSTFIX)-$(PKG_REVISION)' >> $(PKG_DIR)/control/control
@echo 'Architecture: $(ARCH)' >> $(PKG_DIR)/control/control @echo 'Architecture: $(TARGET)' >> $(PKG_DIR)/control/control
@echo 'Maintainer: $(APP_MAINTAINER)' >> $(PKG_DIR)/control/control @echo 'Maintainer: $(APP_MAINTAINER)' >> $(PKG_DIR)/control/control
@echo 'Description: $(APP_DESCRIPTION)' >> $(PKG_DIR)/control/control @echo 'Description: $(APP_DESCRIPTION)' >> $(PKG_DIR)/control/control
@echo 'Section: net' >> $(PKG_DIR)/control/control @echo 'Section: net' >> $(PKG_DIR)/control/control
@ -40,4 +52,4 @@ package:
@cp -r ./opt $(PKG_DIR)/data/ @cp -r ./opt $(PKG_DIR)/data/
@fakeroot sh -c "tar -C $(PKG_DIR)/control -czvf $(PKG_DIR)/control.tar.gz ." @fakeroot sh -c "tar -C $(PKG_DIR)/control -czvf $(PKG_DIR)/control.tar.gz ."
@fakeroot sh -c "tar -C $(PKG_DIR)/data -czvf $(PKG_DIR)/data.tar.gz ." @fakeroot sh -c "tar -C $(PKG_DIR)/data -czvf $(PKG_DIR)/data.tar.gz ."
@tar -C $(PKG_DIR) -czvf $(BUILD_DIR)/$(APP_NAME)_$(ARCH).ipk ./debian-binary ./control.tar.gz ./data.tar.gz @tar -C $(PKG_DIR) -czvf $(BUILD_DIR)/$(APP_NAME)_$(UPSTREAM_VERSION)$(PRERELEASE_POSTFIX)-$(PKG_REVISION)_$(TARGET).ipk ./debian-binary ./control.tar.gz ./data.tar.gz

View File

@ -2,16 +2,16 @@ package models
import "testing" import "testing"
func TestDomain_IsMatch_Plaintext(t *testing.T) { func TestDomain_IsMatch_Domain(t *testing.T) {
rule := &Rule{ rule := &Rule{
Type: "plaintext", Type: "domain",
Rule: "example.com", Rule: "example.com",
} }
if !rule.IsMatch("example.com") { if !rule.IsMatch("example.com") {
t.Fatal("&Rule{Type: \"plaintext\", Rule: \"example.com\"}.IsMatch(\"example.com\") returns false") t.Fatal("&Rule{Type: \"domain\", Rule: \"example.com\"}.IsMatch(\"example.com\") returns false")
} }
if rule.IsMatch("noexample.com") { if rule.IsMatch("noexample.com") {
t.Fatal("&Rule{Type: \"plaintext\", Rule: \"example.com\"}.IsMatch(\"noexample.com\") returns true") t.Fatal("&Rule{Type: \"domain\", Rule: \"example.com\"}.IsMatch(\"noexample.com\") returns true")
} }
} }

View File

@ -9,8 +9,8 @@ import (
func TestLoop(t *testing.T) { func TestLoop(t *testing.T) {
r := New() r := New()
r.AddCNameRecord("1", "2", time.Minute) r.AddCNameRecord("1", "2", 60)
r.AddCNameRecord("2", "1", time.Minute) r.AddCNameRecord("2", "1", 60)
if r.GetARecords("1") != nil { if r.GetARecords("1") != nil {
t.Fatal("loop detected") t.Fatal("loop detected")
} }
@ -21,8 +21,8 @@ func TestLoop(t *testing.T) {
func TestCName(t *testing.T) { func TestCName(t *testing.T) {
r := New() r := New()
r.AddARecord("example.com", []byte{1, 2, 3, 4}, time.Minute) r.AddARecord("example.com", []byte{1, 2, 3, 4}, 60)
r.AddCNameRecord("gateway.example.com", "example.com", time.Minute) r.AddCNameRecord("gateway.example.com", "example.com", 60)
records := r.GetARecords("gateway.example.com") records := r.GetARecords("gateway.example.com")
if records == nil { if records == nil {
t.Fatal("no records") t.Fatal("no records")
@ -34,7 +34,7 @@ func TestCName(t *testing.T) {
func TestA(t *testing.T) { func TestA(t *testing.T) {
r := New() r := New()
r.AddARecord("example.com", []byte{1, 2, 3, 4}, time.Minute) r.AddARecord("example.com", []byte{1, 2, 3, 4}, 60)
records := r.GetARecords("example.com") records := r.GetARecords("example.com")
if records == nil { if records == nil {
t.Fatal("no records") t.Fatal("no records")
@ -46,7 +46,8 @@ func TestA(t *testing.T) {
func TestDeprecated(t *testing.T) { func TestDeprecated(t *testing.T) {
r := New() r := New()
r.AddARecord("example.com", []byte{1, 2, 3, 4}, -time.Minute) r.AddARecord("example.com", []byte{1, 2, 3, 4}, 0)
time.Sleep(time.Second)
records := r.GetARecords("example.com") records := r.GetARecords("example.com")
if records != nil { if records != nil {
t.Fatal("deprecated records") t.Fatal("deprecated records")
@ -63,7 +64,7 @@ func TestNotExistedA(t *testing.T) {
func TestNotExistedCNameAlias(t *testing.T) { func TestNotExistedCNameAlias(t *testing.T) {
r := New() r := New()
r.AddCNameRecord("gateway.example.com", "example.com", time.Minute) r.AddCNameRecord("gateway.example.com", "example.com", 60)
records := r.GetARecords("gateway.example.com") records := r.GetARecords("gateway.example.com")
if records != nil { if records != nil {
t.Fatal("not existed records") t.Fatal("not existed records")
@ -72,8 +73,8 @@ func TestNotExistedCNameAlias(t *testing.T) {
func TestReplacing(t *testing.T) { func TestReplacing(t *testing.T) {
r := New() r := New()
r.AddCNameRecord("gateway.example.com", "example.com", time.Minute) r.AddCNameRecord("gateway.example.com", "example.com", 60)
r.AddARecord("gateway.example.com", []byte{1, 2, 3, 4}, time.Minute) r.AddARecord("gateway.example.com", []byte{1, 2, 3, 4}, 60)
records := r.GetARecords("gateway.example.com") records := r.GetARecords("gateway.example.com")
if bytes.Compare(records[0].Address, []byte{1, 2, 3, 4}) != 0 { if bytes.Compare(records[0].Address, []byte{1, 2, 3, 4}) != 0 {
t.Fatal("mismatch") t.Fatal("mismatch")
@ -82,11 +83,11 @@ func TestReplacing(t *testing.T) {
func TestAliases(t *testing.T) { func TestAliases(t *testing.T) {
r := New() r := New()
r.AddARecord("1", []byte{1, 2, 3, 4}, time.Minute) r.AddARecord("1", []byte{1, 2, 3, 4}, 60)
r.AddCNameRecord("2", "1", time.Minute) r.AddCNameRecord("2", "1", 60)
r.AddCNameRecord("3", "2", time.Minute) r.AddCNameRecord("3", "2", 60)
r.AddCNameRecord("4", "2", time.Minute) r.AddCNameRecord("4", "2", 60)
r.AddCNameRecord("5", "1", time.Minute) r.AddCNameRecord("5", "1", 60)
aliases := r.GetAliases("1") aliases := r.GetAliases("1")
if aliases == nil { if aliases == nil {
t.Fatal("no aliases") t.Fatal("no aliases")