Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ecampidoglio committed Jan 20, 2025
1 parent a04a24a commit a096084
Show file tree
Hide file tree
Showing 15 changed files with 26,708 additions and 6,699 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Install the .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Run a specific Cake script
uses: ./
with:
Expand Down Expand Up @@ -79,7 +83,7 @@ jobs:
uses: ./
with:
cake-bootstrap: auto
cake-version: 1.0.0
cake-version: 1.3.0
script-path: ${{ env.script-directory }}/module.cake
- name: Remove the tools directory
run: rm -rf ${{ env.tools-directory }}
Expand All @@ -88,7 +92,7 @@ jobs:
uses: ./
with:
cake-bootstrap: auto
cake-version: 0.38.5
cake-version: 0.5.0
script-path: ${{ env.script-directory }}/build.cake
target: Successful-Task
- name: Remove the tools directory
Expand All @@ -98,7 +102,7 @@ jobs:
uses: ./
with:
cake-bootstrap: explicit
cake-version: 1.0.0
cake-version: 1.3.0
script-path: ${{ env.script-directory }}/module.cake
- name: Remove the tools directory
run: rm -rf ${{ env.tools-directory }}
Expand All @@ -107,7 +111,7 @@ jobs:
uses: ./
with:
cake-bootstrap: explicit
cake-version: 0.38.5
cake-version: 0.5.0
script-path: ${{ env.script-directory }}/module.cake
- name: Remove the tools directory
run: rm -rf ${{ env.tools-directory }}
Expand All @@ -116,14 +120,14 @@ jobs:
uses: ./
with:
cake-bootstrap: skip
cake-version: 1.0.0
cake-version: 1.3.0
script-path: ${{ env.script-directory }}/build.cake
target: Successful-Task
- name: Run skip bootstrapping of Cake modules (Cake < 1.0.0)
uses: ./
with:
cake-bootstrap: skip
cake-version: 0.38.5
cake-version: 0.5.0
script-path: ${{ env.script-directory }}/build.cake
target: Successful-Task
- name: Run with a specific verbosity level
Expand Down
10 changes: 5 additions & 5 deletions __tests__/cake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('When running a script successfully using the global Cake tool', () =>
const fakeWhich = which as jest.MockedFunction<typeof which>;
const fakeExec = exec as jest.MockedFunction<typeof exec>;

beforeAll(async () => {
beforeAll(() => {
fakeWhich.mockReturnValue(Promise.resolve('/usr/bin/dotnet-cake'));
fakeExec.mockReturnValue(Promise.resolve(0));
});
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('When running a script successfully using the global Cake tool', () =>
describe('When running a script successfully using the local Cake tool', () => {
const fakeExec = exec as jest.MockedFunction<typeof exec>;

beforeAll(async () => {
beforeAll(() => {
fakeExec.mockReturnValue(Promise.resolve(0));
});

Expand Down Expand Up @@ -126,7 +126,7 @@ describe('When failing to run a script using the local Cake tool', () => {
describe('When bootstrapping a script successfully using the local Cake tool', () => {
const fakeExec = exec as jest.MockedFunction<typeof exec>;

beforeAll(async () => {
beforeAll(() => {
fakeExec.mockReturnValue(Promise.resolve(0));
});

Expand Down Expand Up @@ -156,7 +156,7 @@ describe('When failing to bootstrap a script using the local Cake tool', () => {
describe('When running a script successfully using the tool manifest', () => {
const fakeExec = exec as jest.MockedFunction<typeof exec>;

beforeAll(async () => {
beforeAll(() => {
fakeExec.mockReturnValue(Promise.resolve(0));
});

Expand Down Expand Up @@ -197,7 +197,7 @@ describe('When running a Cake Frosting project successfully', () => {
const fakeExec = exec as jest.MockedFunction<typeof exec>;
const fakeToolsDirectory = new ToolsDirectory();

beforeAll(async () => {
beforeAll(() => {
fakeExec.mockReturnValue(Promise.resolve(0));
});

Expand Down
36 changes: 18 additions & 18 deletions __tests__/cakeRelease.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import * as http from '@actions/http-client';
import * as cakeRelease from '../src/cakeRelease';

describe('When retrieving the latest Cake version', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 200,
result: {
tag_name: 'v1.0.0'
},
headers: {}
}));
});
});

test('it should return the latest version number from GitHub', async () => {
Expand All @@ -20,16 +20,16 @@ describe('When retrieving the latest Cake version', () => {
});

describe('When retrieving the latest Cake version without the \'v\' prefix', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 200,
result: {
tag_name: '1.0.0'
},
headers: {}
}));
});
});

test('it should return the latest version number from GitHub', async () => {
Expand All @@ -38,14 +38,14 @@ describe('When retrieving the latest Cake version without the \'v\' prefix', ()
});

describe('When failing to retrieve the latest Cake version due to a GitHub error', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 500,
result: {},
headers: {}
}));
});
});

test('it should return null', async () => {
Expand All @@ -60,14 +60,14 @@ describe('When failing to retrieve the latest Cake version due to a GitHub error
});

describe('When failing to retrieve the latest Cake version due to an empty response from GitHub', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 200,
result: {},
headers: {}
}));
});
});

test('it should return null', async () => {
Expand All @@ -76,16 +76,16 @@ describe('When failing to retrieve the latest Cake version due to an empty respo
});

describe('When failing to retrieve the latest Cake version due to a missing tag name in the GitHub response', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 200,
result: {
tag_name: null
},
headers: {}
}));
});
});

test('it should return null', async () => {
Expand All @@ -94,16 +94,16 @@ describe('When failing to retrieve the latest Cake version due to a missing tag
});

describe('When failing to retrieve the latest Cake version due to an empty tag name in the GitHub response', () => {
beforeAll(async () => {
beforeAll(() => {
jest
.spyOn(http.HttpClient.prototype, 'getJson')
.mockImplementation(async () => ({
.mockResolvedValue({
statusCode: 200,
result: {
tag_name: ''
},
headers: {}
}));
});
});

test('it should return null', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/cakeTool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('When installing the Cake Tool based on the tool manifest', () => {
expect(fakeRestoreTool).toHaveBeenCalled();
});

test('it should not explicitly install any local tools', async () => {
test('it should not explicitly install any local tools', () => {
expect(fakeInstallLocalTool).not.toHaveBeenCalled();
});
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/dotnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describe('When installing a local tool in a directory where it already exists',
fakeExec.mockReturnValue(Promise.resolve(0));
});

test('it should not attempt to install the specified tool in the same directory', () => {
dotnet.installLocalTool('The.Tool', 'dotnet-tool', directoryWithTool);
test('it should not attempt to install the specified tool in the same directory', async () => {
await dotnet.installLocalTool('The.Tool', 'dotnet-tool', directoryWithTool);
expect(fakeExec).not.toHaveBeenCalledWith(
'dotnet tool install',
['--tool-path', directoryWithTool.path, 'The.Tool']);
Expand Down
6 changes: 4 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('When running the action without any input arguments', () => {

test('it should create the tools directory', async () => {
await run();
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(fakeToolsDirectory.prototype.create).toHaveBeenCalled();
});

Expand Down Expand Up @@ -276,7 +277,7 @@ describe('When the script fails with an Error object', () => {
const fakeRunScript = cake.runScript as jest.MockedFunction<typeof cake.runScript>;

beforeAll(() => {
fakeRunScript.mockImplementation(async () => {
fakeRunScript.mockImplementation(() => {
throw new Error('the error message');
});
});
Expand All @@ -292,7 +293,8 @@ describe('When the script fails with a string', () => {
const fakeRunScript = cake.runScript as jest.MockedFunction<typeof cake.runScript>;

beforeAll(() => {
fakeRunScript.mockImplementation(async () => {
fakeRunScript.mockImplementation(() => {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw 'the error message';
});
});
Expand Down
Loading

0 comments on commit a096084

Please sign in to comment.