[ci] update and refactor
Some checks failed
CodeQL / Analyze (go) (push) Failing after 3m5s
CodeQL / Analyze (javascript) (push) Failing after 1m19s
mkdocs / mkdocs (push) Failing after 1m19s
docker / build-docker (inux/arm/v6) (push) Failing after 6s
docker / build-docker (linux/386) (push) Failing after 5s
docker / build-docker (linux/amd64) (push) Failing after 4s
docker / build-docker (linux/arm/v7) (push) Failing after 5s
docker / build-docker (linux/arm64) (push) Failing after 5s
Some checks failed
CodeQL / Analyze (go) (push) Failing after 3m5s
CodeQL / Analyze (javascript) (push) Failing after 1m19s
mkdocs / mkdocs (push) Failing after 1m19s
docker / build-docker (inux/arm/v6) (push) Failing after 6s
docker / build-docker (linux/386) (push) Failing after 5s
docker / build-docker (linux/amd64) (push) Failing after 4s
docker / build-docker (linux/arm/v7) (push) Failing after 5s
docker / build-docker (linux/arm64) (push) Failing after 5s
This commit is contained in:
parent
b245c9f451
commit
5a77fa5e9c
8 changed files with 67 additions and 254 deletions
72
.github/workflows/build-arm.yaml
vendored
72
.github/workflows/build-arm.yaml
vendored
|
@ -1,72 +0,0 @@
|
||||||
---
|
|
||||||
name: build-arm
|
|
||||||
|
|
||||||
# Trigger the workflow on push or pull request
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_job:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
name: linux_${{ matrix.arch }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- arch: armv7
|
|
||||||
go: 1.20.7
|
|
||||||
go_arch: armv6l
|
|
||||||
- arch: aarch64
|
|
||||||
go: 1.20.7
|
|
||||||
go_arch: arm64
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
name: Checkout
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- uses: uraimo/run-on-arch-action@v2.5.1
|
|
||||||
name: Test and Build
|
|
||||||
id: runcmd
|
|
||||||
with:
|
|
||||||
arch: ${{ matrix.arch }}
|
|
||||||
distro: ubuntu20.04
|
|
||||||
githubToken: ${{ github.token }}
|
|
||||||
|
|
||||||
setup: |
|
|
||||||
mkdir -p "/tmp/artifacts"
|
|
||||||
dockerRunArgs: |
|
|
||||||
--volume "/tmp/artifacts:/artifacts"
|
|
||||||
install: |
|
|
||||||
apt update
|
|
||||||
apt install -y fuse libfuse-dev rpm pkg-config curl git make gcc g++
|
|
||||||
apt upgrade -y
|
|
||||||
run: |
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
|
||||||
rm -rf /usr/local/go
|
|
||||||
mkdir -p /usr/local/go
|
|
||||||
curl -s -L https://golang.org/dl/go${{ matrix.go }}.linux-${{ matrix.go_arch }}.tar.gz | tar -C /usr/local -xz
|
|
||||||
go version
|
|
||||||
|
|
||||||
make test
|
|
||||||
make build
|
|
||||||
cp bin/* /artifacts
|
|
||||||
- name: Show artifacts
|
|
||||||
run: |
|
|
||||||
ls -al "/tmp/artifacts"
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
if-no-files-found: error
|
|
||||||
name: build-${{ matrix.arch }}
|
|
||||||
path: "/tmp/artifacts/*"
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
files: "/tmp/artifacts/*"
|
|
126
.github/workflows/build.yaml
vendored
126
.github/workflows/build.yaml
vendored
|
@ -1,126 +0,0 @@
|
||||||
---
|
|
||||||
name: build
|
|
||||||
|
|
||||||
# Trigger the workflow on push or pull request
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
timeout-minutes: 60
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
job_name: ['linux', 'mac', 'windows_amd64']
|
|
||||||
|
|
||||||
include:
|
|
||||||
- job_name: linux
|
|
||||||
os: ubuntu-latest
|
|
||||||
|
|
||||||
- job_name: mac
|
|
||||||
os: macOS-11
|
|
||||||
|
|
||||||
- job_name: windows_amd64
|
|
||||||
os: windows-latest
|
|
||||||
|
|
||||||
name: ${{ matrix.job_name }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: ^1.20
|
|
||||||
|
|
||||||
- name: Install Libraries on Linux
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo modprobe fuse
|
|
||||||
sudo chmod 666 /dev/fuse
|
|
||||||
sudo chown root:$USER /etc/fuse.conf
|
|
||||||
sudo apt-get install fuse libfuse-dev rpm pkg-config
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
|
|
||||||
- name: Install Libraries on macOS
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
brew update
|
|
||||||
brew install --cask osxfuse
|
|
||||||
if: matrix.os == 'macOS-11'
|
|
||||||
|
|
||||||
- name: Install Libraries on Windows
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
|
||||||
choco install -y winfsp zip
|
|
||||||
echo "CPATH=C:\Program Files\WinFsp\inc\fuse;C:\Program Files (x86)\WinFsp\inc\fuse" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
||||||
if ($env:GOARCH -eq "386") {
|
|
||||||
choco install -y mingw --forcex86 --force
|
|
||||||
echo "C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw32\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
||||||
}
|
|
||||||
# Copy mingw32-make.exe to make.exe so the same command line
|
|
||||||
# can be used on Windows as on macOS and Linux
|
|
||||||
$path = (get-command mingw32-make.exe).Path
|
|
||||||
Copy-Item -Path $path -Destination (Join-Path (Split-Path -Path $path) 'make.exe')
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
|
|
||||||
- name: Print Go version and environment
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
printf "Using go at: $(which go)\n"
|
|
||||||
printf "Go version: $(go version)\n"
|
|
||||||
printf "\n\nGo environment:\n\n"
|
|
||||||
go env
|
|
||||||
printf "\n\nSystem environment:\n\n"
|
|
||||||
env
|
|
||||||
|
|
||||||
- name: Go module cache
|
|
||||||
uses: actions/cache@v3.3.2
|
|
||||||
with:
|
|
||||||
path: ~/go/pkg/mod
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
make test-race
|
|
||||||
- name: Convert coverage.out to coverage.lcov
|
|
||||||
uses: jandelgado/gcov2lcov-action@v1.0.9
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
- name: Coveralls
|
|
||||||
uses: coverallsapp/github-action@v2.2.3
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
path-to-lcov: coverage.lcov
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
make build
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
if-no-files-found: error
|
|
||||||
name: build-${{ matrix.job_name }}
|
|
||||||
path: bin/*
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
files: bin/*
|
|
73
.github/workflows/docker.yaml
vendored
73
.github/workflows/docker.yaml
vendored
|
@ -8,48 +8,61 @@ on:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
build-docker:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
- linux/386
|
||||||
|
- inux/arm/v6
|
||||||
|
- linux/arm/v7
|
||||||
|
- linux/arm64
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v5.0.0
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: tstor/tstor
|
# list of Docker images to use as base name for tags
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
|
type=schedule
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Build and push Docker image
|
||||||
uses: docker/setup-qemu-action@v3.0.0
|
uses: docker/build-push-action@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3.0.0
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5.0.0
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
pull: true
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
sbom: true
|
||||||
|
provenance: true
|
||||||
- name: Update repo description
|
cache-from: type=gha
|
||||||
uses: peter-evans/dockerhub-description@v3
|
cache-to: type=gha,mode=max
|
||||||
with:
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
repository: tstor/tstor
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Stage 1: Build
|
# Stage 1: Build
|
||||||
#===============
|
#===============
|
||||||
|
|
||||||
FROM golang:1.20-alpine as builder
|
FROM golang:1.20 as builder
|
||||||
|
|
||||||
ENV BIN_REPO=git.kmsign.ru/royalcat/tstor
|
ENV BIN_REPO=git.kmsign.ru/royalcat/tstor
|
||||||
ENV BIN_PATH=$GOPATH/src/$BIN_REPO
|
ENV BIN_PATH=$GOPATH/src/$BIN_REPO
|
||||||
|
|
|
@ -66,7 +66,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupStorage(tcfg config.TorrentClient) (storage.ClientImplCloser, storage.PieceCompletion, error) {
|
func setupStorage(tcfg config.TorrentClient) (storage.ClientImplCloser, storage.PieceCompletion, error) {
|
||||||
pcp := filepath.Join(tcfg.MetadataFolder, "piece-completion")
|
pcp := filepath.Join(tcfg.DataFolder, "piece-completion")
|
||||||
if err := os.MkdirAll(pcp, 0744); err != nil {
|
if err := os.MkdirAll(pcp, 0744); err != nil {
|
||||||
return nil, nil, fmt.Errorf("error creating piece completion folder: %w", err)
|
return nil, nil, fmt.Errorf("error creating piece completion folder: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func setupStorage(tcfg config.TorrentClient) (storage.ClientImplCloser, storage.
|
||||||
// log.Info().Msg(fmt.Sprintf("setting cache size to %d MB", tcfg.GlobalCacheSize))
|
// log.Info().Msg(fmt.Sprintf("setting cache size to %d MB", tcfg.GlobalCacheSize))
|
||||||
// fc.SetCapacity(tcfg.GlobalCacheSize * 1024 * 1024)
|
// fc.SetCapacity(tcfg.GlobalCacheSize * 1024 * 1024)
|
||||||
|
|
||||||
filesDir := filepath.Join(tcfg.MetadataFolder, "files")
|
filesDir := filepath.Join(tcfg.DataFolder, "files")
|
||||||
if err := os.MkdirAll(pcp, 0744); err != nil {
|
if err := os.MkdirAll(pcp, 0744); err != nil {
|
||||||
return nil, nil, fmt.Errorf("error creating piece completion folder: %w", err)
|
return nil, nil, fmt.Errorf("error creating piece completion folder: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
const (
|
|
||||||
metadataFolder = "./tstor-data/metadata"
|
|
||||||
mountFolder = "./tstor-data/mount"
|
|
||||||
logsFolder = "./tstor-data/logs"
|
|
||||||
serverFolder = "./tstor-data/served-folders/server"
|
|
||||||
)
|
|
||||||
|
|
||||||
var defaultConfig = Config{
|
var defaultConfig = Config{
|
||||||
WebUi: WebUi{
|
WebUi: WebUi{
|
||||||
Port: 4444,
|
Port: 4444,
|
||||||
|
@ -25,20 +18,21 @@ var defaultConfig = Config{
|
||||||
},
|
},
|
||||||
Fuse: Fuse{
|
Fuse: Fuse{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
AllowOther: false,
|
|
||||||
Path: mountFolder,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
TorrentClient: TorrentClient{
|
TorrentClient: TorrentClient{
|
||||||
GlobalCacheSize: 2048,
|
DataFolder: "data",
|
||||||
MetadataFolder: metadataFolder,
|
MetadataFolder: "metadata",
|
||||||
|
|
||||||
|
// GlobalCacheSize: 2048,
|
||||||
|
|
||||||
AddTimeout: 60,
|
AddTimeout: 60,
|
||||||
ReadTimeout: 120,
|
ReadTimeout: 120,
|
||||||
},
|
},
|
||||||
|
|
||||||
Log: Log{
|
Log: Log{
|
||||||
Path: logsFolder,
|
Path: "/tmp/tstor",
|
||||||
MaxBackups: 2,
|
MaxBackups: 2,
|
||||||
MaxSize: 50,
|
MaxSize: 50,
|
||||||
},
|
},
|
||||||
|
@ -69,7 +63,7 @@ var defaultRoutes = []Route{
|
||||||
var defaultServers = []Server{
|
var defaultServers = []Server{
|
||||||
{
|
{
|
||||||
Name: "server",
|
Name: "server",
|
||||||
Path: serverFolder,
|
Path: "server",
|
||||||
Trackers: []string{
|
Trackers: []string{
|
||||||
"wss://tracker.btorrent.xyz",
|
"wss://tracker.btorrent.xyz",
|
||||||
"wss://tracker.openwebtorrent.com",
|
"wss://tracker.openwebtorrent.com",
|
||||||
|
|
|
@ -24,9 +24,9 @@ func Load(path string) (*Config, error) {
|
||||||
_ = k.Load(file.Provider(path), yaml.Parser()) // its ok if file doesnt exist
|
_ = k.Load(file.Provider(path), yaml.Parser()) // its ok if file doesnt exist
|
||||||
}
|
}
|
||||||
|
|
||||||
err = k.Load(env.Provider("tstor_", ".", func(s string) string {
|
err = k.Load(env.Provider("TSTOR_", ".", func(s string) string {
|
||||||
return strings.Replace(strings.ToLower(
|
return strings.Replace(strings.ToLower(
|
||||||
strings.TrimPrefix(s, "tstor_")), "_", ".", -1)
|
strings.TrimPrefix(s, "TSTOR_")), "_", ".", -1)
|
||||||
}), nil)
|
}), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -24,10 +24,14 @@ type Log struct {
|
||||||
type TorrentClient struct {
|
type TorrentClient struct {
|
||||||
ReadTimeout int `koanf:"read_timeout,omitempty"`
|
ReadTimeout int `koanf:"read_timeout,omitempty"`
|
||||||
AddTimeout int `koanf:"add_timeout,omitempty"`
|
AddTimeout int `koanf:"add_timeout,omitempty"`
|
||||||
GlobalCacheSize int64 `koanf:"global_cache_size,omitempty"`
|
|
||||||
MetadataFolder string `koanf:"metadata_folder,omitempty"`
|
|
||||||
DisableIPv6 bool `koanf:"disable_ipv6,omitempty"`
|
DisableIPv6 bool `koanf:"disable_ipv6,omitempty"`
|
||||||
|
|
||||||
|
DataFolder string `koanf:"data_folder,omitempty"`
|
||||||
|
MetadataFolder string `koanf:"metadata_folder,omitempty"`
|
||||||
|
|
||||||
|
// GlobalCacheSize int64 `koanf:"global_cache_size,omitempty"`
|
||||||
|
|
||||||
Routes []Route `koanf:"routes"`
|
Routes []Route `koanf:"routes"`
|
||||||
Servers []Server `koanf:"servers"`
|
Servers []Server `koanf:"servers"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue