Skip to content

Commit

Permalink
add support for vcpkg-configuration.json's baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Dec 28, 2023
1 parent d42250c commit 1737e22
Show file tree
Hide file tree
Showing 16 changed files with 35,385 additions and 19,020 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,26 @@ jobs:
uses: ./
with:
vcpkgDirectory: ${{ github.workspace }}/vcpkg
vcpkgGitCommitId: 'c9f906558f9bb12ee9811d6edc98ec9255c6cda5'
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50'
vcpkgGitUrl: 'https://github.com/microsoft/vcpkg.git'

- name: basic test for run-vcpkg with running 'vcpkg install'.
uses: ./
with:
vcpkgDirectory: ${{ github.workspace }}/vcpkg
vcpkgGitCommitId: 'c9f906558f9bb12ee9811d6edc98ec9255c6cda5'
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50'
runVcpkgInstall: true
vcpkgGitUrl: 'https://github.com/microsoft/vcpkg.git'
env:
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed

- name: basic test for run-vcpkg with 'vcpkg-configuration.json'.
uses: ./
with:
vcpkgDirectory: ${{ github.workspace }}/vcpkg
#vcpkgGitCommitId: is not provided intentionally, the Git commit it is read from vcpkg-configuration.json.
vcpkgConfigurationJsonGlob: '**/__tests__/theAssets/vcpkg_project/vcpkg-configuration.json'

tests_with_cache_hit:
needs: tests
name: '${{ matrix.os }}: functional tests'
Expand All @@ -90,7 +97,7 @@ jobs:
uses: ./
with:
vcpkgDirectory: ${{ github.workspace }}/vcpkg
vcpkgGitCommitId: 'c9f906558f9bb12ee9811d6edc98ec9255c6cda5'
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50'
vcpkgGitUrl: 'https://github.com/microsoft/vcpkg.git'

finalize_coveralls:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ build
coverage
.DS_Store
__tests__/theAssets/
__tests__/b
-__tests__/b
41 changes: 30 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Setup for consuming GitHub Registry public packages](#setup-for-consuming-github-registry-public-packages)
- [Build and lint](#build-and-lint)
- [Packaging](#packaging)
- [Build and Package](#build-and-package)
- [Testing](#testing)

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/run-vcpkg) with fixes and new features contributed by means of Pull Requests.
Expand All @@ -14,7 +15,7 @@ The software is provided as is, there is no warranty of any kind. All users are
Run

```bash
npm install
> npm install
```

to populate the dependencies in `./node_modules` directory.
Expand All @@ -32,25 +33,43 @@ __Note__: **Never commit this `.npmrc` file!**
## Build and lint
Build with `tsc` running:

> npm run build
```bash
> npm run build
```

Launch `lint` by:

> npm run lint
```bash
> npm run lint
```

## Packaging
To build, lint validate and package the extension for release purpose, run:
To package the extension for release purpose, run:

> npm run pack
```bash
> npm run pack
```

## Build and Package

To run linter, build and package all:

```bash
> npm run repack
```

## Testing

To build, pack and test:

> npm run test
To run the test suite:

```bash
> npm run test
```

To run a specific test by name:

To run test directly:
> npx jest
```bash
> npx jest -t `<regular-expression>`
```

Validation tests on various scenarios are run using the workflows of the [Samples](./README.md#samples).
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ jobs:
# Change it to the right location if needed.
# vcpkgDirectory: '${{ github.workspace }}/vcpkg'

# If not using a submodule for vcpkg sources, this specifies which commit
# id must be checkout from a Git repo.
# Note: it must not be set if using a Git submodule for vcpkg.
# If not using a Git submodule for vcpkg sources, this input
# specifies which commit id to checkout from a Git repo.
# Notes:
# - it must _not_ be set if using a Git submodule for vcpkg.
# - if not provided, the `vcpkgConfigurationJsonGlob` or `vcpkgJsonGlob`
# are being used to locate either a vcpkg-configuration.json or vcpkg.json
# in order to use the builtin-baseline or the default-registry's
# builtin baseline.
# vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}'

# This is only needed if the command `vcpkg install` must run at this step.
Expand Down Expand Up @@ -181,12 +186,16 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-vcpkg/
│ from the GH cache. │ to run this block.
└────────────┬────────────┘
┌─────────────────────────┐ Inputs:
│ If vcpkg is not a │ - `vcpkgDirectory`
│ submodule, fetch it │ - `vcpkgGitCommitId`
│ │ - `vcpkgGitURL`
└────────────┬────────────┘ - `doNotUpdateVcpkg`
┌────────────────────────────┐ Inputs:
│ If vcpkg is not a │ - `vcpkgDirectory`
│ submodule, fetch it. │ - `vcpkgGitCommitId`
│ Use either the provided │ - `vcpkgGitURL`
│ commit id or the default │ - `doNotUpdateVcpkg`
│ registry baseline in │ - `vcpkgConfigurationJsonGlob`
│ vcpkg-configuration.json │ - `vcpkgJsonGlob`
│ or vcpkg.json. │ Environment variables:
└────────────┬───────────────┘ - VCPKG_CONFIGURATION_JSON_IGNORE_PATTERNS:
▼ semicolon separated ignore patterns.
┌─────────────────────────┐
│ Rebuild vcpkg executable│ Inputs:
│ if not in sync with │ - `vcpkgGitCommitId`
Expand Down
33 changes: 25 additions & 8 deletions __tests__/functional.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ describe('run-vcpkg functional tests', () => {
process.env.INPUT_VCPKGGITURL = "https://github.com/microsoft/vcpkg.git";
process.env.INPUT_VCPKGDIRECTORY = vcpkgDirectory;
process.env.INPUT_VCPKGJSONGLOB = "**/vcpkg.json";
process.env.INPUT_VCPKGGITCOMMITID = "c9f906558f9bb12ee9811d6edc98ec9255c6cda5";
process.env.INPUT_VCPKGGITCOMMITID = "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50";
process.env.INPUT_RUNVCPKGINSTALL = "true";
process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT;

// Ensure child is running in the GH workspace, needed to find vcpkg.json.
process.chdir(vcpkgProject);
process.chdir(assetDirectory);

const options: cp.ExecSyncOptions = {
env: process.env,
Expand All @@ -70,7 +70,7 @@ describe('run-vcpkg functional tests', () => {
process.env.INPUT_VCPKGGITURL = "https://github.com/microsoft/vcpkg.git";
process.env.INPUT_VCPKGDIRECTORY = vcpkgDirectory;
process.env.INPUT_VCPKGJSONGLOB = "**/vcpkg.json";
process.env.INPUT_VCPKGGITCOMMITID = "c9f906558f9bb12ee9811d6edc98ec9255c6cda5";
process.env.INPUT_VCPKGGITCOMMITID = "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50";
process.env.INPUT_RUNVCPKGINSTALL = "false";
process.env.INPUT_RUNVCPKGFORMATSTRING = "['invalid command']";

Expand All @@ -86,7 +86,7 @@ describe('run-vcpkg functional tests', () => {
console.log(process.env.INPUT_VCPKGDIRECTORY);
delete process.env.INPUT_VCPKGJSONGLOB;
process.env.INPUT_VCPKGGITURL = "https://github.com/microsoft/vcpkg.git";
process.env.INPUT_VCPKGGITCOMMITID = "c9f906558f9bb12ee9811d6edc98ec9255c6cda5";
process.env.INPUT_VCPKGGITCOMMITID = "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50";
process.env.INPUT_RUNVCPKGINSTALL = "false";
process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT;

Expand All @@ -97,7 +97,6 @@ describe('run-vcpkg functional tests', () => {
console.log(cp.execSync(`node ${testScript}`, options)?.toString());
});


test('vcpkg setup and install must pull packages stored in the cache and succeed', async () => {
// Use the default vcpkg directory
delete process.env.INPUT_VCPKGDIRECTORY;
Expand All @@ -112,12 +111,10 @@ describe('run-vcpkg functional tests', () => {
await actionLib.rmRF(await runvcpkglib.getDefaultVcpkgCacheDirectory(baseLibUtils.baseLib));

process.env.INPUT_VCPKGGITURL = "https://github.com/microsoft/vcpkg.git";
process.env.INPUT_VCPKGGITCOMMITID = "c9f906558f9bb12ee9811d6edc98ec9255c6cda5";
process.env.INPUT_VCPKGGITCOMMITID = "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50";
process.env.INPUT_RUNVCPKGINSTALL = "true";
process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT;

process.chdir(vcpkgProject);

// Populate the cache in the default location (i.e. /b/vcpkg_cache).
// Populate the vcpkg_installed in the default location (i.e. /b/vcpkg_installed).
let startTime = new Date();
Expand All @@ -144,4 +141,24 @@ describe('run-vcpkg functional tests', () => {
console.log(`********* With cached built packages (binary cache) it took: ${elapsedWithCache}ms`)
expect(elapsedWithCache).toBeLessThan(elapsed / 2);
});

test('vcpkg setup and no install must succeed when the commit id is not provided as input but it is read from vcpkg-configurationn.json', () => {
process.env.INPUT_VCPKGGITURL = "https://github.com/microsoft/vcpkg.git";
process.env.INPUT_VCPKGDIRECTORY = vcpkgDirectory;
process.env.INPUT_VCPKGJSONGLOB = "**/vcpkg.json";
delete process.env.INPUT_VCPKGGITCOMMITID;
process.env.INPUT_RUNVCPKGINSTALL = "false";

function fwSlash(p: string): string {
return p.replace(/\\/g, '/');
}
process.env.INPUT_VCPKGCONFIGURATIONJSONGLOB = fwSlash(path.join("**", path.basename(vcpkgProject), runvcpkglib.VCPKG_CONFIGURATION_JSON));

const options: cp.ExecSyncOptions = {
env: process.env,
stdio: "inherit"
};
console.log(cp.execSync(`node ${testScript}`, options)?.toString());
});

});
Empty file.
6 changes: 6 additions & 0 deletions __tests__/theAssets/vcpkg_project/vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default-registry": {
"kind": "builtin",
"baseline": "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50"
}
}
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
description: "Run the installation of packages by running `vcpkg install` on the directory of the discovered 'vcpkg.json' file. Default is false."
vcpkgGitCommitId:
required: false
description: "Specify the full SHA-1 hash of a Git commit (not a branch name, nor a tag!) that establishes which version of vcpkg needs to be used. When using vcpkg as a Git submodule, this input is *not* needed as implicitly specified by the submodule."
description: "Specify the full SHA-1 hash of a Git commit (not a branch name, nor a tag!) that establishes which version of vcpkg needs to be used. When using vcpkg as a Git submodule, this input is *not* needed as implicitly specified by the submodule. When not specified and a submodule is not used for vcpkg, the commit id is being searched in vcpkg.json or vcpkg-configure.json, see vcpkgConfigurationJsonGlob input."
vcpkgGitURL:
default: "https://github.com/microsoft/vcpkg.git"
required: false
Expand All @@ -41,6 +41,10 @@ inputs:
default: "['**/vcpkg/**']"
required: false
description: "Specify an array of string containing the pattenrs to be ignored when searching for the vcpkg.json file. The default value ignores the pattern '**/vcpkg/**'"
vcpkgConfigurationJsonGlob:
default: '**/vcpkg-configuration.json'
required: false
description: "When the vcpkgGitCommitId input is not provided by the user, this glob expression is used to locate the vcpkg-configuration.json file which contains the commit id of the builtin baseline. On Windows GitHub runners do not use `github.workspace` context expression to form the value of this input, since it contains backslashes and it will eventually fail. Use instead `**/path/to/vcpkg-configuration.json` to match the desired `vcpkg-configuration.json` file."
binaryCachePath:
required: false
description: "Specify a path to store the built packages to be cached with the GitHub cache service. Default is '<runnerWorkspace>/b/vcpkg_cache'."
Expand Down
4 changes: 4 additions & 0 deletions dist/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if (!yy.ast) {
yy.ast = _ast;
_ast.initialize();
}

0 comments on commit 1737e22

Please sign in to comment.