Compare commits

..

5 Commits

Author SHA1 Message Date
Alexei Lozovsky 25affc65a9 [debug] add missing file 2021-04-29 22:49:54 +09:00
Alexei Lozovsky ed700f61b8 [debug] add this thing that should fail 2021-04-29 22:49:01 +09:00
Alexei Lozovsky 529b6c1c09 [debug] disable release workflow for now 2021-04-29 22:48:20 +09:00
Alexei Lozovsky a7c03318e1 [debug] trigger build 2021-04-29 22:38:05 +09:00
Alexei Lozovsky 73375e968b Run tests on all Windows versions
Some time ago GitHub has introduced an alternative version of Windows
virtual environment. One of those is possibly untested in this repo.
Let's test both of them.

Audit tasks and side tracks are still using "windows-latest" because we
don't particularly care about them. However, main tests should be run
against both versions.

You can find currently supported environments here:
https://github.com/actions/virtual-environments/
2021-04-29 22:35:59 +09:00
10 changed files with 630 additions and 1890 deletions
+19
View File
@@ -0,0 +1,19 @@
name: z5-build-env
channels:
- conda-forge
dependencies:
- cmake
- compilers
- bzip2
- lz4-c
- xz
- zlib
- boost-cpp>=1.63
- xtensor>=0.21,<0.22
- xtensor-python>=0.24,<0.25
- xsimd
- blosc
- imageio
- nlohmann_json
- zarr
- h5py
+33 -48
View File
@@ -6,65 +6,50 @@ on:
branches: branches:
- master - master
- release/* - release/*
- new-windows
schedule: schedule:
- cron: '0 6 * * *' - cron: '0 6 * * *'
jobs: jobs:
test: test:
name: default name: default
runs-on: ${{ matrix.windows }}
strategy:
matrix:
windows: [windows-2016, windows-2019]
steps:
- name: Check out source code
uses: actions/checkout@v2
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: z5-build-env
auto-update-conda: true
channels: conda-forge
environment-file: .github/workflows/environment.yaml
python-version: 3.7
auto-activate-base: false
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Download Internet
run: npm install
- name: Enable Developer Command Prompt
uses: ./
- name: Compile and run some C code
shell: cmd
run: |
cl.exe hello.c
hello.exe
audit:
name: npm audit
runs-on: windows-latest runs-on: windows-latest
steps:
- name: Check out source code
uses: actions/checkout@v2
- name: Download Internet
run: npm install
- name: Run eslint
run: npm run lint
- name: Enable Developer Command Prompt (amd64)
uses: ./
with:
arch: amd64
- name: Compile and run some C code (amd64)
shell: cmd
run: |
cl.exe hello.c
hello.exe
- name: Enable Developer Command Prompt (amd64_x86)
uses: ./
with:
arch: amd64_x86
- name: Compile and run some C code (x86)
shell: cmd
run: |
cl.exe hello.c
hello.exe
- name: Enable Developer Command Prompt (amd64_arm)
uses: ./
with:
arch: amd64_arm
- name: Compile some C code (arm)
shell: cmd
run: |
cl.exe hello.c
dumpbin /headers hello.exe
- name: Enable Developer Command Prompt (amd64_arm64)
uses: ./
with:
arch: amd64_arm64
- name: Compile some C code (arm64)
shell: cmd
run: |
cl.exe hello.c
dumpbin /headers hello.exe
audit:
name: npm audit
runs-on: ubuntu-latest
steps: steps:
- name: Check out source code - name: Check out source code
uses: actions/checkout@v2 uses: actions/checkout@v2
- run: npm install - run: npm install
- run: npm audit --audit-level=moderate --production - run: npm audit --audit-level=moderate
- run: npm audit --audit-level=critical
alias-arch: alias-arch:
name: arch aliases name: arch aliases
runs-on: windows-latest runs-on: windows-latest
+6 -4
View File
@@ -10,7 +10,10 @@ on:
jobs: jobs:
test: test:
name: release name: release
runs-on: windows-latest runs-on: ${{ matrix.windows }}
strategy:
matrix:
windows: [windows-2016, windows-2019]
steps: steps:
- name: Setup Developer Command Prompt - name: Setup Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
@@ -23,9 +26,8 @@ jobs:
hello.exe hello.exe
audit: audit:
name: npm audit name: npm audit
runs-on: ubuntu-latest runs-on: windows-latest
steps: steps:
- name: Check out source code - name: Check out source code
uses: actions/checkout@v2 uses: actions/checkout@v2
- run: npm audit --audit-level=moderate --production - run: npm audit --audit-level=moderate
- run: npm audit --audit-level=critical
+1
View File
@@ -0,0 +1 @@
node_modules
+17 -88
View File
@@ -8,57 +8,14 @@ This sets up the environment for compiling C/C++ code from command line.
Supports Windows. Does nothing on Linux and macOS. Supports Windows. Does nothing on Linux and macOS.
## Example usage
Basic usage for default compilation settings is like this:
```yaml
jobs:
test:
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
- name: Build something requiring CL.EXE
run: |
cmake -G "NMake Makefiles" .
nmake
# ...
```
If you want something non-default,
like using a specific version of Visual Studio,
or cross-compling for a differen target,
you will need to configure those settings via inputs:
```yaml
jobs:
test:
# Run a job for each of the specified target architectures:
strategy:
matrix:
arch:
- amd64
- amd64_x86
- amd64_arm64
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Build something requiring CL.EXE
run: |
cmake -G "NMake Makefiles" .
nmake
# ...
```
## Inputs ## Inputs
- `arch` target architecture - `arch` target architecture
- native compilation: - native compilation:
- `x64` (default) or its synonyms: `amd64`, `win64`, `x86_64`, `x86-64` - `x64` (default) or its synonyms: `amd64`, `win64`
- `x86` or its synonyms: `win32` - `x86` or its synonyms: `win32`
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`, `amd64_x86`, `amd64_arm`, `amd64_arm64` - cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`,
`amd64_x86`, `amd64_arm`, `amd64_arm64`
- `sdk` Windows SDK to use - `sdk` Windows SDK to use
- do not specify to use the default SDK - do not specify to use the default SDK
- or specify full Windows 10 SDK number (e.g, `10.0.10240.0`) - or specify full Windows 10 SDK number (e.g, `10.0.10240.0`)
@@ -71,6 +28,20 @@ jobs:
- `uwp` set `true` to build for Universal Windows Platform (i.e., for Windows Store) - `uwp` set `true` to build for Universal Windows Platform (i.e., for Windows Store)
- `spectre` set `true` to use Visual Studio libraries with [Spectre](https://meltdownattack.com) mitigations - `spectre` set `true` to use Visual Studio libraries with [Spectre](https://meltdownattack.com) mitigations
## Example usage
```yaml
jobs:
test:
- uses: actions/checkout@v1
- uses: ilammy/msvc-dev-cmd@v1
- name: Build something requiring CL.EXE
run: |
cmake -G "NMake Makefiles" .
nmake
# ...
```
## Caveats ## Caveats
### Name conflicts with `shell: bash` ### Name conflicts with `shell: bash`
@@ -87,48 +58,6 @@ If you experience compilation errors where `link` complains about unreasonable c
Recommended workaround is to remove `/usr/bin/link` if that interferes with your builds. Recommended workaround is to remove `/usr/bin/link` if that interferes with your builds.
If this is not acceptable, please file an issue, then we'll figure out something better. If this is not acceptable, please file an issue, then we'll figure out something better.
### Reconfiguration
You can invoke `ilammy/msvc-dev-cmd` multiple times during your jobs with different inputs
to reconfigure the environment for building with different settings
(e.g., to target multiple architectures).
```yaml
jobs:
release:
steps:
# ...
- name: Configure build for amd64
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- run: build # (for amd64)
- name: Configure build for x86
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_x86
- run: build # (for x86)
- name: Configure build for ARM64
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_arm64
- run: build # (for ARM64)
# ...
```
This mostly works but it's not really recommended
since Developer Command Prompt was not meant for recursive reconfiguration.
That said, if it does not work for you, please file an issue.
Consider using [`strategy.matrix`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)
to execute different build configuration in parallel, independent environments.
## License ## License
MIT, see [LICENSE](LICENSE). MIT, see [LICENSE](LICENSE).
+22 -58
View File
@@ -5,11 +5,9 @@ const path = require('path')
const process = require('process') const process = require('process')
const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)'] const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)']
const PROGRAM_FILES = [process.env['ProgramFiles(x86)'], process.env['ProgramFiles']]
const EDITIONS = ['Enterprise', 'Professional', 'Community'] const EDITIONS = ['Enterprise', 'Professional', 'Community']
const VERSIONS = ['2022', '2019', '2017'] const VERSIONS = ['2019', '2017']
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer` const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
@@ -34,10 +32,9 @@ function findVcvarsall() {
// If that does not work, try the standard installation locations, // If that does not work, try the standard installation locations,
// starting with the latest and moving to the oldest. // starting with the latest and moving to the oldest.
for (const prog_files of PROGRAM_FILES) {
for (const ver of VERSIONS) { for (const ver of VERSIONS) {
for (const ed of EDITIONS) { for (const ed of EDITIONS) {
path = `${prog_files}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat` path = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
core.info(`Trying standard location: ${path}`) core.info(`Trying standard location: ${path}`)
if (fs.existsSync(path)) { if (fs.existsSync(path)) {
core.info(`Found standard location: ${path}`) core.info(`Found standard location: ${path}`)
@@ -45,7 +42,6 @@ function findVcvarsall() {
} }
} }
} }
}
core.info("Not found in standard locations") core.info("Not found in standard locations")
// Special case for Visual Studio 2015 (and maybe earlier), try it out too. // Special case for Visual Studio 2015 (and maybe earlier), try it out too.
@@ -59,23 +55,7 @@ function findVcvarsall() {
throw new Error('Microsoft Visual Studio not found') throw new Error('Microsoft Visual Studio not found')
} }
function isPathVariable(name) { function main() {
const pathLikeVariables = ['PATH', 'INCLUDE', 'LIB', 'LIBPATH']
return pathLikeVariables.indexOf(name.toUpperCase()) != -1
}
function filterPathValue(path) {
let paths = path.split(';')
// Remove duplicates by keeping the first occurance and preserving order.
// This keeps path shadowing working as intended.
function unique(value, index, self) {
return self.indexOf(value) === index
}
return paths.filter(unique).join(';')
}
/** See https://github.com/ilammy/msvc-dev-cmd#inputs */
function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
if (process.platform != 'win32') { if (process.platform != 'win32') {
core.info('This is not a Windows virtual environment, bye!') core.info('This is not a Windows virtual environment, bye!')
return return
@@ -84,13 +64,17 @@ function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
// Add standard location of "vswhere" to PATH, in case it's not there. // Add standard location of "vswhere" to PATH, in case it's not there.
process.env.PATH += path.delimiter + VSWHERE_PATH process.env.PATH += path.delimiter + VSWHERE_PATH
var arch = core.getInput('arch')
const sdk = core.getInput('sdk')
const toolset = core.getInput('toolset')
const uwp = core.getInput('uwp')
const spectre = core.getInput('spectre')
// There are all sorts of way the architectures are called. In addition to // There are all sorts of way the architectures are called. In addition to
// values supported by Microsoft Visual C++, recognize some common aliases. // values supported by Microsoft Visual C++, recognize some common aliases.
let arch_aliases = { let arch_aliases = {
"win32": "x86", "win32": "x86",
"win64": "x64", "win64": "x64",
"x86_64": "x64",
"x86-64": "x64",
} }
// Ignore case when matching as that's what humans expect. // Ignore case when matching as that's what humans expect.
if (arch.toLowerCase() in arch_aliases) { if (arch.toLowerCase() in arch_aliases) {
@@ -117,27 +101,25 @@ function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}` const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
core.debug(`vcvars command-line: ${vcvars}`) core.debug(`vcvars command-line: ${vcvars}`)
const cmd_output_string = child_process.execSync(`set && cls && ${vcvars} && cls && set`, {shell: "cmd"}).toString() const old_environment = child_process.execSync(`set`, {shell: "cmd"}).toString().split('\r\n')
const cmd_output_parts = cmd_output_string.split('\f') const new_environment = child_process.execSync(`${vcvars} && set`, {shell: "cmd"}).toString().split('\r\n')
const old_environment = cmd_output_parts[0].split('\r\n')
const vcvars_output = cmd_output_parts[1].split('\r\n')
const new_environment = cmd_output_parts[2].split('\r\n')
// If vsvars.bat is given an incorrect command line, it will print out // If vsvars.bat is given an incorrect command line, it will print out
// an error and *still* exit successfully. Parse out errors from output // an error and *still* exit successfully. Parse out errors from output
// which don't look like environment variables, and fail if appropriate. // which don't look like environment variables, and fail if appropriate.
const error_messages = vcvars_output.filter((line) => { var failed = false
for (let line of new_environment) {
if (line.match(/^\[ERROR.*\]/)) { if (line.match(/^\[ERROR.*\]/)) {
failed = true
// Don't print this particular line which will be confusing in output. // Don't print this particular line which will be confusing in output.
if (!line.match(/Error in script usage. The correct usage is:$/)) { if (line.match(/Error in script usage. The correct usage is:$/)) {
return true continue
}
core.error(line)
} }
} }
return false if (failed) {
}) throw new Error('invalid parameters')
if (error_messages.length > 0) {
throw new Error('invalid parameters' + '\r\n' + error_messages.join('\r\n'))
} }
// Convert old environment lines into a dictionary for easier lookup. // Convert old environment lines into a dictionary for easier lookup.
@@ -157,18 +139,11 @@ function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
if (!string.includes('=')) { if (!string.includes('=')) {
continue; continue;
} }
let [name, new_value] = string.split('=') const [name, new_value] = string.split('=')
let old_value = old_env_vars[name] const old_value = old_env_vars[name]
// For new variables "old_value === undefined". // For new variables "old_value === undefined".
if (new_value !== old_value) { if (new_value !== old_value) {
core.info(`Setting ${name}`) core.info(`Setting ${name}`)
// Special case for a bunch of PATH-like variables: vcvarsall.bat
// just prepends its stuff without checking if its already there.
// This makes repeated invocations of this action fail after some
// point, when the environment variable overflows. Avoid that.
if (isPathVariable(name)) {
new_value = filterPathValue(new_value)
}
core.exportVariable(name, new_value) core.exportVariable(name, new_value)
} }
} }
@@ -176,17 +151,6 @@ function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre) {
core.info(`Configured Developer Command Prompt`) core.info(`Configured Developer Command Prompt`)
} }
exports.setupMSVCDevCmd = setupMSVCDevCmd
function main() {
var arch = core.getInput('arch')
const sdk = core.getInput('sdk')
const toolset = core.getInput('toolset')
const uwp = core.getInput('uwp')
const spectre = core.getInput('spectre')
setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre)
}
try { try {
main() main()
-13
View File
@@ -1,13 +0,0 @@
{
"name": "msvc-dev-cmd",
"version": "1.10.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/@actions/core": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
}
}
}
+46 -17
View File
@@ -1,16 +1,40 @@
{ {
"name": "@actions/core", "_args": [
"version": "1.2.6", [
"description": "Actions core lib", "@actions/core@1.2.6",
"keywords": [ "/Users/ilammy/Documents/dev/ilammy/msvc-dev-cmd"
"github", ]
"actions",
"core"
], ],
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core", "_from": "@actions/core@1.2.6",
"license": "MIT", "_id": "@actions/core@1.2.6",
"main": "lib/core.js", "_inBundle": false,
"types": "lib/core.d.ts", "_integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==",
"_location": "/@actions/core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/core@1.2.6",
"name": "@actions/core",
"escapedName": "@actions%2fcore",
"scope": "@actions",
"rawSpec": "1.2.6",
"saveSpec": null,
"fetchSpec": "1.2.6"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"_spec": "1.2.6",
"_where": "/Users/ilammy/Documents/dev/ilammy/msvc-dev-cmd",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"description": "Actions core lib",
"devDependencies": {
"@types/node": "^12.0.2"
},
"directories": { "directories": {
"lib": "lib", "lib": "lib",
"test": "__tests__" "test": "__tests__"
@@ -19,6 +43,15 @@
"lib", "lib",
"!.DS_Store" "!.DS_Store"
], ],
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
"keywords": [
"github",
"actions",
"core"
],
"license": "MIT",
"main": "lib/core.js",
"name": "@actions/core",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -32,10 +65,6 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"bugs": { "types": "lib/core.d.ts",
"url": "https://github.com/actions/toolkit/issues" "version": "1.2.6"
},
"devDependencies": {
"@types/node": "^12.0.2"
}
} }
+476 -1653
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -1,10 +1,11 @@
{ {
"name": "msvc-dev-cmd", "name": "msvc-dev-cmd",
"version": "1.10.0", "version": "1.1.1",
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++", "description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"lint": "eslint index.js" "lint": "eslint index.js",
"test": "eslint index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -30,6 +31,6 @@
"@actions/core": "^1.2" "@actions/core": "^1.2"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^7" "eslint": "^6.8.0"
} }
} }