Skip to content

Commit

Permalink
use @actions/cache package;bump cmake to v3.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Sep 28, 2020
1 parent 0c94bc3 commit 446604d
Show file tree
Hide file tree
Showing 50 changed files with 57,694 additions and 27,925 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ jobs:
which cmake
cmake --version
CMAKE_VER="$(cmake --version)"
if ! [[ "$CMAKE_VER" =~ .*"3.18.0".* ]]; then
echo "ASSERTION FAILED! Instead of 3.18.0, found: "
if ! [[ "$CMAKE_VER" =~ .*"3.18.2".* ]]; then
echo "ASSERTION FAILED! Instead of 3.18.2, found: "
echo "$CMAKE_VER"
exit -1
fi
shell: bash
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ token.txt
build
__tests__/build Directory
__tests__/b
.npmrc
coverage
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[![Action Status](https://github.com/lukka/get-cmake/workflows/build-test/badge.svg)](https://github.com/lukka/get-cmake/actions)

[![Coverage Status](https://coveralls.io/repos/github/lukka/get-cmake/badge.svg?branch=master)](https://coveralls.io/github/lukka/get-cmake?branch=master)

# [The **get-cmake** action for downloading and caching CMake binaries](https://github.com/marketplace/actions/run-cmake)

Restores from cache, or downloads and caches CMake binaries **v3.18.0**.
Restores from cache, or downloads and caches CMake binaries **v3.18.2**.
Works for x64 on Linux/macOS/Windows.

Flowchart of `get-cmake`:
Expand All @@ -23,7 +25,7 @@ Flowchart of `get-cmake`:

# If you need to pin your workflow to specific version you can use the 'tag'.
- name: Get specific version CMake
uses: lukka/get-cmake@v3.17.2 ⟸ THIS IS THE ONE LINER YOU NEED
uses: lukka/get-cmake@v3.18.2 ⟸ THIS IS THE ONE LINER YOU NEED
```
## Developer Manual
Expand Down Expand Up @@ -74,12 +76,7 @@ To build, pack and test:
The software is provided as is, there is no warranty of any kind. All users are encouraged to improve the [source code](https://github.com/lukka/get-cmake) with fixes and new features.

# License
All the content, except for the `actions/cache directory and its content` in this repository is licensed under the [MIT License](LICENSE.txt).
All the content in this repository is licensed under the [MIT License](LICENSE.txt).

Copyright (c) 2020 Luca Cappa

<hr>

All content under [actions/cache](./actions/cache) directory is subject to this [LICENSE](./actions/cache/LICENSE)

Copyright (c) 2018 GitHub, Inc. and contributors
34 changes: 34 additions & 0 deletions __tests__/action_failed.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as os from 'os';
import * as cache from '@actions/cache';
import * as toolcache from '@actions/tool-cache';
import * as core from '@actions/core';
import * as getcmake from '../src/get-cmake';

jest.setTimeout(15 * 1000);

jest.mock('@actions/tool-cache');

jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

jest.spyOn(cache, 'restoreCache').mockImplementation(() => {
throw new Error();
}
);

var coreSetFailed = jest.spyOn(core, 'setFailed');
var coreError = jest.spyOn(core, 'error');
var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir');

test('testing get-cmake action failure', async () => {
process.env.RUNNER_TEMP = os.tmpdir();
await getcmake.main();
expect(coreSetFailed).toBeCalledTimes(1);
expect(coreError).toBeCalledTimes(0);
expect(toolsCacheDir).toBeCalledTimes(0);
});
34 changes: 34 additions & 0 deletions __tests__/action_succeeded.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as os from 'os';
import * as path from 'path';
import * as getcmake from '../src/get-cmake';
import * as cache from '@actions/cache';
import * as toolcache from '@actions/tool-cache';
import * as core from '@actions/core';

jest.setTimeout(15 * 1000)

jest.mock('@actions/tool-cache');

jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

jest.spyOn(cache, 'restoreCache').mockImplementation(() =>
Promise.resolve("42")
);

var coreSetFailed = jest.spyOn(core, 'setFailed');
var coreError = jest.spyOn(core, 'error');
var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir');

test('testing get-cmake action success', async () => {
process.env.RUNNER_TEMP = os.tmpdir();
await getcmake.main();
expect(coreSetFailed).toBeCalledTimes(0);
expect(coreError).toBeCalledTimes(0);
expect(toolsCacheDir).toBeCalledTimes(1);
});
45 changes: 0 additions & 45 deletions __tests__/basic.test.ts

This file was deleted.

32 changes: 32 additions & 0 deletions __tests__/cachehit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as process from 'process';
import * as os from 'os';
import * as path from 'path';
import { CMakeGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as tools from '@actions/tool-cache'


jest.setTimeout(15 * 1000)

jest.mock('@actions/tool-cache');

const cacheSaveCache = jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation(() =>
Promise.resolve("key")
);

test('testing get-cache with cache-hit...', async () => {
process.env.RUNNER_TEMP = os.tmpdir();
const getter: CMakeGetter = new CMakeGetter();
await getter.run();
expect(cacheSaveCache).toBeCalledTimes(0);
expect(cacheRestoreCache).toBeCalledTimes(1);
});
30 changes: 30 additions & 0 deletions __tests__/cachemiss.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as process from 'process';
import * as os from 'os';
import { CMakeGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';
import * as core from '@actions/core';

jest.setTimeout(15 * 1000)
jest.mock('@actions/tool-cache');

var coreSetFailed = jest.spyOn(core, 'setFailed');

const cacheSaveCache = jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation(() =>
Promise.resolve(undefined)
);

test('testing get-cache with cache-miss...', async () => {
process.env.RUNNER_TEMP = os.tmpdir();
const getter: CMakeGetter = new CMakeGetter();
await getter.run();
expect(cacheSaveCache).toBeCalledTimes(1);
expect(cacheRestoreCache).toBeCalledTimes(1);
});
28 changes: 28 additions & 0 deletions __tests__/cacherestorefailure.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as process from 'process';
import * as os from 'os';
import * as path from 'path';
import { CMakeGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';

jest.setTimeout(15 * 1000)

jest.mock('@actions/tool-cache');

jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

jest.spyOn(cache, 'restoreCache').mockImplementation(() => {
throw new Error();
}
);

test('testing get-cache with restoreCache failure', async () => {
process.env.RUNNER_TEMP = os.tmpdir();
const getter: CMakeGetter = new CMakeGetter();
await expect(getter.run()).rejects.toThrowError();
});
29 changes: 29 additions & 0 deletions __tests__/notmpdir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2020 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

import * as path from 'path';
import { CMakeGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';

const tempDirectory = path.join(__dirname, "tempDirectory");
const testScript = path.join(__dirname, '..', 'dist', 'index.js');;

jest.setTimeout(15 * 1000)

jest.mock('@actions/tool-cache');

jest.spyOn(cache, 'saveCache').mockImplementation(() =>
Promise.resolve(0)
);

jest.spyOn(cache, 'restoreCache').mockImplementation(() => {
throw new Error();
}
);

test('testing get-cache with no temporary directory failure', async () => {
delete process.env.RUNNER_TEMP;
const getter: CMakeGetter = new CMakeGetter();
await expect(getter.run()).rejects.toThrowError();
});
2 changes: 0 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ author: 'Luca Cappa https://github.com/lukka'
runs:
using: 'node12'
main: 'dist/index.js'
post: 'dist/post/index.js'
post-if: 'success()'

branding:
icon: 'terminal'
Expand Down
16 changes: 0 additions & 16 deletions actions/cache/.eslintrc.json

This file was deleted.

54 changes: 0 additions & 54 deletions actions/cache/.github/workflows/workflow.yml

This file was deleted.

Loading

0 comments on commit 446604d

Please sign in to comment.