Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Rust FFI + major Go refactor #32

Merged
merged 9 commits into from Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .dockerignore

This file was deleted.

1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* @ch3ck

File renamed without changes.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug Report
about: If something isn't working as its supposed to
labels: bug, feature request, needs triage, won't fix
assignees: ch3ck
---

Please provide more details:

* What are you trying to do
* What happened
* What was the expected behaviour

Please share relevent code sample or [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example).
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Proposed changes
Describe the *big picture* reason for your PR.

## Checklist

Please review the following checklist before submitting a PR:

- [ ] **CONSIDER** adding a unit test to demonstrate your PR resolves an issue
- [ ] **DO** keep PRs small for easy review
- [ ] **DO** make sure unit tests pass
- [ ] **DO** ensure no compiler warnings are triggered
- [ ] **AVOID** breaking the CI builds

## Other comments
Any other comments you might have.
7 changes: 0 additions & 7 deletions .github/issue_template.md

This file was deleted.

38 changes: 28 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
name: Build
name: CI

on: [push, pull_request]


jobs:
setup-build-test:
name: Setup, Build, Test
build-and-test-rust-library:
name: Build and test rust library
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v2
- name: install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: build and test
working-directory: ./pkg/download
run: |
cargo build --tests --verbose && cargo test --verbose
build-and-test-go-module:
name: Build and test go source
strategy:
matrix:
go-version: [1.13.x]
platform: [macos-latest]
runs-on: ${{ matrix.platform }}
go-version: [1.16.x, 1.17.x, 1.18.x]
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Go
uses: actions/setup-go@v1
- name: Install go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Test
run: go test -v -coverage ./...
- name: Build
run: brew install ffmpeg && make build && make vet
run: make
18 changes: 18 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for Go
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for build tools
- package-ecosystem: "gomod"
directory: "/tools"
schedule:
interval: "weekly"
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release new binaries

on:
workflow_dispatch:
inputs:
reason:
description: new release message
required: true
push:
tags:
- "*"

permissions:
contents: write


jobs:
publish-crate-on-new-release:
name: "Publish crate on Release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-go-package-on-release:
name: Release go binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GoReleaser Pro key, for 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run security audit
# Author: Nyah Check
name: Run Security Audit

on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'

jobs:
run-security-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
53 changes: 39 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,57 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# MacOS DS_Store files
.DS_Store

# Ignore all downloaded video and audio files
# Binaries for programs and plugins
*.mp3
*.flv
*.webm
*.opus
*.mp4
*.3gpp
*.ogg
*.exe
*.exe~
*.dll
*.o
*.a
*.so
*.dylib

# Compiled binaries
## Compiled binaries
ytd
youtube-dl
ydl

*.exe

# Test binary, built with `go test -c`
*.test
*.prof

# OSX
.DS_Store

# CODE coverage results
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.html
coverage.txt
profile.out

# ENV files
# Dependency directories (remove the comment below to include it)
vendor/

# Output of GoReleaser
dist/

# Visual Studio Code files
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# GoLand and IntelliJ IDEA files
.idea/

# env files that usually contain secrets or local config
.env
.envrc
.idea
19 changes: 0 additions & 19 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 youtube-dl
Copyright (c) 2022 ydl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
69 changes: 25 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
# Setup package name variables
NAME := ytd
PKG := github.com/ch3ck/$(NAME)
PREFIX?=$(shell pwd)
BUILDTAGS=
version=v1.1

.PHONY: clean all fmt vet build test install static
.DEFAULT: default

all: clean fmt vet build test install

build: clean fmt
@echo "+ $@"
CGO_ENABLED=1 go build -tags "$(BUILDTAGS) cgo" .

static:
@echo "+ $@"
CGO_ENABLED=1 go build -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static" -o ytd .

fmt:
@echo "+ $@"
@gofmt -s -l -w . | tee /dev/stderr

test:
@echo "+ $@"
@find . -name \*.mp3 -delete #clean previous test files.
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list)
@find . -name \*.mp3 -delete # clean previous test downloads
@go test -bench=. $(shell go list)

vet:
@echo "+ $@"
@go vet $(shell go list | grep -v vendor)

.PHONY: build-all
build-all: build-static

.PHONY: run-all
run-all: run-static

.PHONY: build-static
build-static:
rustup toolchain install nightly
cd pkg/download && cargo +nightly build --release
cp pkg/download/target/release/libydl.a pkg/
go build -v ./...

.PHONY: run-static
run-static:
RUST_LOG=trace ./ydl

# test rust lib
.PHONY: test-rs
test-rs:
cd pkg/download && RUST_LOG=trace cargo test -- --nocapture

# clean all packages
.PHONY: clean
clean:
@echo "+ $@"
@rm -rf ytd
@find . -name \*.mp3 -delete
@find . -name \*.flv -delete

install:
@echo "+ $@"
@docker build -t ch3ck/youtube-dl:$(version) .
@go install .
rm -rf main_static pkg/libydl.so pkg/libydl.a pkg/download/target
Loading