Skip to content

Commit

Permalink
- drop gulp.
Browse files Browse the repository at this point in the history
- update all deps to latest.
- update node to v20.
  • Loading branch information
lukka committed Nov 4, 2023
1 parent 2f041fd commit 1f075d1
Showing 17 changed files with 42,118 additions and 40,414 deletions.
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
/dist
/node_modules
.eslintrc.js
*.js
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020 Luca Cappa
// Copyright (c) 2019-2020-2023 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT

@@ -9,7 +9,6 @@ module.exports = {
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
@@ -20,4 +19,4 @@ module.exports = {
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": ["off"]
},
};
};
17 changes: 11 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -22,24 +22,29 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'
# How to consume GitHub packages, from this message (!): https://github.community/t/download-from-github-package-registry-without-authentication/14407/35
# Inspired from here: https://github.com/jcansdale-test/npmrc-configurations/blob/master/.github/workflows/blank.yml
- name: Authenticate to GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
echo "@${{ github.repository_owner }}:registry=https://npm.pkg.github.com/" >> ~/.npmrc
- uses: lukka/get-cmake@latest
- run: |
npm install
npm run test
name: build and test
- run: npm install
- run: npm run build
- run: npm run lint
- run: npm run pack
- run: npm run test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
flag-name: ${{ matrix.os }}-build_and_unit_test
base-path: ${{ runner.os != 'macOS' && '__tests__/theAssets/vcpkg_project/' || '' }}
debug: true

tests:
name: '${{ matrix.os }}: functional tests'
5 changes: 3 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -35,15 +35,16 @@ jobs:
with:
languages: ${{ matrix.language }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'
- name: Authenticate to GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
echo "@${{ github.repository_owner }}:registry=https://npm.pkg.github.com/" >> ~/.npmrc
- run: |
npm install
npm run build
npm run pack
- name: Perform CodeQL Analysis
16 changes: 11 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# Contributing
- [Contributing](#contributing)
- [Prerequisites](#prerequisites)
- [Setup for GitHub Registry public packages](#setup-for-github-registry-public-packages)
- [Setup for consuming GitHub Registry public packages](#setup-for-consuming-github-registry-public-packages)
- [Build and lint](#build-and-lint)
- [Packaging](#packaging)
- [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-cmake) with fixes and new features contributed by means of Pull Requests.


## Prerequisites
[gulp 4](https://www.npmjs.com/package/gulp4) globally installed.

### Setup for GitHub Registry public packages
Run

```bash
npm install
```

to populate the dependencies in `./node_modules` directory.

### Setup for consuming GitHub Registry public packages

`run-cmake` depends on public NPM packages published by [lukka/run-cmake-vcpkg-action-libs](https://github.com/lukka/run-cmake-vcpkg-action-libs) in the [GitHub Packages registry](https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages).
Unexpectedly, a public package still requires authentication when downloading it, hence if you want to `npm install` those packages correctly, you need to obtain a token with `read:packages` scope. Then create in the root of the repository a `.npmrc` file with the following content:
@@ -46,6 +52,6 @@ To build, pack and test:
To run test directly:

> jest
> npx jest
Validation tests on various scenarios are run using the workflows of the [Samples](./README.md#samples).
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2019-2020-2021 Luca Cappa
Copyright (c) 2019-2020-2021-2023 Luca Cappa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
82 changes: 47 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@

# Quickstart with a C++ project template

Take a look at this [C++ project template](https://github.com/lukka/CppCMakeVcpkgTemplate) that applies all the following instructions and also shows how to create a __pure__ workflow without using special GitHub action that you cannot run locally on your development machine, but directly using the tools (`CMake`, `Ninja`, `vcpkg`, `C++` compilers) you already use daily.
Take a look at this [C++ project template](https://github.com/lukka/CppCMakeVcpkgTemplate/tree/v11) that applies all the following instructions, but also shows how to create a __pure__ workflow without using special GitHub action that you cannot run locally on your development machine, but directly using the tools (`CMake`, `Ninja`, `vcpkg`, `C++` compilers) you already use daily.

# [**run-cmake@v10** runs CMake with CMakePresets.json](https://github.com/marketplace/actions/run-cmake)

@@ -24,13 +24,16 @@ The **run-cmake** action runs [CMake](https://cmake.org) on GitHub workflows lev
Good companions are the [run-vcpkg](https://github.com/marketplace/actions/run-vcpkg) action and the [get-cmake](https://github.com/marketplace/actions/get-cmake) action.

Special features which provide added value over a pure workflow are:
- annotations for `CMake` errors/warnings and for build (`gcc`/`msvc`/`clang`) errors/warnings are created inline in the changed source files the build run for, e.g.:
- annotations for `CMake` errors/warnings and for build (`gcc`/`msvc`/`clang`) errors/warnings are created inline in the changed source files the build run for, e.g.:
![Annotation](./docs/imgs/annotation.png)
- when necessary, it sets up the environment to build with the `MSVC` toolset.
- automatic dump of log files created by `CMake` (e.g., `CMakeOutput.log`) and `vcpkg`. The content of those files flow into the workflow output log. The regex is customizable by the user.

The provided [samples](#samples) use [GitHub hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners).

Good companions are the [run-vcpkg](https://github.com/marketplace/actions/run-vcpkg) action and the
[get-cmake](https://github.com/marketplace/actions/get-cmake) action.

<br>

## Quickstart with instructions
@@ -49,47 +52,51 @@ jobs:
# Install latest CMake and Ninja.
- uses: lukka/get-cmake@latest
# Or pin to a specific CMake version:
# lukka/get-cmake@v3.21.2

# Restore from cache the previously built ports. If a "cache miss" occurs,
# then vcpkg is bootstrapped. Since a the vcpkg.json is being used later on
# 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
# lukka/get-cmake@v3.27

# Setup vcpkg: ensures vcpkg is downloaded and built.
# Since vcpkg.json is being used later on to install the packages
# when `run-cmake` runs, no packages are installed at this time
# (and vcpkg does not run).
- name: Setup anew (or from cache) vcpkg (and does not build any package)
uses: lukka/run-vcpkg@v11 # Always specify the specific _version_ of the
# action you need, `v10` in this case to stay up
# to date with fixes on the v10 branch.
# to date with fixes on the v11 branch.
#with:
# This is the default location of the directory containing vcpkg sources.
# 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. It must not set if using a submodule
# for vcpkg.
# id must be checkout from a Git repo.
# Note: it must not be set if using a Git submodule for vcpkg.
# vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}'

# This is the glob expression used to locate the vpkg.json and add its
# hash to the cache key. Change it to match a single manifest file you want
# to use.
# vcpkgJsonGlob: '**/vcpkg.json'

# This is needed to run `vcpkg install` command (after vcpkg is built) in
# the directory where vcpkg.json has been located. Default is false,
# It is highly suggested to let `run-cmake` to run vcpkg (i.e. `false`)
# (i.e. let CMake run `vcpkg install`) using the vcpkg.cmake toolchain.
# This is only needed if the command `vcpkg install` must run at this step.
# Instead it is highly suggested to let `run-cmake` to run vcpkg later on
# using the vcpkg.cmake toolchain. The default is `false`.
# runVcpkgInstall: true

- name: Run CMake consuming CMakePresets.json and vcpkg.json by mean of vcpkg.
# This is only needed if `runVpkgInstall` is `true`.
# This glob expression used to locate the vcpkg.json and use
# its directory location as `working directory` when running `vcpkg install`.
# Change it to match a single manifest file you want to use.
# Note: do not use `${{ github.context }}` to compose the value as it
# contains backslashes that would be misinterpreted. Instead
# compose a value relative to the root of the repository using
# `**/path/from/root/of/repo/to/vcpkg.json` to match the desired `vcpkg.json`.
# vcpkgJsonGlob: '**/vcpkg.json'

- name: Run CMake consuming CMakePreset.json and run vcpkg to build packages
uses: lukka/run-cmake@v10
with:
# This is the default path to the CMakeLists.txt along side the
# CMakePresets.json. Change if you need have CMakeLists.txt and CMakePresets.json
# located elsewhere.
# cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'

# You could use CMake workflow presets defined in the CMakePresets.json
# with just this line below. Note this one cannot be used with any other
# You could use CMake workflow presets defined in the CMakePresets.json
# with just this line below. Note this one cannot be used with any other
# preset input, it is mutually exclusive.
# workflowPreset: 'workflow-name'

@@ -108,18 +115,23 @@ jobs:
# configuration to build.
# This is useful to reduce the number of CMake's Presets you need in CMakePresets.json.
buildPresetAdditionalArgs: "['--config Release']"

# This is the name of the CMakePresets.json's configuration to test the project with.
testPreset: 'ninja-multi-vcpkg'
# Additional arguments can be appended when testing, for example to specify the config
# to test.
# This is useful to reduce the number of CMake's Presets you need in CMakePresets.json.
testPresetAdditionalArgs: "['--config Release']"

#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).
# [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 }}
#
# [OPTIONAL] 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
#
```

<br>
@@ -142,14 +154,14 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-cmake/
└─────────────┬─────────────┘ └─────────────┬─────────────┘ - `workflowPreset`
│ No ⬬ - `workflowPresetCmdString`
┌──────────────────────────────────┐
┌──────────────────────────────────┐
│ <if configurePreset `*`│ Inputs:
│ provided> | - `cmakeListsTxtPath`
| | - `configurePreset`
│ $CONFIGURE_PRESET_NAME = │ - `configurePresetCmdString`
│ configurePreset's value │
| runs: `cmake --preset` │
└─────────────┬────────────────────┘
| runs: `cmake --preset` │
└─────────────┬────────────────────┘
┌───────────────────────────────────┐
│ <if buildPreset provided> `*`│ Inputs:
@@ -176,8 +188,8 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-cmake/
`*` On Windows runners, the MSVC environment is setup for each block
with the `*` on the top right corner. Note that VCPKG_ROOT will not be
overridden by the value defined in the VS Developer Command Prompt
with the `*` on the top right corner. Note that VCPKG_ROOT will not be
overridden by the value defined in the VS Developer Command Prompt
environment, but the original value will be kept.
┌───────────────────────────┐
│ <if VCPKG_ROOT defined │ Inputs:
2 changes: 1 addition & 1 deletion __tests__/functional.test.ts
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ describe('run-cmake functional tests', () => {
console.log(cp.execSync(`node ${testScript}`, options)?.toString());
});

test('basic test for xenvironment variables in input, no shell, it must throw', () => {
test('basic test for environment variables in input, no shell, it must throw', () => {
// Building will use an environment variable that will not be
// resolved since not being run inside a shell, and it will throw.
expect(() => envTest(false, undefined)).toThrow();
2 changes: 1 addition & 1 deletion __tests__/theAssets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(test_project)
cmake_minimum_required(VERSION 3.21)
project(test_project)

add_executable(main main.cpp)

6 changes: 6 additions & 0 deletions __tests__/unit.test.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,12 @@ describe('run-cmake unit tests', () => {
jest.spyOn(runcmakelib.CMakeRunner, "run").mockImplementation(() => { throw new Error(); })
// Act
await cmakeaction.main();

// The failure sets an exit code different than 0, and this will fail `npm run test`.
// On node20+ on Linux/Windows (but not on macOS) this leads to a failing exit
// code: https://github.com/jestjs/jest/issues/14501
process.exitCode = 0;

// Assert
expect(setFailedMock).toBeCalledTimes(1);
});
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ inputs:
description: "Specify the command line to dump the environment variables with the 'vcpkg env' command. This command is only used when setting up the environment for MSVC on Windows."

runs:
using: 'node16'
using: 'node20'
main: './dist/index.js'

branding:
Loading

0 comments on commit 1f075d1

Please sign in to comment.