Loading .github/workflows/test.yml +22 −1 Changes for .github/workflows/test.yml: 22 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ jobs: steps: # Clone this repo - name: Checkout uses: actions/checkout@v1 # todo: switch to V2 uses: actions/checkout@v2-beta # Basic checkout - name: Basic checkout Loading Loading @@ -81,3 +81,24 @@ jobs: - name: Verify LFS shell: bash run: __test__/verify-lfs.sh test-job-container: runs-on: ubuntu-latest container: pstauffer/curl:latest steps: # Clone this repo # todo: after v2-beta contains the latest changes, switch this to "uses: actions/checkout@v2-beta". Also switch to "alpine:latest" - name: Checkout run: | curl --location --user token:${{ github.token }} --output checkout.tar.gz https://api.github.com/repos/actions/checkout/tarball/${{ github.sha }} tar -xzf checkout.tar.gz mv */* ./ # Basic checkout - name: Basic checkout uses: ./ with: ref: test-data/v2/basic path: basic - name: Verify basic run: __test__/verify-basic.sh --archive README.md +3 −1 Changes for README.md: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Refer [here](https://help.github.com/en/articles/events-that-trigger-workflows) # What's new - Improved fetch performance - The default behavior now fetches only the SHA being checked-out - The default behavior now fetches only the commit being checked-out - Script authenticated git commands - Persists `with.token` in the local git config - Enables your scripts to run authenticated git commands Loading @@ -25,6 +25,8 @@ Refer [here](https://help.github.com/en/articles/events-that-trigger-workflows) - Improved layout - `with.path` is always relative to `github.workspace` - Aligns better with container actions, where `github.workspace` gets mapped in - Fallback to REST API download - When Git 2.18 or higher is not in the PATH, the REST API will be used to download the files - Removed input `submodules` Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous versions. Loading __test__/retry-helper.test.ts +88 Changes for __test__/retry-helper.test.ts: 88 added lines, 0 removed lines. Original line number Diff line number Diff line const mockCore = jest.genMockFromModule('@actions/core') as any mockCore.info = (message: string) => { info.push(message) } let info: string[] let retryHelper: any describe('retry-helper tests', () => { beforeAll(() => { // Mocks jest.setMock('@actions/core', mockCore) // Now import const retryHelperModule = require('../lib/retry-helper') retryHelper = new retryHelperModule.RetryHelper(3, 0, 0) }) beforeEach(() => { // Reset info info = [] }) afterAll(() => { // Reset modules jest.resetModules() }) it('first attempt succeeds', async () => { const actual = await retryHelper.execute(async () => { return 'some result' }) expect(actual).toBe('some result') expect(info).toHaveLength(0) }) it('second attempt succeeds', async () => { let attempts = 0 const actual = await retryHelper.execute(() => { if (++attempts == 1) { throw new Error('some error') } return Promise.resolve('some result') }) expect(attempts).toBe(2) expect(actual).toBe('some result') expect(info).toHaveLength(2) expect(info[0]).toBe('some error') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) }) it('third attempt succeeds', async () => { let attempts = 0 const actual = await retryHelper.execute(() => { if (++attempts < 3) { throw new Error(`some error ${attempts}`) } return Promise.resolve('some result') }) expect(attempts).toBe(3) expect(actual).toBe('some result') expect(info).toHaveLength(4) expect(info[0]).toBe('some error 1') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) expect(info[2]).toBe('some error 2') expect(info[3]).toMatch(/Waiting .+ seconds before trying again/) }) it('all attempts fail succeeds', async () => { let attempts = 0 let error: Error = (null as unknown) as Error try { await retryHelper.execute(() => { throw new Error(`some error ${++attempts}`) }) } catch (err) { error = err } expect(error.message).toBe('some error 3') expect(attempts).toBe(3) expect(info).toHaveLength(4) expect(info[0]).toBe('some error 1') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) expect(info[2]).toBe('some error 2') expect(info[3]).toMatch(/Waiting .+ seconds before trying again/) }) }) __test__/verify-basic.sh +16 −2 Changes for __test__/verify-basic.sh: 16 added lines, 2 removed lines. Original line number Diff line number Diff line #!/bin/bash #!/bin/sh if [ ! -f "./basic/basic-file.txt" ]; then echo "Expected basic file does not exist" exit 1 fi if [ "$1" = "--archive" ]; then # Verify no .git folder if [ -d "./basic/.git" ]; then echo "Did not expect ./basic/.git folder to exist" exit 1 fi else # Verify .git folder if [ ! -d "./basic/.git" ]; then echo "Expected ./basic/.git folder to exist" exit 1 fi # Verify auth token cd basic git fetch No newline at end of file git fetch --no-tags --depth=1 origin +refs/heads/master:refs/remotes/origin/master fi dist/index.js +3455 −517 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
.github/workflows/test.yml +22 −1 Changes for .github/workflows/test.yml: 22 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ jobs: steps: # Clone this repo - name: Checkout uses: actions/checkout@v1 # todo: switch to V2 uses: actions/checkout@v2-beta # Basic checkout - name: Basic checkout Loading Loading @@ -81,3 +81,24 @@ jobs: - name: Verify LFS shell: bash run: __test__/verify-lfs.sh test-job-container: runs-on: ubuntu-latest container: pstauffer/curl:latest steps: # Clone this repo # todo: after v2-beta contains the latest changes, switch this to "uses: actions/checkout@v2-beta". Also switch to "alpine:latest" - name: Checkout run: | curl --location --user token:${{ github.token }} --output checkout.tar.gz https://api.github.com/repos/actions/checkout/tarball/${{ github.sha }} tar -xzf checkout.tar.gz mv */* ./ # Basic checkout - name: Basic checkout uses: ./ with: ref: test-data/v2/basic path: basic - name: Verify basic run: __test__/verify-basic.sh --archive
README.md +3 −1 Changes for README.md: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Refer [here](https://help.github.com/en/articles/events-that-trigger-workflows) # What's new - Improved fetch performance - The default behavior now fetches only the SHA being checked-out - The default behavior now fetches only the commit being checked-out - Script authenticated git commands - Persists `with.token` in the local git config - Enables your scripts to run authenticated git commands Loading @@ -25,6 +25,8 @@ Refer [here](https://help.github.com/en/articles/events-that-trigger-workflows) - Improved layout - `with.path` is always relative to `github.workspace` - Aligns better with container actions, where `github.workspace` gets mapped in - Fallback to REST API download - When Git 2.18 or higher is not in the PATH, the REST API will be used to download the files - Removed input `submodules` Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous versions. Loading
__test__/retry-helper.test.ts +88 Changes for __test__/retry-helper.test.ts: 88 added lines, 0 removed lines. Original line number Diff line number Diff line const mockCore = jest.genMockFromModule('@actions/core') as any mockCore.info = (message: string) => { info.push(message) } let info: string[] let retryHelper: any describe('retry-helper tests', () => { beforeAll(() => { // Mocks jest.setMock('@actions/core', mockCore) // Now import const retryHelperModule = require('../lib/retry-helper') retryHelper = new retryHelperModule.RetryHelper(3, 0, 0) }) beforeEach(() => { // Reset info info = [] }) afterAll(() => { // Reset modules jest.resetModules() }) it('first attempt succeeds', async () => { const actual = await retryHelper.execute(async () => { return 'some result' }) expect(actual).toBe('some result') expect(info).toHaveLength(0) }) it('second attempt succeeds', async () => { let attempts = 0 const actual = await retryHelper.execute(() => { if (++attempts == 1) { throw new Error('some error') } return Promise.resolve('some result') }) expect(attempts).toBe(2) expect(actual).toBe('some result') expect(info).toHaveLength(2) expect(info[0]).toBe('some error') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) }) it('third attempt succeeds', async () => { let attempts = 0 const actual = await retryHelper.execute(() => { if (++attempts < 3) { throw new Error(`some error ${attempts}`) } return Promise.resolve('some result') }) expect(attempts).toBe(3) expect(actual).toBe('some result') expect(info).toHaveLength(4) expect(info[0]).toBe('some error 1') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) expect(info[2]).toBe('some error 2') expect(info[3]).toMatch(/Waiting .+ seconds before trying again/) }) it('all attempts fail succeeds', async () => { let attempts = 0 let error: Error = (null as unknown) as Error try { await retryHelper.execute(() => { throw new Error(`some error ${++attempts}`) }) } catch (err) { error = err } expect(error.message).toBe('some error 3') expect(attempts).toBe(3) expect(info).toHaveLength(4) expect(info[0]).toBe('some error 1') expect(info[1]).toMatch(/Waiting .+ seconds before trying again/) expect(info[2]).toBe('some error 2') expect(info[3]).toMatch(/Waiting .+ seconds before trying again/) }) })
__test__/verify-basic.sh +16 −2 Changes for __test__/verify-basic.sh: 16 added lines, 2 removed lines. Original line number Diff line number Diff line #!/bin/bash #!/bin/sh if [ ! -f "./basic/basic-file.txt" ]; then echo "Expected basic file does not exist" exit 1 fi if [ "$1" = "--archive" ]; then # Verify no .git folder if [ -d "./basic/.git" ]; then echo "Did not expect ./basic/.git folder to exist" exit 1 fi else # Verify .git folder if [ ! -d "./basic/.git" ]; then echo "Expected ./basic/.git folder to exist" exit 1 fi # Verify auth token cd basic git fetch No newline at end of file git fetch --no-tags --depth=1 origin +refs/heads/master:refs/remotes/origin/master fi