-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from promise/feat/author-env-variables
Add author environment variables
- Loading branch information
Showing
5 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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 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
7 changes: 7 additions & 0 deletions
7
action/test/specs/__snapshots__/ssh-custom-username-email.spec.ts.snap
This file contains 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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test custom username and email 1`] = ` | ||
"msg:Update branch-a to output generated at <sha> | ||
tree:8bf87c66655949e66937b11593cc4ae732d1f610 | ||
author:tester <[email protected]>" | ||
`; |
This file contains 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,49 @@ | ||
import { promises as fs } from 'fs'; | ||
import * as path from 'path'; | ||
import { mkdirP } from '@actions/io'; | ||
|
||
import * as util from '../util'; | ||
import { prepareTestFolders } from '../util/io'; | ||
|
||
it('Test custom username and email', async () => { | ||
const folders = await prepareTestFolders({ __filename }); | ||
|
||
// Create empty repo | ||
await util.wrappedExec('git init --bare', { cwd: folders.repoDir }); | ||
|
||
// Create dummy data | ||
await mkdirP(path.join(folders.dataDir, 'dummy')); | ||
await fs.writeFile(path.join(folders.dataDir, 'dummy', 'baz'), 'foobar'); | ||
await fs.writeFile(path.join(folders.dataDir, 'dummy', '.bat'), 'foobar'); | ||
|
||
// Run Action | ||
await util.runWithGithubEnv( | ||
path.basename(__filename), | ||
{ | ||
REPO: folders.repoUrl, | ||
BRANCH: 'branch-a', | ||
FOLDER: folders.dataDir, | ||
SSH_PRIVATE_KEY: (await fs.readFile(util.SSH_PRIVATE_KEY)).toString(), | ||
KNOWN_HOSTS_FILE: util.KNOWN_HOSTS, | ||
COMMIT_NAME: 'tester', | ||
COMMIT_EMAIL: '[email protected]', | ||
}, | ||
's0/test', | ||
{}, | ||
's0' | ||
); | ||
|
||
// Check that the log of the repo is as expected | ||
// (check tree-hash, commit message, and author) | ||
const log = ( | ||
await util.exec( | ||
'git log --pretty="format:msg:%s%ntree:%T%nauthor:%an <%ae>" branch-a', | ||
{ | ||
cwd: folders.repoDir, | ||
} | ||
) | ||
).stdout; | ||
const sha = await util.getRepoSha(); | ||
const cleanedLog = log.replace(sha, '<sha>'); | ||
expect(cleanedLog).toMatchSnapshot(); | ||
}); |