Contributing

This guide is for developers who want to contribute to apt-bundle or understand its internals.

Project Structure

apt-bundle/
├── cmd/
│   └── apt-bundle/       # Main entry point
├── internal/
│   ├── aptfile/          # Aptfile parsing
│   ├── commands/         # CLI commands (install, dump, check)
│   ├── apt/              # APT interactions
│   └── config/           # Configuration
├── docs/                 # Documentation
├── Makefile              # Build automation
└── go.mod                # Go module definition

Prerequisites

Building

Build the Binary

make build

The binary will be created at build/apt-bundle.

Install Locally

sudo make install

This installs to /usr/local/bin/apt-bundle by default. You can customize:

INSTALL_DIR=$HOME/.local/bin USE_SUDO="" make install

Build Options

The Makefile uses the following build flags:

Development Workflow

Format Code

make fmt

This runs go fmt ./... to format all Go code.

Run Static Analysis

make vet

This runs go vet ./... to catch common errors.

Run Linter

make lint

This runs golangci-lint for comprehensive code analysis.

Run Tests

make test

This runs all tests with verbose output.

Clean Build Artifacts

make clean

Removes the build/ directory.

Testing

Running Tests

# Run all tests
make test

# Run tests for a specific package
go test ./internal/aptfile/...

# Run tests with coverage
go test -cover ./...

Writing Tests

Test Requirements

Testing GitHub Actions Locally

There are two ways to test the CI workflow locally before pushing:

The easiest way is to use the ci-build Makefile target, which mimics the exact CI build step:

# Test with default architecture (amd64) and version from VERSION file
make ci-build

# Test with specific architecture
make ci-build ARCH=arm64

# Test with specific architecture and version
make ci-build ARCH=amd64 VERSION=0.1.5

This will:

Note: This only tests the build step. It doesn’t test the full workflow (version calculation, release creation, etc.).

Option 2: Full Workflow Testing with act

For testing the complete GitHub Actions workflow, you can use act:

Installation:

# On macOS
brew install act

# On Linux (using the install script)
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash

# Or download from releases: https://github.com/nektos/act/releases

Basic Usage:

# List all workflows
act -l

# Run the build job (dry-run, won't actually build)
act -j build --dryrun

# Run the build job for a specific architecture
act -j build --matrix goarch:amd64 --matrix debarch:amd64

# Run with environment variables
act -j build -e VERSION=0.1.0

Limitations:

Recommended Workflow:

  1. Quick iteration: Use make ci-build to test build changes rapidly
  2. Full workflow: Use act before pushing to test the complete workflow
  3. Final verification: Push to a test branch and let GitHub Actions run

Debugging CI Test Failures

When tests pass locally but fail in CI:

  1. Run tests in a CI-like environment (Docker, matches ubuntu-latest):
    make test-docker
    

    This often reproduces the failure locally.

  2. Download the test output artifact when CI fails: In the Actions run, open the “Run tests” step. If the log is truncated, go to the “Summary” tab and download the test-output artifact (uploaded on failure).

  3. Use -failfast (already in CI): Tests stop at the first failure, so the failing test name and error appear at the end of the log.

Code Style

Architecture

For a detailed walkthrough of the internal design — including motivation, component diagrams, data flow for each command, and guidance on where to make changes for new features — see the Architecture page.

Pull Request Guidelines

Getting Started

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/yourusername/apt-bundle.git
  3. Create a branch: git checkout -b feature/your-feature
  4. Make your changes
  5. Run tests: make test
  6. Format code: make fmt
  7. Run linter: make lint
  8. Commit your changes
  9. Push to your fork
  10. Open a Pull Request

PR Guidelines

Commit Messages

Write clear, descriptive commit messages:

Add support for version pinning in Aptfile

- Parse version strings from apt directives
- Pass version to apt-get install
- Add tests for version parsing

Dependencies

External Dependencies

Development Dependencies

Managing Dependencies

# Download dependencies
make deps

# Add a new dependency
go get <package>

# Update dependencies
go get -u ./...
go mod tidy

Binary Characteristics

The apt-bundle binary is designed to be:

Release Process

  1. Update version in code (if versioning is implemented)
  2. Update CHANGELOG.md
  3. Create a git tag
  4. Build release binaries
  5. Create GitHub release
  6. Upload binaries

Troubleshooting

Build Issues

Test Issues

Development Environment

CI and Workflow Issues

nfpm not found: The Makefile will auto-install nfpm if it’s missing. For act, ensure Docker is running.

Architecture-specific issues: Test each architecture individually:

make ci-build ARCH=amd64
make ci-build ARCH=arm64
make ci-build ARCH=armhf
make ci-build ARCH=i386

Version format: The CI workflow expects versions in MAJOR.MINOR.PATCH format. The Makefile defaults to VERSION.0 if only MAJOR.MINOR is in the VERSION file.

Resources

Getting Help