Skip to content

Commit

Permalink
fixes for:
Browse files Browse the repository at this point in the history
-telemetry
-jobstatus
-vcpkgconfjson
  • Loading branch information
lukka committed Jan 30, 2022
1 parent 45ca959 commit 7b25951
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 193 deletions.
46 changes: 26 additions & 20 deletions README.md
Expand Up @@ -59,7 +59,7 @@ jobs:
# to install the packages when `run-cmake` runs, no packages are installed at
# this time.
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v10 # Always specify the specific _version_ of the
uses: lukka/run-vcpkg@v10.1 # Always specify the specific _version_ of the
# action you need, `v10` in this case to stay up
# to date with fixes on v10 branch.
#with:
Expand Down Expand Up @@ -100,9 +100,14 @@ jobs:
buildPreset: 'ninja-multi-vcpkg'

#env:
# VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} # [OPTIONAL] Define the vcpkg's triplet
# you want to enforce, otherwise the default one for the hosting system will be
# automatically choosen (x64 is the default on all platforms, e.g. x64-osx).
# By default the action disables vcpkg's telemetry by defining VCPKG_DISABLE_METRICS.
# This behavior can be disabled by defining `VCPKG_ENABLE_METRICS` as follows.
# VCPKG_ENABLE_METRICS: 1
#
# [OPTIONAL] Define the vcpkg's triplet you want to enforce, otherwise the default one
# for the hosting system will be automatically choosen (x64 is the default on all platforms,
# e.g. `x64-osx`).
# VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
```

## Action reference: all input/output parameters
Expand All @@ -120,64 +125,65 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-vcpkg/
│ - platform and OS │ - `vcpkgGitCommitId`
│ - user provided key │
└─────────────┬────────────┘
┌─────────────────────────┐
│ Locate vcpkg.json. │ Inputs:
│ If found, add its hash │ - `vcpkgJsonGlob`
│ to cache key │ _ `vcpkgJsonIgnores`
└────────────┬────────────┘
┌─────────────────────────┐ Inputs:
│ Restore vcpkg and │ - `doNotCache`
│ packages from cache │ - `vcpkgDirectory`
│ to cache key │ - `binaryCachePath`
└────────────┬────────────┘ Environment variable:
│ - `VCPKG_DEFAULT_BINARY_CACHE`: where previous built packages
│ - `VCPKG_DEFAULT_BINARY_CACHE`: where previous built packages
▼ are going to be restored
┌─────────────────────────┐
│ If vcpkg is not a │ Inputs:
│ submodule, fetch it │ - `vcpkgGitCommitId`
│ │ - `vcpkgGitURL`
└────────────┬────────────┘ - `doNotUpdateVcpkg`
│ - `vcpkgDirectory`
┌─────────────────────────┐
│ Rebuild vcpkg executable│ Inputs:
│ if not in sync with │ - `vcpkgGitCommitId`
│ sources │ - `vcpkgGitURL`
└────────────┬────────────┘
<Is `runVcpkgInstall:true`>┐ Inputs:
────┬──── No│ - `runVcpkgInstall`
│ Yes │
▼ │
┌─────────────────────────┐ │
│ Launch `vcpkg install` │ │ Inputs:
│ where vcpkg.json has │ │ - `runVcpkgFormatString`
│ been located │ │ Environment variables:
│ been located │ │ Environment variables:
└────────────┬────────────┘ │ - `VCPKG_DEFAULT_TRIPLET` is used. If not yet
│ │ set, it is set to the current platform.
▼ │
┌─────────────────────────┐ │
│ Set `VCPKG_ROOT` and │ │
│ `VCPKG_DEFAULT_TRIPLET` │ │
│ workflow-wide env vars │ │
│ Set `VCPKG_ROOT` and │ │
│ `VCPKG_DEFAULT_TRIPLET` │ │
│ workflow-wide env vars │ │
└────────────┬────────────┘ │
├───────────── ┘
┌───────────────────────────┐
│ Schedule this step at │
│ end of the workflow: │
│┌─────────────────────────┐│
│| If no cache-hit, ││ Inputs:
││ store `VCPKG_ROOT` and ││ - `binaryCachePath`
││ binary packages in cache││ - `doNotCache`
│└────────────┬────────────┘│ - `doNotCacheOnWorkflowFailure`
└────────────┬──────────────┘
││ ││ Environment variables:
│└────────────┬────────────┘│ - RUNVCPKG_NO_CACHE: Any step before the post action
└────────────┬──────────────┘ may set this environment variable to disable saving
▼ the cache.
```

Expand Down
2 changes: 1 addition & 1 deletion __tests__/functional.test.ts
Expand Up @@ -9,7 +9,7 @@ import { ActionLib } from '@lukka/action-lib';
import { BaseUtilLib } from '@lukka/base-util-lib';
import * as runvcpkglib from "@lukka/run-vcpkg-lib"

jest.setTimeout(400 * 1000);
jest.setTimeout(800 * 1000);

const tempDirectory = path.join(__dirname, "temp Directory");
// Note: 'theAssets' must match the directory __tests__/theAssets/
Expand Down
41 changes: 21 additions & 20 deletions __tests__/unit.test.ts
Expand Up @@ -118,8 +118,6 @@ test('run-vcpkg: basic run with exception', async () => {
// Run post action.
const vcpkgPostAction = new vcpkgpostaction.VcpkgPostAction(
baseUtil,
true,
false,
false,
baseutil.createKeySet(["primary"]),
['/dummy/Path/'],
Expand All @@ -138,8 +136,6 @@ test('run-vcpkg: basic run with exception on saving the cache', async () => {
// Run post action.
const vcpkgPostAction = new vcpkgpostaction.VcpkgPostAction(
baseUtil,
true,
false,
false,
baseutil.createKeySet(["primary"]),
['/dummy/Path/'],
Expand Down Expand Up @@ -172,8 +168,6 @@ test('run-vcpkg: cache hit', async () => {

// Run post action.
const vcpkgPostAction = new vcpkgpostaction.VcpkgPostAction(baseUtil,
true,
false,
false,
keys,
['/dummy/Path/'],
Expand Down Expand Up @@ -211,8 +205,6 @@ test('run-vcpkg: cache miss', async () => {
// code is running by an GitHub runner indeed)
process.env.STATE_VCPKG_CACHE_COMPUTEDKEY_STATE = '{"primary":"runnerOS=darwin","restore":[]}';
const vcpkgPostAction = new vcpkgpostaction.VcpkgPostAction(baseUtil,
true,
false,
false,
baseutil.createKeySet([key]),
['/dummy/Path/'],
Expand Down Expand Up @@ -325,6 +317,7 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided an
expect(await vcpkgutils.Utils.computeCacheKeys(
baseUtil,
null,
null,
".",
"",
"appendedCacheKey")).toStrictEqual(expected);
Expand All @@ -338,10 +331,10 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided an
test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)', async () => {
// Arrange.
const expected: baseutil.KeySet = {
"primary": "runnerOS=imageos-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json_appendedKey=appendedCacheKey",
"primary": "runnerOS=imageos-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey",
"restore":
[
"runnerOS=imageos-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json",
"runnerOS=imageos-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json",
"runnerOS=imageos-vcpkgGitCommit=1234"
]
};
Expand All @@ -353,7 +346,9 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)',

// Act and Assert.
expect(await vcpkgutils.Utils.computeCacheKeys(
baseUtil, "hash-of-vcpkg.json",
baseUtil,
"hash-of-vcpkg.json",
"hash-of-vcpkg-configuration.json",
".",
"",
"appendedCacheKey")).toStrictEqual(expected);
Expand All @@ -366,10 +361,10 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)',
test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', async () => {
// Arrange.
const expected: baseutil.KeySet = {
"primary": "runnerOS=imageos-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json_appendedKey=appendedCacheKey",
"primary": "runnerOS=imageos-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey",
"restore":
[
"runnerOS=imageos-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json",
"runnerOS=imageos-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json",
"runnerOS=imageos-vcpkgGitCommit=5678"
]
};
Expand All @@ -381,7 +376,9 @@ test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', asy

// Act and Assert.
expect(await vcpkgutils.Utils.computeCacheKeys(
baseUtil, "hash-of-vcpkg.json",
baseUtil,
"hash-of-vcpkg.json",
"hash-of-vcpkg-configuration.json",
".",
"",
"appendedCacheKey")).toStrictEqual(expected);
Expand All @@ -394,10 +391,10 @@ test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', asy
test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id, it must trigger a warning', async () => {
// Arrange.
const expected: baseutil.KeySet = {
"primary": "runnerOS=imageos-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json_appendedKey=appendedCacheKey",
"primary": "runnerOS=imageos-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey",
"restore":
[
"runnerOS=imageos-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json",
"runnerOS=imageos-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json",
"runnerOS=imageos-vcpkgGitCommit=0912"
]
};
Expand All @@ -409,7 +406,9 @@ test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id,

// Act and Assert.
expect(await vcpkgutils.Utils.computeCacheKeys(
baseUtil, "hash-of-vcpkg.json",
baseUtil,
"hash-of-vcpkg.json",
"hash-of-vcpkg-configuration.json",
path.resolve("."),
"vcpkgcommitid",
"appendedCacheKey")).toStrictEqual(expected);
Expand All @@ -420,9 +419,9 @@ test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id,
test('computeCacheKey(): vcpkg with user provided commit it must not trigger a warning', async () => {
// Arrange.
const expected: baseutil.KeySet = {
"primary": "runnerOS=imageos-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json_appendedKey=appendedCacheKey",
"primary": "runnerOS=imageos-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey",
"restore": [
"runnerOS=imageos-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json",
"runnerOS=imageos-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json",
"runnerOS=imageos-vcpkgGitCommit=userId"]
};
process.env.ImageOS = "imageos";
Expand All @@ -433,7 +432,9 @@ test('computeCacheKey(): vcpkg with user provided commit it must not trigger a w

// Act and assert.
expect(await vcpkgutils.Utils.computeCacheKeys(
baseUtil, "hash-of-vcpkg.json",
baseUtil,
"hash-of-vcpkg.json",
"hash-of-vcpkg-configuration.json",
"/Users/luca/github/run-vcpkg/__tests__/assets/",
"userId",
"appendedCacheKey")).toStrictEqual(expected);
Expand Down
8 changes: 0 additions & 8 deletions action.yml
Expand Up @@ -34,10 +34,6 @@ inputs:
default: false
required: false
description: "Disable the automatic caching mechanism by setting it to true. Default is false."
doNotCacheOnWorkflowFailure:
default: false
required: false
description: "Disable the saving of the cache if the workflow failed."

# The following inputs are rarely set by the user, since the default values suffice the most common scenarios.
vcpkgJsonGlob:
Expand All @@ -63,10 +59,6 @@ inputs:
default: "\\s*\"(.+CMakeOutput\\.log)\"\\.\\s*;\\s*\"(.+CMakeError\\.log)\"\\.\\s*;\\s*(.+out\\.log)\\s*;\\s+(.+err\\.log)\\s*;\\s*(.+vcpkg.+\\.log)\\s*"
required: false
description: "Specifies a semicolon separated list of regular expressions that are used to identify log file paths in the workflow output. A regular expression must have a single capturing group, that is a single pair of parenthesis such as 'See also (.+.log)'. When a match occurs, the content of the file is written into the workflow output for disclosing its content to the user. The default regular expressions are for CMake's and vcpkg's log files."
jobStatus:
default: ${{ job.status }}
required: false
description: "Do not set nor use. It is used to get the status of the job and decide whether to save cache on the post action run at the end of the job."

runs:
using: 'node12'
Expand Down

0 comments on commit 7b25951

Please sign in to comment.