diff --git a/.gitea/workflows/benchmark.yml b/.gitea/workflows/benchmark.yml new file mode 100644 index 0000000..9ece2e4 --- /dev/null +++ b/.gitea/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Go Benchmarks + +on: + push: + branches: [ "main", "master" ] + pull_request: + branches: [ "main", "master" ] + +jobs: + benchmark: + name: Run Benchmarks + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: https://git.quad4.io/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Set up Go + uses: https://git.quad4.io/actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 + with: + go-version: '1.25' + + - name: Setup Task + uses: https://git.quad4.io/actions/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 + with: + version: '3.46.3' + + - name: Run Benchmarks + run: task bench + diff --git a/.gitea/workflows/build-test.yml b/.gitea/workflows/build-test.yml new file mode 100644 index 0000000..b10d97b --- /dev/null +++ b/.gitea/workflows/build-test.yml @@ -0,0 +1,55 @@ +name: Go Build Test + +on: + pull_request: + branches: + - main + - master + +permissions: + contents: read + +jobs: + build: + name: Build (${{ matrix.goos }}, ${{ matrix.goarch }}) + strategy: + fail-fast: false + matrix: + goos: [linux, windows, darwin, freebsd] + goarch: [amd64, arm64, arm] + include: + - goos: js + goarch: wasm + exclude: + - goos: darwin + goarch: arm + + runs-on: ubuntu-latest + + steps: + - name: Checkout Source + uses: https://git.quad4.io/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Set up Go + uses: https://git.quad4.io/actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 + with: + go-version: '1.25' + + - name: Setup Task + uses: https://git.quad4.io/actions/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 + with: + version: '3.46.3' + + - name: Build + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + GOARM: ${{ matrix.goarch == 'arm' && '6' || '' }} + CGO_ENABLED: '0' + run: | + if [ "${{ matrix.goos }}" = "js" ] && [ "${{ matrix.goarch }}" = "wasm" ]; then + task build-wasm + else + task build + fi + diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml deleted file mode 100644 index 4c5ff23..0000000 --- a/.gitea/workflows/build.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: Go Build Multi-Platform - -on: - push: - branches: [ "main", "master" ] - tags: - - 'v*' - pull_request: - branches: [ "main", "master" ] - -jobs: - build: - permissions: - contents: write - strategy: - matrix: - goos: [linux, windows, darwin, freebsd] - goarch: [amd64, arm64, arm] - include: - - goos: js - goarch: wasm - exclude: - - goos: darwin - goarch: arm - - runs-on: ubuntu-latest - - outputs: - build_complete: ${{ steps.build_step.outcome == 'success' }} - - steps: - - name: Checkout code - uses: https://git.quad4.io/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - - name: Set up Go - uses: https://git.quad4.io/actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 - with: - go-version: '1.25' - - - name: Setup Task - uses: https://git.quad4.io/actions/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1 - with: - version: '3.46.3' - - - name: Build - id: build_step - env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - GOARM: ${{ matrix.goarch == 'arm' && '6' || '' }} - CGO_ENABLED: '0' - run: | - output_name="reticulum-go-${GOOS}-${GOARCH}" - if [ "$GOOS" = "js" ] && [ "$GOARCH" = "wasm" ]; then - task build-wasm - output_name+=".wasm" - mv bin/reticulum-go.wasm "${output_name}" - else - task build - if [ "$GOOS" = "windows" ]; then - output_name+=".exe" - fi - mv bin/reticulum-go "${output_name}" - fi - echo "Built: ${output_name}" - - - name: Calculate SHA256 Checksum - run: | - output_name="reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }}" - if [ "${{ matrix.goos }}" = "windows" ]; then - output_name+=".exe" - elif [ "${{ matrix.goos }}" = "js" ] && [ "${{ matrix.goarch }}" = "wasm" ]; then - output_name+=".wasm" - fi - BINARY_PATH="${output_name}" task checksum - - - name: Upload Artifact - uses: https://git.quad4.io/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1 - with: - name: reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }} - path: | - reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }}* - - release: - name: Create Release - runs-on: ubuntu-latest - needs: build - if: startsWith(github.ref, 'refs/tags/') - - permissions: - contents: write - - steps: - - name: Download All Build Artifacts - uses: https://git.quad4.io/actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a - with: - path: ./release-assets - - - name: List downloaded files (for debugging) - run: ls -R ./release-assets - - - name: Create Gitea Release - uses: https://git.quad4.io/actions/gitea-release-action@4875285c0950474efb7ca2df55233c51333eeb74 - with: - files: ./release-assets/*/* diff --git a/.gitea/workflows/go-test.yml b/.gitea/workflows/go-test.yml index 51ae311..2cc2588 100644 --- a/.gitea/workflows/go-test.yml +++ b/.gitea/workflows/go-test.yml @@ -65,41 +65,20 @@ jobs: if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' run: task test-race + - name: Run Resource Leak tests (Linux AMD64 only) + if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' + run: task test-leaks + + - name: Run Network Simulation tests (Linux AMD64 only) + if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' + run: task test-network + + - name: Run Fuzz tests (Linux AMD64 only) + if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' + run: task test-fuzz + - name: Run WebAssembly tests (Linux AMD64 only) if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' run: | chmod +x misc/wasm/go_js_wasm_exec task test-wasm - - - name: Test build (ensure compilation works) - run: | - echo "Testing build for current platform (${{ matrix.os }}, ${{ matrix.goarch }})..." - task build - - - name: Test WebAssembly build (Linux AMD64 only) - if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' - run: task build-wasm - - - name: Test binary execution - run: | - echo "Testing binary execution on (${{ matrix.os }}, ${{ matrix.goarch }})..." - timeout 5s ./bin/reticulum-go || echo "Binary started successfully (timeout expected)" - - - name: Test cross-compilation (AMD64 runners only) - if: matrix.goarch == 'amd64' - run: | - echo "Testing ARM64 cross-compilation from AMD64..." - GOOS=linux GOARCH=arm64 task build - env: - GOOS: linux - GOARCH: arm64 - - - name: Test ARMv6 cross-compilation (AMD64 runners only) - if: matrix.goarch == 'amd64' - run: | - echo "Testing ARMv6 cross-compilation from AMD64..." - GOOS=linux GOARCH=arm GOARM=6 task build - env: - GOOS: linux - GOARCH: arm - GOARM: 6 diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..0e97719 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,97 @@ +name: Go Publish + +on: + push: + branches: + - main + - master + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build: + name: Build (${{ matrix.goos }}, ${{ matrix.goarch }}) + strategy: + matrix: + goos: [linux, windows, darwin, freebsd] + goarch: [amd64, arm64, arm] + include: + - goos: js + goarch: wasm + exclude: + - goos: darwin + goarch: arm + + runs-on: ubuntu-latest + + steps: + - name: Checkout Source + uses: https://git.quad4.io/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + + - name: Set up Go + uses: https://git.quad4.io/actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 + with: + go-version: '1.25' + + - name: Setup Task + uses: https://git.quad4.io/actions/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 + with: + version: '3.46.3' + + - name: Build + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + GOARM: ${{ matrix.goarch == 'arm' && '6' || '' }} + CGO_ENABLED: '0' + run: | + output_name="reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }}" + if [ "${{ matrix.goos }}" = "js" ] && [ "${{ matrix.goarch }}" = "wasm" ]; then + task build-wasm + output_name+=".wasm" + mv bin/reticulum-go.wasm "${output_name}" + else + task build + if [ "${{ matrix.goos }}" = "windows" ]; then + output_name+=".exe" + fi + mv bin/reticulum-go "${output_name}" + fi + echo "Built: ${output_name}" + + - name: Calculate SHA256 Checksum + run: | + output_name="reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }}" + if [ "${{ matrix.goos }}" = "windows" ]; then + output_name+=".exe" + elif [ "${{ matrix.goos }}" = "js" ] && [ "${{ matrix.goarch }}" = "wasm" ]; then + output_name+=".wasm" + fi + BINARY_PATH="${output_name}" task checksum + + - name: Upload Artifact + uses: https://git.quad4.io/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 + with: + name: reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }} + path: | + reticulum-go-${{ matrix.goos }}-${{ matrix.goarch }}* + + release: + name: Create Release + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download All Build Artifacts + uses: https://git.quad4.io/actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a + with: + path: ./release-assets + + - name: Create Gitea Release + uses: https://git.quad4.io/actions/gitea-release-action@4875285c0950474efb7ca2df55233c51333eeb74 + with: + files: ./release-assets/*/* + diff --git a/Taskfile.yml b/Taskfile.yml index 7e6d263..2159a88 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -141,6 +141,21 @@ tasks: cmds: - '{{.GOCMD}} test -race -v ./...' + test-fuzz: + desc: Run fuzz tests for a short duration + cmds: + - '{{.GOCMD}} test -fuzz=FuzzPacketUnpack -fuzztime=30s ./pkg/packet' + + test-leaks: + desc: Run resource leak tests + cmds: + - '{{.GOCMD}} test -v ./pkg/transport -run TestTransportLeak' + + test-network: + desc: Run network simulation tests + cmds: + - '{{.GOCMD}} test -v ./pkg/transport -run TestTransportNetworkSimulation' + coverage: desc: Generate test coverage report cmds: