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 Nov 25, 2023
1 parent d42250c commit 6f5b3dc
Show file tree
Hide file tree
Showing 12 changed files with 1,655 additions and 82 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).
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ 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` is used to locate a
# vcpkg-configuration.json file in order to use the default-registry's
# baseline.
# vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}'

# This is only needed if the command `vcpkg install` must run at this step.
Expand Down Expand Up @@ -181,11 +185,14 @@ 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. │ Files:
└────────────┬───────────────┘ - `vcpkg-configuration.json`
┌─────────────────────────┐
│ Rebuild vcpkg executable│ Inputs:
Expand Down
31 changes: 25 additions & 6 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,7 +111,7 @@ 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;

Expand Down Expand Up @@ -144,4 +143,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"
}
}
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ 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."
vcpkgConfigurationJsonGlob:
default: '**/vcpkg-configuration.json'
required: false
description: "Specify the glob expression used to discover 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."

runs:
using: 'node20'
Expand Down
Loading

0 comments on commit 6f5b3dc

Please sign in to comment.