Skip to content
Max Howell edited this page Dec 11, 2022 · 24 revisions

Welcome to the pantry.zero wiki!

If you're new to Tea, please check out the cli wiki.

Contributing Packages

  • Fork pantry.extra.
  • Create a branch for your new package (git checkout -b example.com).
  • Complete step-by-step section.
  • Submit a pull request for your packages. Once they are stable and if otherwise deemed appropriate we will move them to pantry.core.

Step-by-step

Here is an example session starting from scratch. You should replace "example.com/your.pantry.git" with the url of your pantry (assuming you renamed your fork). You should replace projects/example.com with the domain of the package. If you are in doubt about what domain to use, look at the existing names in pantry.core/projects and pantry.extra/projects. For example, if you were building a package for the product Ansible, you'd use projects/ansible.com because the Ansible product has that domain registered to them. If they don't have a domain for their product, I don't know what you should use.

sh <(curl https://tea.xyz)
mkdir pkgdev
cd pkgdev
git clone https://github.com/example.com/your.pantry.git
git clone https://github.com/teaxyz/cli.git
git clone https://github.com/teaxyz/pantry.core.git
mkdir your.pantry/projects/example.com
touch your.pantry/projects/example.com/package.yml

Edit your.pantry/projects/example.com/package.yml.

Editing package.yml

The best way to get started is to find an existing package.yml that is as close to what you need and copy it. You've already downloaded pantry.core, download pantry.extra too.

git clone https://github.com/teaxyz/pantry.core.git

Now grep it to see if there's something like what you need. For example, if you're building a python package, grep for python.

Also, check out the Packaging Guide and package.yml documentation.

Here is the simplest package.yml file.

distributable:
  url: https://example.com/download/{{version}}/src.tar.gz
  strip-components: 1

versions:
  - 1.0.0

build:
  script: |
    touch "{{prefix}}"/example

test:
  script: |
    ls -l
  working-directory: build

The "build" -> "script" section must create something in "{{prefix}}" or else the build will fail. "{{prefix}}" is "$TEA_PREFIX/example.com/v1.0.0".

Personal Access Token

Before you can build you need a GitHub PAT if the package.yml script gets versions from GitHub. In other words, this code requires a PAT.

versions:
  github: example.com/example/tags

This code doesn't require a PAT.

versions:
  - 1.0.0.

Here's the instructions for creating a (classic) personal access token. Make sure your token has the "repo" -> "public_repo" permission or else it won't work (you'll get "error: Uncaught (in promise) Error: 404").

Copy the token (it will start with "ghp_") add it to the shell environment like the following.

export GITHUB_TOKEN=ghp_secret

Build

export TEA_PANTRY_PATH="$PWD/your.pantry"
./pantry.core/scripts/build.ts example.com

As mentioned above, the "build" -> "script" section must create something in "{{prefix}}" or else the build will fail. "{{prefix}}" is "$TEA_PREFIX/example.com/v1.0.0".

Troubleshooting the Build

The script pantry.core/scripts/build.ts creates the file $TEA_PREFIX/example.com/src/build.sh. This script creates all of the environment variables needed to build your project. It also contains the code in package.yml, build -> script. You can modify this file directly to get closer to the build process.

If you want to get a REPL with the environment and test things out, just edit the build.sh script and exit before the package.yml stuff runs. You should also comment out some of the "set ..." commands at the top because they'll cause the shell to exit if there's an error.

Then do this.

. /path/to/build.sh

That will change your current environment to match the build environment.

Test

Packages require a test YAML node. This script should thoroughly verify all the functionality of the package is working. You can run the test with:

pantry.core/scripts/test.ts pkg.com

tea requires all packages be relocatable and cross platform. Our CI will verify this for you. You can check locally by moving the installation from ~/.tea to another tea installation (eg. ~/scratch/tea§ and running the test again.

Now make a pull request! We’ll test on all platforms we support in the PR. If it passes both CI and review: we’ll merge!

§ TEA_PREFIX=~/scratch/tea sh <(curl tea.xyz)

After Your Contribution

We build “bottles” (tar’d binaries) and upload them to both our centralized bottle storage and decentralized IPFS.

tea automatically builds new releases of packages as soon as they are released (usually starting the builds within seconds). There is no need to submit PRs for updates.

Basics

Advanced

^^ Guides for specific build tools and scenarios

Appendix

Clone this wiki locally