Skip to content

Commit

Permalink
Add Ref and Commit outputs
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Comellini <luca.com@gmail.com>
  • Loading branch information
lucacome committed May 7, 2024
1 parent 44c2b7a commit 0f7dff8
Show file tree
Hide file tree
Showing 13 changed files with 10,501 additions and 30,214 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,32 @@ jobs:
uses: actions/checkout@v3
with:
path: v3

test-output:
runs-on: ubuntu-latest
steps:
# Clone this repo
- name: Checkout
uses: actions/checkout@v3

# Basic checkout using git
- name: Checkout basic
id: checkout
uses: ./
with:
ref: test-data/v2/basic

# Verify output
- name: Verify output
run: |
echo "Commit: ${{ steps.checkout.outputs.commit }}"
echo "Ref: ${{ steps.checkout.outputs.ref }}"
if [ "${{ steps.checkout.outputs.ref }}" != "test-data/v2/basic" ]; then
echo "Expected ref to be test-data/v2/basic"
exit 1
fi
# needed to make checkout post cleanup succeed
- name: Fix Checkout
uses: actions/checkout@v3
8 changes: 4 additions & 4 deletions __test__/git-auth-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ describe('git-auth-helper tests', () => {

// Mock fs.promises.readFile
const realReadFile = fs.promises.readFile
jest
.spyOn(fs.promises, 'readFile')
.mockImplementation(async (file: any, options: any): Promise<Buffer> => {
jest.spyOn(fs.promises, 'readFile').mockImplementation(
async (file: any, options: any): Promise<Buffer> => {
const userKnownHostsPath = path.join(
os.homedir(),
'.ssh',
Expand All @@ -182,7 +181,8 @@ describe('git-auth-helper tests', () => {
}

return await realReadFile(file, options)
})
}
)

// Act
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
Expand Down
4 changes: 2 additions & 2 deletions __test__/ref-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ let git: IGitCommandManager

describe('ref-helper tests', () => {
beforeEach(() => {
git = {} as unknown as IGitCommandManager
git = ({} as unknown) as IGitCommandManager
})

it('getCheckoutInfo requires git', async () => {
const git = null as unknown as IGitCommandManager
const git = (null as unknown) as IGitCommandManager
try {
await refHelper.getCheckoutInfo(git, 'refs/heads/my/branch', commit)
throw new Error('Should not reach here')
Expand Down
2 changes: 1 addition & 1 deletion __test__/retry-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('retry-helper tests', () => {

it('all attempts fail succeeds', async () => {
let attempts = 0
let error: Error = null as unknown as Error
let error: Error = (null as unknown) as Error
try {
await retryHelper.execute(() => {
throw new Error(`some error ${++attempts}`)
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ inputs:
github-server-url:
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
required: false
outputs:
ref:
description: 'The branch, tag or SHA that was checked out'
commit:
description: 'The commit SHA that was checked out'
runs:
using: node20
main: dist/index.js
Expand Down
Loading

0 comments on commit 0f7dff8

Please sign in to comment.