-
Notifications
You must be signed in to change notification settings - Fork 1.5k
start #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
start #1
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# runtime dependencies are checked in | ||
# dev dependencies are *not* checked in | ||
node_modules/.bin | ||
node_modules/typescript | ||
node_modules/@types | ||
node_modules/prettier | ||
__tests__/runner/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": false, | ||
"arrowParens": "avoid", | ||
"parser": "typescript" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import io = require('@actions/io'); | ||
import fs = require('fs'); | ||
import os = require('os'); | ||
import path = require('path'); | ||
|
||
const toolDir = path.join(__dirname, 'runner', 'tools'); | ||
const tempDir = path.join(__dirname, 'runner', 'temp'); | ||
|
||
process.env['RUNNER_TOOLSDIRECTORY'] = toolDir; | ||
process.env['RUNNER_TEMPDIRECTORY'] = tempDir; | ||
import * as installer from '../src/installer'; | ||
|
||
describe('installer tests', () => { | ||
beforeAll(() => {}); | ||
beforeAll(async () => { | ||
await io.rmRF(toolDir); | ||
await io.rmRF(tempDir); | ||
}); | ||
|
||
it('Acquires version of node if no matching version is installed', async () => { | ||
await installer.getNode('10.16.0'); | ||
const nodeDir = path.join(toolDir, 'node', '10.16.0', os.arch()); | ||
|
||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); | ||
}, 100000); | ||
|
||
if (process.platform === 'win32') { | ||
it('Falls back to backup location if first one doesnt contain correct version', async () => { | ||
await installer.getNode('5.10.1'); | ||
const nodeDir = path.join(toolDir, 'node', '5.10.1', os.arch()); | ||
|
||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); | ||
}, 100000); | ||
|
||
it('Falls back to third location if second one doesnt contain correct version', async () => { | ||
await installer.getNode('0.12.18'); | ||
const nodeDir = path.join(toolDir, 'node', '0.12.18', os.arch()); | ||
|
||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); | ||
}, 100000); | ||
} | ||
|
||
it('Throws if no location contains correct node version', async () => { | ||
let thrown = false; | ||
try { | ||
await installer.getNode('1000'); | ||
} catch { | ||
thrown = true; | ||
} | ||
expect(thrown).toBe(true); | ||
}); | ||
|
||
it('Acquires version of node with long paths', async () => { | ||
const toolpath = await installer.getNode('8.8.1'); | ||
const nodeDir = path.join(toolDir, 'node', '8.8.1', os.arch()); | ||
|
||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true); | ||
}, 100000); | ||
|
||
it('Uses version of node installed in cache', async () => { | ||
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); | ||
await io.mkdirP(nodeDir); | ||
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await installer.getNode('250.0.0'); | ||
return; | ||
}); | ||
|
||
it('Doesnt use version of node that was only partially installed in cache', async () => { | ||
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); | ||
await io.mkdirP(nodeDir); | ||
let thrown = false; | ||
try { | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await installer.getNode('251.0.0'); | ||
} catch { | ||
thrown = true; | ||
} | ||
expect(thrown).toBe(true); | ||
return; | ||
}); | ||
|
||
it('Resolves semantic versions of node installed in cache', async () => { | ||
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch()); | ||
await io.mkdirP(nodeDir); | ||
fs.writeFileSync(`${nodeDir}.complete`, 'hello'); | ||
// These will throw if it doesn't find it in the cache (because no such version exists) | ||
await installer.getNode('250.0.0'); | ||
await installer.getNode('250'); | ||
await installer.getNode('250.0'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Contributors | ||
|
||
|
||
# Checkin | ||
|
||
- Do checkin source (src) | ||
- Do checkin build output (lib) | ||
- Do checkin runtime node_modules | ||
- Do not checkin | ||
|
||
# Adding a dev dependency | ||
|
||
Remember to update .gitignore. | ||
|
||
# Updating toolkit dependency | ||
|
||
Until released publically, update tgz packages in toolkit |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
testRunner: 'jest-circus/runner', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
verbose: true | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't have to be part of this initial PR, but maybe we should just webpack as part of our build process. Then we can just ignore node modules
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note also - this also doesn't really work to not check in dev dependencies. While this doesn't check in the top level dev-deps, nested dependencies will still get checked in. For example, Prettier alone has ~60 dependencies all of which get checked in (not to mention the dependencies of those dependencies).
I think webpack is probably the best path forward here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we doing this to avoid having to
npm install
the production dependencies of this tool? If so, there are a few options for vendoring in dependencies that we already use at GitHub. If you can give me a sense of the goal with this, I can advise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runner will run the action from the github graph at runtime per the execution model. That is, it will get the targz of that ref and run it.
Dependencies are vendored in as you noted.
@damccorm - regarding dev dependencies, you can use
npm prune
before you publish (push).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool - didn't know about
npm prune
. It looks like that handles all devDependencies though, so we probably don't need those listed in gitignore. It also might be good to enforce that with something like huskyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #5 proposing using husky