Skip to content

Commit

Permalink
Allow specifying other pkgs; allow “chaste” mode (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Feb 6, 2023
1 parent 73d1d42 commit bc5244e
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 41 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ permissions:
contents: read

jobs:
# check if this is a new release
smoke:
runs-on: ubuntu-latest
outputs:
Expand All @@ -29,12 +30,12 @@ jobs:
- uses: andymckay/[email protected]
if: ${{ steps.rev-parse.outputs.result == 'cancel' }}

ci1:
ci:
needs: [smoke]
uses: ./.github/workflows/ci.yml
secrets: inherit

ci2:
ci-pre-reqs:
needs: [smoke]
uses: ./.github/workflows/ci-pre-reqs.yml
secrets: inherit
Expand All @@ -43,7 +44,7 @@ jobs:
permissions:
contents: write
deployments: write
needs: [ci1, ci2, smoke]
needs: [ci, ci-pre-reqs, smoke]
runs-on: ubuntu-latest
steps:
- name: Create Deployment
Expand Down
41 changes: 39 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
env:
VERBOSE: ${{ matrix.verbose }}
- run: tea --env
- run: tea --env xc test
- run: tea --env xc check
# ^^ tea -E necessary because we run the install script and not the action
# so no additions to PATH or magic is installed
- run: which tea
Expand Down Expand Up @@ -106,9 +106,46 @@ jobs:
- run: test v$VERSION = v${{ steps.tea.outputs.version }}
- run: tea --env
- run: which tea
- run: tea xc test
- run: tea xc check
- run: node --eval 'console.log(1)'

chaste:
runs-on: ubuntu-latest
container: debian:buster-slim
steps:
- uses: actions/checkout@v3
- uses: ./
with:
chaste: true
- run:
if node --version; then
exit 1;
fi

additional-pkgs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
+deno.land: ^1.30
# ^^ produces a warning, but we like this syntax
# we're hoping GH allows us to suppress this warning in the future
# discussion: https://github.com/octokit/request-action/issues/26
- run: deno --version

additional-pkgs-2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
+: |
deno.land^1.30
cli.github.com
- run: deno --version
- run: gh --version

multiple-apply:
runs-on: ubuntu-latest
steps:
Expand Down
79 changes: 48 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
![tea](https://tea.xyz/banner.png)

[`install.sh`](./install.sh) is delivered when you `curl tea.xyz`.
* [`install.sh`](./install.sh) is delivered when you `curl tea.xyz`.
* This repository also provides the `tea` GitHub Action.

# GitHub Action 0.13.2

This repository also provides the `tea` GitHub Action.
# GitHub Action 0.14.0

```yaml
- uses: teaxyz/setup@v0
```
Installs tea, your dependencies (computed from your developer environment),
adds your deps to `PATH` and exports some other *tea’ish* variables like
`VERSION`.

# Usage
See [`action.yml`] for all inputs and outputs, but here’s the usual ones:

## Via Terminal
```yaml
- uses: teaxyz/setup@v0
with:
+: |
deno.land^1.30
rust-lang.org^1.60
```

Our packages are named after their homepages, to see what is available you
can browse the pantry on our website:
[tea.xyz] (we agree this isn’t great UX)

## Magic

We cannot install our shell magic into GitHub Actions. So unless you manually
add a package with `+:` you will need to ensure it is called with a `tea`
prefix, eg. `tea npx`.

## Interesting Usages

At tea, we consider the version in the `README` the definitive version.
Thus we use GitHub Actions to automatically tag and publish that version when
the README is edited and the version changes.

See our CI scripts for details.



# `tea` Installer

To install tea:

```sh
sh <(curl tea.xyz)
$ sh <(curl tea.xyz)
# - installs to `~/.tea`
# - if tea is already installed, the script instead checks for updates
```

To use tea to run a command in a temporary sandbox:

```sh
sh <(curl -Ssf tea.xyz) gum spin -- sleep 5
$ sh <(curl -Ssf tea.xyz) gum spin -- sleep 5

# - if tea is installed, uses that installation to run gum
# - if tea is *not* installed, downloads gum and its deps to a safe and
Expand All @@ -32,44 +67,26 @@ sh <(curl -Ssf tea.xyz) gum spin -- sleep 5

> NOTE we omit `https://` for clarity, *please* include it in all your usages.
### Options
## Options

* `sh <(curl tea.xyz) --yes` assumes affirmative for all prompts
* `sh <(curl tea.xyz) --prefix foo` change install location (you can use this option to force a re-install)
* `sh <(curl tea.xyz) --version 1.2.3` install a specific version of tea


## Via GitHub Actions

```yaml
- uses: teaxyz/setup@v0
```
Installs tea, your dependencies (listed in your `README.md`), adds your deps
to `PATH` and exports some other *tea’ish* variables like `VERSION`.

See [`action.yml`] for all inputs and outputs.

> NOTE: we cannot install our shell magic, so if eg. `npx` is not listed in
> your dependencies you will need to invoke it as `tea npx` to use it.

### Interesting Usages

At tea, we consider the version in the `README` the definitive version.
Thus we use GitHub Actions to automatically tag and publish that version when
the README is edited and the version changes.

See our CI scripts for details.

&nbsp;

# Tasks

## Test
## Check

Run this with `xc test`.
Run this with `xc check`.

```sh
node --check ./action.js
```


[`action.yml`]: ./action.yml
[tea.xyz]: https://tea.xyz
26 changes: 21 additions & 5 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ async function go() {
return path.normalize(TEA_DIR)
})()

const additional_pkgs = []
for (let key in process.env) {
if (key.startsWith("INPUT_+")) {
const value = process.env[key]
if (key == 'INPUT_+') {
for (const item of value.split(/\s+/)) {
if (item.trim()) {
additional_pkgs.push(`+${item}`)
}}} else {
key = key.slice(6).toLowerCase()
additional_pkgs.push(key+value)
}}}

// we build to /opt and special case this action so people new to
// building aren’t immediatelyt flumoxed
if (PREFIX == '/opt' && os.platform == 'darwin') {
Expand Down Expand Up @@ -91,17 +104,19 @@ async function go() {
const vv = parseFloat(v)
const env_flag = vv >= 0.19 ? '--env --keep-going' : '--env'

// install packages
execSync(`${teafile} --sync ${env_flag} echo`, {env})

// get env FIXME one call should do init

const args = vv >= 0.21
let args = vv >= 0.21
? ""
: vv >= 0.19
? "--dry-run"
: "--dump"
out = execSync(`${teafile} ${env_flag} ${args}`, {env}).toString()

if (process.env["INPUT_CHASTE"] == "true") {
args += " --chaste"
}

out = execSync(`${teafile} --sync ${env_flag} ${args} ${additional_pkgs.join(" ")}`, {env}).toString()

const lines = out.split("\n")
for (const line of lines) {
Expand Down Expand Up @@ -134,6 +149,7 @@ async function go() {
}
}

//TODO deprecated exe/md
const target = process.env['INPUT_TARGET']
if (target) {
execSync(`${teafile} ${target}`, {stdio: "inherit", env})
Expand Down
18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ inputs:
The version of teaxyz/cli to install.
Defaults to the most recent published version.
required: false
chaste:
description: >
Do not install packages.
Defaults to `false`.
default: false
+:
description: |
Whitespace separated, pkgs to supplement the environment. eg.
```yaml
+: |
deno.land^1.30
rust-lang.org^1.60
```
By default tea reads your developer environment and adds those packages.
Specifying additional packages here is a way to augment that.
required: false
srcroot:
description: |
Override detection of `$SRCROOT`.
Expand Down

0 comments on commit bc5244e

Please sign in to comment.