Skip to content

Commit 19092c2

Browse files
authored
k, setting $TEA_DIR always was bad (#36)
1 parent f0bec2e commit 19092c2

4 files changed

Lines changed: 35 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ jobs:
4949
- /opt
5050
container:
5151
- ~
52-
- ghcr.io/teaxyz/infuser:latest
53-
exclude:
54-
- os: macos-latest
52+
include:
53+
- os: ubuntu-latest
5554
container: ghcr.io/teaxyz/infuser:latest
55+
srcroot: .
56+
- os: ubuntu-latest
57+
container: ghcr.io/teaxyz/infuser:latest
58+
srcroot: ~
5659
container: ${{ matrix.container }}
5760
steps:
5861
- uses: actions/checkout@v3
@@ -64,6 +67,7 @@ jobs:
6467
with:
6568
prefix: ${{ matrix.prefix }}
6669
target: test
70+
srcroot: ${{ matrix.srcroot || github.workspace }}
6771

6872
- run: test -n "$VERSION"
6973
- run: test -n "${{ steps.tea.outputs.version }}"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[`install.sh`](./install.sh) is delivered when you `curl tea.xyz`.
44

55

6-
# GitHub Action 0.5.1
6+
# GitHub Action 0.5.3
77

88
This repository also provides the `tea` GitHub Action.
99

action.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
const { execSync, spawn } = require('child_process')
22
const https = require('https')
3+
const path = require('path')
34
const fs = require('fs')
45
const os = require("os")
56

67
async function go() {
78
process.stdout.write("installing tea…\n")
89

910
const PREFIX = process.env['INPUT_PREFIX'] || `${os.homedir()}/opt`
11+
const TEA_DIR = (() => {
12+
let TEA_DIR = process.env['INPUT_SRCROOT']
13+
if (!TEA_DIR) return
14+
TEA_DIR = TEA_DIR.trim()
15+
if (!TEA_DIR) return
16+
if (!TEA_DIR.startsWith("/")) {
17+
// for security this must be an absolute path
18+
TEA_DIR = `${process.cwd()}/${TEA_DIR}`
19+
}
20+
return path.normalize(TEA_DIR)
21+
})()
1022

1123
// we build to /opt and special case this action so people new to
1224
// building aren’t immediatelyt flumoxed
@@ -59,13 +71,9 @@ async function go() {
5971
fs.appendFileSync(GITHUB_PATH, `${bindir}\n`, {encoding: 'utf8'})
6072

6173
const teafile = `${bindir}/tea`
62-
const TEA_DIR = process.cwd()
6374

6475
const env = {
6576
TEA_DIR,
66-
// ^^ if there's no git then the checkout action uses the GitHub API
67-
// to check out the repo. So there won’t be a `.git` directory and tea
68-
// won’t find the SRCROOT
6977
...process.env
7078
}
7179

@@ -85,9 +93,10 @@ async function go() {
8593
fs.appendFileSync(GITHUB_ENV, `VERSION=${version}\n`, {encoding: 'utf8'})
8694
}
8795

88-
process.stdout.write(`::set-output name=srcroot::${TEA_DIR}\n`)
89-
fs.appendFileSync(GITHUB_ENV, `TEA_DIR=${TEA_DIR}\n`, {encoding: 'utf8'})
90-
96+
if (TEA_DIR) {
97+
process.stdout.write(`::set-output name=srcroot::${TEA_DIR}\n`)
98+
fs.appendFileSync(GITHUB_ENV, `TEA_DIR=${TEA_DIR}\n`, {encoding: 'utf8'})
99+
}
91100
} catch {
92101
// `tea -Eds` returns exit code 1 if no SRCROOT is found
93102
//TODO a flag so it returns 0 so we can not just swallow all errors lol

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ inputs:
1212
Set to `null` to install to the tea default (~/.tea).
1313
For GHA we default to `~/opt`.
1414
required: false
15+
srcroot:
16+
description: |
17+
Override detection of `$SRCROOT`.
18+
19+
tea normally finds your `$SRCROOT` by looking for a `.git` directory.
20+
However, if git is not installed the checkout action uses the GitHub
21+
API to download the repository.
22+
23+
You will need this if you depend on the virtual environment tea
24+
provides.
25+
1526
outputs:
1627
version:
1728
description: Your project’s version.

0 commit comments

Comments
 (0)