Introducing a new way to review your PRs.

Read the announcement

iv-org / invidious

Invidious is an alternative front-end to YouTube

View on GitHub

19 documents · Updated Oct 12, 2026

docs / build-test-and-development-workflow

Build, test, and development workflow

Invidious uses the Crystal toolchain to turn one application entry point into a web and API service. The development workflow keeps dependency setup, compilation, automated specifications, formatting, lint checks, and container smoke checks close to the same path used for release builds.

Crystal toolchain and dependency model

The project defines one Crystal application target and separates libraries needed at runtime from tools used only during development. This split lets production builds install only the libraries needed by the service while test and lint work can add the development tools.

Crystal project contract

The project target is built from src/invidious.cr. The supported language range starts at Crystal 1.14.1 and stops before Crystal 2.0, so a local toolchain must stay inside that range. The project records its direct library choices and versions in shard.yml, while the lock file keeps installs repeatable.

The main libraries provide the service, database access, proxy access, data encoding, and content negotiation. Spectator provides the specification runner and Ameba provides the Crystal linter for development work.

References: shard.yml• L8-10 shard.yml• L15-43

Dependency setup layers

Local setup has two layers. The host setup installs Crystal, PostgreSQL, native development libraries, Git, the image tool used by login CAPTCHA support, and Make; the Crystal package step then fetches the project libraries.

The Makefile production path uses shards install --production, which excludes development-only libraries. Test and lint commands therefore need a normal Shards install when the development dependencies are not already present.

References: scripts/install-dependencies.sh• L3-20 scripts/install-dependencies.sh• L60-118 Makefile• L35-42 shard.yml• L35-41

Build entrypoints

The build entrypoints offer a normal executable build, a compile-only check, and a local launch path. They share the same application target but serve different feedback needs during development.

Production executable build

The default make target fetches production libraries and builds an invidious executable. Release mode is on by default, while debug symbols remain on unless NO_DBG_SYMBOLS=1 is set.

Builds can also be made static with STATIC=1. API_ONLY=1 selects the API-only product shape by excluding the browser-facing route set. SKIP_VERSION_CHECK=1 bypasses the compile-time Crystal version check for development or unusual build environments. These options change the artifact or feature surface without changing the main entry point.

References: Makefile• L5-33 Makefile• L39-47 Makefile• L108-115 src/invidious.cr• L50-72 src/invidious.cr• L17-51

Compile-only verification

The make verify target checks that the application compiles without producing a binary. It also disables the player asset download and skips code generation, which makes it useful for fast source checks and for finding compile errors when external asset access is not needed.

This check is distinct from a production build. It confirms source compatibility, but it does not prove that the final executable or downloaded player assets are ready to run.

References: Makefile• L64-66 src/invidious.cr• L148-161

Local service launch

The make run target builds the executable first and then starts it. This gives a developer a path that exercises the same compiled application entry point used by the service rather than a separate development server.

References: Makefile• L49-50

Automated specification suite

The specification suite checks small pieces of service behavior in process. It uses Spectator and groups specifications by the behavior they protect, such as parsing, search rules, user data import, localization, proxy access, HTTP asset delivery, and video data handling.

Shared specification context

Most specifications use spec/spec_helper.cr. It loads the shared application helpers and feature types, then configures Spectator to reject blank specifications and randomize execution order. Parser specifications use spec/parsers_helper.cr when they need JSON fixtures from mocks/ and a quiet logger.

The shared setup keeps specifications focused on behavior rather than on starting the full service. This also exposes hidden ordering or shared-state assumptions because the normal suite runs in a randomized order.

References: spec/spec_helper.cr• L1-18 spec/parsers_helper.cr• L1-35

Specification coverage areas

The suite is organized by the kind of user or service behavior under check:

AreaWhat the specifications protect
Search and query handlingSearch types, legacy filters, URL filters, and round-trip parameter encoding
Video and content parsingVideo metadata, related content, missing descriptions, and parser results from saved response data
User data portabilitySubscription import from exported CSV data
Shared helpers and localizationContinuation tokens, signed tokens, date parsing, and locale plural rules
Network boundariesSOCKS5 negotiation, authentication, address encoding, and tunneled HTTP requests
HTTP assets and text outputStatic file caching, ranges, compression, and WebVTT output

The specifications use both direct inputs and saved mocks. This gives parser checks stable source data while network-bound behavior uses small local test servers instead of live external services.

References: spec/…/query_spec.cr• L12-241 spec/…/regular_videos_extract_spec.cr• L3-83 spec/…/imports_spec.cr• L28-51 spec/…/socks_proxy_spec.cr• L138-243 spec/…/static_assets_handler_spec.cr• L65-232

Isolated static asset specification

The static asset handler specification is not part of the normal all-specification run because its compile-time setup conflicts with the rest of the suite. Run it directly with crystal spec spec/http_server/handlers/static_assets_handler_spec.cr -Drunning_by_self on a Crystal version that supports the file.

The isolated check covers serving, cache behavior, byte ranges, compression, and the cache size limit. It clears the handler cache after each example so one check does not change the next check.

References: spec/…/static_assets_handler_spec.cr• L1-10 spec/…/static_assets_handler_spec.cr• L97-122 spec/…/static_assets_handler_spec.cr• L201-233

Continuous integration gates

Continuous integration checks language compatibility, service behavior, container startup, formatting, and lint quality. The gates run at different levels so a source change can fail either as a Crystal program, as a containerized service, or as a maintained code base.

Crystal compatibility matrix

The build job runs the full specifications and a warning-clean build across supported stable Crystal releases from 1.14.1 through 1.21.0. It also probes the Crystal nightly build without making that probe a required result.

The job installs the native SQLite development package and restores Shards from a lock-file-based cache before it runs. This makes the matrix test both the declared Crystal range and the native dependency needed by the application.

References: .github/…/ci.yml• L31-90 shard.yml• L19-21 shard.yml• L43

Container service check

The container job builds the service for AMD64 and ARM64, starts it with Docker Compose, and checks that the HTTP endpoint on port 3000 responds. When the check fails, the workflow prints the service logs so the failure can be traced to startup or runtime behavior.

This gate complements the Crystal build. A successful compile does not guarantee that the image can start with its service and database wiring, so the container check validates the assembled runtime shape.

References: .github/…/ci.yml• L92-125

Container image publication

The container publication workflows turn a release or a push to master into AMD64 and ARM64 images in the Quay registry. Each architecture is built on a matching runner, then a multi-architecture manifest points one tag at both images so consumers can use the same image name on either platform.

Stable publication runs for version tags or by manual dispatch and publishes version and latest tags. Nightly publication runs on relevant pushes to master and publishes a date-and-commit tag plus master. Both workflows require registry credentials and mark the image as a release build.

The publication flow is separate from the CI container service check. CI starts a local Compose deployment to verify service behavior, while these workflows push the built image and combine its architecture-specific results for users.

References: .github/…/build-stable-container.yml• L1-7 .github/…/build-stable-container.yml• L9-66 .github/…/build-stable-container.yml• L68-87 .github/…/build-nightly-container.yml• L1-19 .github/…/build-nightly-container.yml• L21-77 .github/…/build-nightly-container.yml• L79-98

Formatting and lint checks

The lint job checks Crystal formatter compliance and runs Ameba. A formatting mismatch causes the job to show the formatter's proposed diff and fail; the Ameba job uses the repository rule set in .ameba.yml.

The rule set excludes known false positives in selected source areas, disables rules that do not fit current code patterns, and limits the useless-assignment route exclusion to direct route files. The lint job is advisory today because the workflow allows it to continue after failure. It still defines the expected style and lint contract for developers and for later enforcement.

References: .github/…/ci.yml• L127-167 .ameba.yml• L1-72 Makefile• L58-59

Developer support scripts

Support scripts prepare host tools, synchronize generated or downloaded assets, and automate release preparation. They are not alternate application entrypoints; they keep work around the main Crystal build repeatable.

Host dependency installer

The shell installer chooses a package path from the host's operating system metadata. It installs the system packages that Crystal and Invidious need, including database tools and libraries for SQLite imports and CAPTCHA image conversion.

Use it as a starting point for supported Linux hosts, then verify the package result before running the Crystal build. Unsupported distributions are told to install the dependencies by hand.

References: scripts/install-dependencies.sh• L23-37 scripts/install-dependencies.sh• L60-78 scripts/install-dependencies.sh• L95-118 scripts/install-dependencies.sh• L125-173

Player asset synchronization

Player dependencies are treated as build inputs. During a normal compile, the application checks videojs-dependencies.yml, downloads missing or changed packages from the npm registry, verifies their checksums, and places the selected JavaScript and CSS assets under the asset tree. The --minified option selects smaller files.

The process runs at compile time because the built service expects those assets to be available. -Dskip_videojs_download is the explicit escape hatch for compile-only checks and CI paths that do not need to refresh them.

References: src/invidious.cr• L169-179 scripts/fetch-player-dependencies.cr• L7-12 scripts/fetch-player-dependencies.cr• L25-71 scripts/fetch-player-dependencies.cr• L73-161

Asset license generation

The license helper scans shipped JavaScript files and prints HTML table rows for the application license page. Its output is intended for compile-time insertion into the page, so changes to shipped JavaScript can affect the generated license view.

References: scripts/generate_js_licenses.cr• L1-9 scripts/generate_js_licenses.cr• L22-34 scripts/generate_js_licenses.cr• L36-56

Release preparation

The release helper turns merged pull requests into a proposed release branch and pull request. It computes the date-based version from shard.yml, collects merged pull requests, prepares changelog prose through an OpenAI-compatible service, updates the version and changelog, and leaves tagging and publishing for maintainer review.

The workflow that calls it is manual. A dry run edits local files only, while a full run needs Python, GitHub CLI access, and the configured API key.

References: scripts/create-release.py• L1-37 scripts/create-release.py• L240-279 scripts/create-release.py• L296-333 .github/…/create-release.yml• L1-11 .github/…/create-release.yml• L38-59

Build and test work is tied to two operating concerns covered by related pages:

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the Crystal version range in shard.yml, the CI version matrix, and any native package guidance aligned.
  • Keep Makefile compile flags aligned with the compile-time flags consumed by src/invidious.cr, especially API_ONLY, SKIP_VERSION_CHECK, and skip_videojs_download.
  • When player dependency names, versions, or checksums change, verify both the asset fetch path and any generated license output.
  • When a specification needs special compile-time flags or fixture setup, keep its normal-suite behavior and its standalone invocation clear in the spec file.
  • Keep the stable and nightly container tag rules aligned with their manifest source tags and the intended trigger branches or release tags.
  • When container build platforms or registry settings change, review both architecture jobs and the manifest step together.
  • When release version rules or changelog structure change, update both scripts/create-release.py and its manual workflow inputs.

Important failure modes

TriggerConsequenceGuard
A developer runs make test after only a production Shards installSpectator or other development tools are unavailableInstall the development dependencies with a normal shards install before test or lint work
A normal build cannot reach the npm registry or a player package checksum differsCompile-time player asset preparation fails before the application build finishesCheck network access and the declared package checksum; use make verify only when a player refresh is not part of the check
The static asset specification is included in the full spec runCrystal can report a compile-time conflict and the suite does not completeRun the file alone with -Drunning_by_self on the required Crystal version
A supported Crystal version falls outside the project range or a CI matrix version is dropped without reviewThe source may compile locally but lose a declared compatibility guaranteeCompare shard.yml with the CI matrix before changing the toolchain
A build uses a Crystal compiler older than 1.14.1 without SKIP_VERSION_CHECK=1The compile-time guard stops the build and reports the required minimum versionUse Crystal 1.14.1 or newer, or use the explicit skip flag only for a suitable development environment
A yum-family host reaches the installer path that calls the missing install_dnf functionHost setup stops before all required packages are installedInspect the installer path for that distribution and install the listed packages manually if needed
One architecture image is not pushed or its tag differs from the manifest sourceThe multi-architecture tag is incomplete or points to an image that does not existKeep the architecture tags and manifest sources synchronized in both publication workflows
Container registry credentials are missing during a publication runImage pushes and manifest creation fail after the build workProvide the required Quay credentials before running stable or nightly publication

Key files

FileWhy to read it
shard.ymlDefines the Crystal target, supported language range, runtime libraries, and development tools
MakefileProvides the main local build, run, format, test, verify, and cleanup entrypoints
src/invidious.crShows the application entry point, compiler version guard, and compile-time player asset step
.github/…/ci.ymlShows the required compatibility, specification, container, format, and lint gates
.github/…/build-stable-container.ymlShows stable multi-architecture image publication and manifest creation
.github/…/build-nightly-container.ymlShows master image publication and multi-architecture manifest creation
.ameba.ymlDefines repository-specific lint exclusions, disabled rules, and style exceptions
spec/spec_helper.crDefines the shared specification imports and Spectator behavior
spec/parsers_helper.crDefines parser fixture loading and quiet test logging
spec/http_server/handlers/static_assets_handler_spec.crDocuments the separate static asset test invocation and its runtime guarantees
scripts/install-dependencies.shDescribes the host packages needed before Crystal development
scripts/fetch-player-dependencies.crDefines how checked player assets are fetched and refreshed
scripts/generate_js_licenses.crDefines the generated JavaScript license table input
scripts/create-release.pyAutomates version, changelog, and release pull request preparation