Skip to content

Commit 8bd5fe5

Browse files
Merge pull request #374 from JarvusInnovations/feat/remove-habitat
feat(action): remove habitat dependence
2 parents 63d920a + 3edb02d commit 8bd5fe5

File tree

13 files changed

+116
-581
lines changed

13 files changed

+116
-581
lines changed

.github/workflows/pr-test.yml

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,58 @@ name: 'PR: Test'
22

33
on: pull_request
44

5-
env:
6-
HAB_LICENSE: accept-no-persist
7-
85
jobs:
9-
pr-test:
6+
test-cli:
7+
8+
runs-on: ubuntu-latest
9+
steps:
10+
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: '20.x'
14+
15+
- uses: actions/checkout@v4
16+
17+
- name: Configure git identity
18+
run: |
19+
git config user.name "Github Action $GITHUB_JOB"
20+
git config user.email "$(whoami)@$(uname -n)"
21+
22+
- run: npm install
23+
24+
- name: 'Test projection: github-action-projector'
25+
run: node bin/cli.js project --no-cache-from --cache-to=origin github-action-projector
26+
27+
- name: 'Test projection: docs-site'
28+
run: node bin/cli.js project --no-cache-from --cache-to=origin docs-site
29+
30+
test-action:
1031

1132
runs-on: ubuntu-latest
1233
steps:
1334

14-
- name: 'Initialize Chef Habitat environment'
15-
uses: JarvusInnovations/habitat-action@action/v1
16-
with:
17-
deps: |
18-
core/hab-plan-build
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: '20.x'
1938

20-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v4
2140

22-
- name: 'Generate origin key: jarvus'
23-
run: hab origin key generate jarvus
41+
- run: npm install
42+
working-directory: github-actions/projector
2443

25-
- name: Build jarvus/hologit
26-
run: hab pkg exec core/hab-plan-build hab-plan-build .
44+
- name: Install local hologit
45+
run: |
46+
npm install
47+
npm link
2748
28-
- name: 'Test projection: docs-site'
29-
run: hab pkg exec jarvus/hologit/0.0.1 git-holo project --no-cache-from --cache-to=origin docs-site
49+
- name: 'Test projection action: github-action-projector'
50+
uses: ./github-actions/projector/
51+
with:
52+
holobranch: github-action-projector
53+
cache: false
3054

31-
- name: 'Test projection: github-action-projector'
32-
run: hab pkg exec jarvus/hologit/0.0.1 git-holo project --no-cache-from --cache-to=origin github-action-projector
55+
- name: 'Test projection action: docs-site'
56+
uses: ./github-actions/projector/
57+
with:
58+
holobranch: docs-site
59+
cache: false

.github/workflows/publish-npm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212

13-
- uses: actions/setup-node@v1
13+
- uses: actions/setup-node@v4
1414
with:
15-
node-version: '14.x'
15+
node-version: '20.x'
1616
registry-url: 'https://registry.npmjs.org'
1717

1818
- uses: actions/checkout@v2

.holo/branches/docs-site.lenses/mkdocs.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[hololens]
2-
package = "holo/lens-mkdocs"
2+
container = "ghcr.io/hologit/lenses/mkdocs:latest"
3+
4+
[hololens.mkdocs]
35
requirements = [
46
"mkdocs-material",
57
"mkdocs-awesome-pages-plugin",

.holo/branches/github-action-projector.lenses/npm-install.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[hololens]
2-
package = "holo/lens-npm-install/16"
2+
container = "ghcr.io/hologit/lenses/npm-install:latest"
33

44
[hololens.input]
55
files = [

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 20.19.3

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,20 @@
308308
"4e78f11a2d8ba8cc462e8e6ace46d2a71d002774",
309309
"da4534092d66f23e29c69e485f544f88636639c0"
310310
]
311+
},
312+
{
313+
"type": "node",
314+
"request": "launch",
315+
"name": "github-actions/projector",
316+
"program": "${workspaceFolder}/github-actions/projector/index.js",
317+
"cwd": "${workspaceFolder}/.scratch/test-wd",
318+
"env": {
319+
"GITHUB_ACTOR": "github-action",
320+
"GITHUB_REPOSITORY": "JarvusInnovations/hologit",
321+
"GITHUB_REF": "refs/heads/develop",
322+
"INPUT_HOLOBRANCH": "github-action-projector",
323+
"INPUT_REF": "refs/heads/develop"
324+
}
311325
}
312326
]
313327
}

github-actions/projector/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
commit-to:
1515
description: 'Name of branch/ref to optionally commit result to'
1616
required: false
17+
cache:
18+
description: 'Whether to use cache (true/false)'
19+
required: false
20+
default: 'true'
1721
outputs:
1822
tree:
1923
description: 'Tree hash for last projection'
@@ -22,4 +26,3 @@ outputs:
2226
runs:
2327
using: 'node20'
2428
main: 'index.js'
25-
post: 'post.js'

github-actions/projector/index.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const core = require('@actions/core');
22
const { exec } = require('@actions/exec');
3-
const io = require('@actions/io');
43

54

65
// gather input
@@ -12,6 +11,7 @@ const fetch = core.getInput('fetch') !== 'false';
1211
const holobranch = core.getInput('holobranch', { required: true });
1312
const lens = core.getInput('lens');
1413
const commitTo = core.getInput('commit-to', { required: false });
14+
const cache = core.getInput('cache') !== 'false';
1515
const commitToRef = commitTo
1616
? (
1717
commitTo == 'HEAD' || commitTo.startsWith('refs/')
@@ -28,22 +28,21 @@ try {
2828
}
2929

3030
async function run() {
31-
try {
32-
await require('habitat-action');
33-
} catch (err) {
34-
core.setFailed(`Failed to run habitat-action: ${err.message}`);
35-
return;
36-
}
37-
31+
// check if git-holo is already installed
32+
const isInstalled = await exec('which', ['git-holo'], { ignoreReturnCode: true, silent: true }) === 0;
3833

39-
try {
40-
core.startGroup('Installing Jarvus Hologit');
41-
await exec('hab pkg install jarvus/hologit');
42-
} catch (err) {
43-
core.setFailed(`Failed to install Jarvus Hologit: ${err.message}`);
44-
return;
45-
} finally {
46-
core.endGroup();
34+
if (isInstalled) {
35+
core.info('Hologit is already installed, skipping npm install');
36+
} else {
37+
try {
38+
core.startGroup('Installing Jarvus Hologit');
39+
await exec('npm install -g hologit');
40+
} catch (err) {
41+
core.setFailed(`Failed to install Jarvus Hologit: ${err.message}`);
42+
return;
43+
} finally {
44+
core.endGroup();
45+
}
4746
}
4847

4948

@@ -151,11 +150,15 @@ async function run() {
151150
core.startGroup(`Projecting holobranch: ${holobranch}`);
152151
const projectionArgs = [
153152
holobranch,
154-
`--ref=${ref}`,
155-
'--cache-from=origin',
156-
'--cache-to=origin'
153+
`--ref=${ref}`
157154
];
158155

156+
if (cache) {
157+
projectionArgs.push('--cache-from=origin', '--cache-to=origin');
158+
} else {
159+
projectionArgs.push('--no-cache-from', '--no-cache-to');
160+
}
161+
159162
if (debug) {
160163
projectionArgs.push('--debug');
161164
}
@@ -209,17 +212,15 @@ async function run() {
209212
}
210213

211214
async function gitExec(command, args = [], options = {}) {
212-
return exec('hab pkg exec jarvus/hologit', [
213-
'git',
215+
return exec('git', [
214216
'--no-pager',
215217
command,
216218
...args
217219
], options);
218220
}
219221

220222
async function gitExecOutput(command, args = [], options = {}) {
221-
return execOutput('hab pkg exec jarvus/hologit', [
222-
'git',
223+
return execOutput('git', [
223224
'--no-pager',
224225
command,
225226
...args

0 commit comments

Comments
 (0)