-
Notifications
You must be signed in to change notification settings - Fork 831
Added support for GPG signing #63
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d94db22
Added support for GPG
jaredpetersen e494666
fixed setSecret
jaredpetersen 01f4422
Merge remote-tracking branch 'upstream/master'
jaredpetersen 7f23828
addressed most of the feedback
jaredpetersen 91d1667
added blurb about private key file and cleanup for hosted runners
jaredpetersen 034b7a7
forgot to run build
jaredpetersen 2d0e474
removed unecessary set secret -- it's an environment variable not a l…
jaredpetersen 4d8dc69
fixing defaults
jaredpetersen 012c21e
fixed gpg passhprase default
jaredpetersen 36bb906
removed test timeout
jaredpetersen ac9630f
cleaned up description for how the private key is stored
jaredpetersen 38e0c8b
improved cleanup error message
jaredpetersen 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
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,56 @@ | ||
| import path = require('path'); | ||
| import io = require('@actions/io'); | ||
| import exec = require('@actions/exec'); | ||
|
|
||
| jest.mock('@actions/exec', () => { | ||
| return { | ||
| exec: jest.fn() | ||
| }; | ||
| }); | ||
|
|
||
| const tempDir = path.join(__dirname, 'runner', 'temp'); | ||
| process.env['RUNNER_TEMP'] = tempDir; | ||
|
|
||
| import gpg = require('../src/gpg'); | ||
|
|
||
| describe('gpg tests', () => { | ||
| beforeEach(async () => { | ||
| await io.mkdirP(tempDir); | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| try { | ||
| await io.rmRF(tempDir); | ||
| } catch { | ||
| console.log('Failed to remove test directories'); | ||
| } | ||
| }); | ||
|
|
||
| describe('importKey', () => { | ||
| it('attempts to import private key and returns null key id on failure', async () => { | ||
| const privateKey = 'KEY CONTENTS'; | ||
| const keyId = await gpg.importKey(privateKey); | ||
|
|
||
| expect(keyId).toBeNull(); | ||
|
|
||
| expect(exec.exec).toHaveBeenCalledWith( | ||
| 'gpg', | ||
| expect.anything(), | ||
| expect.anything() | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('deleteKey', () => { | ||
| it('deletes private key', async () => { | ||
| const keyId = 'asdfhjkl'; | ||
| await gpg.deleteKey(keyId); | ||
|
|
||
| expect(exec.exec).toHaveBeenCalledWith( | ||
| 'gpg', | ||
| expect.anything(), | ||
| expect.anything() | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
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,61 @@ | ||
| import path = require('path'); | ||
|
|
||
| const env = process.env; | ||
|
|
||
| describe('util tests', () => { | ||
| beforeEach(() => { | ||
| const tempEnv = Object.assign({}, env); | ||
| delete tempEnv.RUNNER_TEMP; | ||
| delete tempEnv.USERPROFILE; | ||
| process.env = tempEnv; | ||
| Object.defineProperty(process, 'platform', {value: 'linux'}); | ||
| }); | ||
|
|
||
| describe('getTempDir', () => { | ||
| it('gets temp dir using env', () => { | ||
| process.env['RUNNER_TEMP'] = 'defaulttmp'; | ||
| const util = require('../src/util'); | ||
|
|
||
| const tempDir = util.getTempDir(); | ||
|
|
||
| expect(tempDir).toEqual(process.env['RUNNER_TEMP']); | ||
| }); | ||
|
|
||
| it('gets temp dir for windows using userprofile', () => { | ||
| Object.defineProperty(process, 'platform', {value: 'win32'}); | ||
| process.env['USERPROFILE'] = 'winusertmp'; | ||
| const util = require('../src/util'); | ||
|
|
||
| const tempDir = util.getTempDir(); | ||
|
|
||
| expect(tempDir).toEqual( | ||
| path.join(process.env['USERPROFILE'], 'actions', 'temp') | ||
| ); | ||
| }); | ||
|
|
||
| it('gets temp dir for windows using c drive', () => { | ||
| Object.defineProperty(process, 'platform', {value: 'win32'}); | ||
| const util = require('../src/util'); | ||
|
|
||
| const tempDir = util.getTempDir(); | ||
|
|
||
| expect(tempDir).toEqual(path.join('C:\\', 'actions', 'temp')); | ||
| }); | ||
|
|
||
| it('gets temp dir for mac', () => { | ||
| Object.defineProperty(process, 'platform', {value: 'darwin'}); | ||
| const util = require('../src/util'); | ||
|
|
||
| const tempDir = util.getTempDir(); | ||
|
|
||
| expect(tempDir).toEqual(path.join('/Users', 'actions', 'temp')); | ||
| }); | ||
|
|
||
| it('gets temp dir for linux', () => { | ||
| const util = require('../src/util'); | ||
| const tempDir = util.getTempDir(); | ||
|
|
||
| expect(tempDir).toEqual(path.join('/home', 'actions', 'temp')); | ||
| }); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.