mirror of
https://github.com/actions-rs/cargo.git
synced 2025-08-14 12:45:12 +00:00
Compare commits
152 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9e120dd99b | ||
|
e16f454f6b | ||
|
93101f479e | ||
|
2556f17de2 | ||
|
9289a3680d | ||
|
d11d5b7464 | ||
|
112ff2c6a7 | ||
|
3d40d633ea | ||
|
fd98e64842 | ||
|
13ca0434d9 | ||
|
9b63f19692 | ||
|
0cbbda151c | ||
|
c904ff2d49 | ||
|
74b5d547b1 | ||
|
da6cc28094 | ||
|
6ebb66603b | ||
|
899cac1937 | ||
|
6328cd53b7 | ||
|
9b0da1649c | ||
|
4da0a68949 | ||
|
709a14479b | ||
|
b91df07630 | ||
|
f518b1bf4f | ||
|
669dbe819f | ||
|
cfe09f0cd0 | ||
|
10e186d6c3 | ||
|
3a8f68722b | ||
|
0316b4dbeb | ||
|
643a107c69 | ||
|
495251dde1 | ||
|
827b111f29 | ||
|
26ff6f45e2 | ||
|
6c7d65c3ae | ||
|
6887958b7e | ||
|
3978ae1819 | ||
|
a5d90faaac | ||
|
0c45933697 | ||
|
b24fa7fa19 | ||
|
f5ebd6b53f | ||
|
bfb772b37f | ||
|
2ad44e7437 | ||
|
a5368735dc | ||
|
097170339e | ||
|
47f0b800a7 | ||
|
1545d7115e | ||
|
9ef4e012d1 | ||
|
81e7b4fc50 | ||
|
55c1b24b53 | ||
|
c80c77a601 | ||
|
4db9ec66b1 | ||
|
916adaa2ec | ||
|
5b0d053e0c | ||
|
b67a2a2085 | ||
|
200d4dd218 | ||
|
9fb19abe20 | ||
|
ba4c43f12b | ||
|
b1c730db5c | ||
|
2d34cc3baa | ||
|
928a398d47 | ||
|
c57438a3b5 | ||
|
f89536e253 | ||
|
76313c9750 | ||
|
6fb3eb315b | ||
|
18d0b84e8b | ||
|
473fa467f5 | ||
|
a11685ebe5 | ||
|
0fec3c9e4b | ||
|
e0dbeeae1e | ||
|
90749cf47d | ||
|
eef3dff983 | ||
|
b7b99ee70c | ||
|
d64d910352 | ||
|
fc0be9b9bf | ||
|
6ff09eef9c | ||
|
e4f1d35037 | ||
|
d864f3d802 | ||
|
90f33d00c0 | ||
|
9021ac3f23 | ||
|
de5f09d485 | ||
|
c7a52555c6 | ||
|
aabb2735ba | ||
|
6ddf35e4d7 | ||
|
bcbe7625d8 | ||
|
6c501d70cc | ||
|
c6a8680a20 | ||
|
84d04d4ab8 | ||
|
a82231b2af | ||
|
7e28e2e906 | ||
|
2f2a669b7f | ||
|
df3ab0f3f5 | ||
|
532792827f | ||
|
b9d148ae69 | ||
|
e8634b4139 | ||
|
1cc43e03bb | ||
|
2bb6b48068 | ||
|
43a3b53436 | ||
|
4f6bb6dbdc | ||
|
30dfe359f3 | ||
|
68937d92fc | ||
|
efdda56b63 | ||
|
ecffd7835a | ||
|
be8af9e871 | ||
|
ec4ebbc81f | ||
|
254f9e6382 | ||
|
45419cb407 | ||
|
49fbc98021 | ||
|
37578ffd8b | ||
|
d69a1498bc | ||
|
896d5e8318 | ||
|
2d29e3bf4a | ||
|
8740e43619 | ||
|
e5cb681de1 | ||
|
57e1c3d389 | ||
|
1ff29157f8 | ||
|
2c068b1dda | ||
|
af2a932bd5 | ||
|
7c11835f59 | ||
|
844f36862e | ||
|
d2cb01ee35 | ||
|
e0944f3af7 | ||
|
dafd80507a | ||
|
131c46c0b7 | ||
|
107736017b | ||
|
0362540e88 | ||
|
d57a4be083 | ||
|
7011238f67 | ||
|
989c5b6dd5 | ||
|
4b6fe961df | ||
|
6f09586277 | ||
|
2daac5e246 | ||
|
9b19153732 | ||
|
380e817a2d | ||
|
93e592e418 | ||
|
77d7358972 | ||
|
edf4070df2 | ||
|
46893a442f | ||
|
b6a5e9eb92 | ||
|
f9a165e753 | ||
|
e35786a472 | ||
|
5c0786fa0f | ||
|
6cb8ab3188 | ||
|
f1454eebbc | ||
|
23f951744d | ||
|
3357c7c844 | ||
|
26dcd7703b | ||
|
2c42f22fe4 | ||
|
16f1ea2210 | ||
|
e2d210d7c8 | ||
|
d53fa3b377 | ||
|
f7ad9fc10a | ||
|
29ddb16b37 | ||
|
ae10961054 |
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.eslint.json"
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/ban-ts-ignore": "off"
|
||||
}
|
||||
}
|
18
.github/workflows/ci.yml
vendored
Normal file
18
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: Continuous integration
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create npm configuration
|
||||
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
|
||||
env:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npm run build
|
||||
- run: npm run test
|
21
.matchers/rust.json
Normal file
21
.matchers/rust.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "rust",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
|
||||
"severity": 1,
|
||||
"message": 4,
|
||||
"code": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
27
CHANGELOG.md
Normal file
27
CHANGELOG.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.0.3] - 2019-11-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Rustup installer for Windows VMs is downloaded via HTTPS
|
||||
|
||||
## [1.0.2] - 2019-11-09
|
||||
|
||||
### Added
|
||||
|
||||
- Problem matcher which will highlight warnings and errors in the cargo output
|
||||
|
||||
### Changed
|
||||
|
||||
- Use `@action-rs/core` package for cargo/cross execution
|
||||
|
||||
## [1.0.1] - 2019-09-15
|
||||
|
||||
### Added
|
||||
|
||||
- First public version
|
88
README.md
88
README.md
@ -1,11 +1,24 @@
|
||||
# Rust `cargo` Action
|
||||
|
||||
[](https://actions-rs.github.io/#sponsoring)
|
||||

|
||||
[](https://gitter.im/actions-rs/community)
|
||||

|
||||

|
||||
|
||||
This GitHub Action runs specified [`cargo`](https://github.com/rust-lang/cargo)
|
||||
command on a Rust language project.
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
* [Example workflow](#example-workflow)
|
||||
* [Use cases](#use-cases)
|
||||
* [Inputs](#inputs)
|
||||
* [Toolchain](#toolchain)
|
||||
* [Cross-compilation](#cross-compilation)
|
||||
* [License](#license)
|
||||
* [Contribute and support](#contribute-and-support)
|
||||
|
||||
## Example workflow
|
||||
|
||||
```yaml
|
||||
@ -18,37 +31,68 @@ jobs:
|
||||
name: Rust project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
arguments: --release --all-features
|
||||
args: --release --all-features
|
||||
```
|
||||
|
||||
See [additional recipes here](https://github.com/actions-rs/meta).
|
||||
|
||||
## Use cases
|
||||
|
||||
Note that this Action is not required usually
|
||||
and you can just use [`run`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun)
|
||||
step instead as in example below:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build_and_test:
|
||||
name: Rust project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- run: cargo build --release --all-features
|
||||
```
|
||||
|
||||
Why would you want to use this Action instead:
|
||||
|
||||
1. Transparent `cross` installation and execution with `use-cross: true` input enabled
|
||||
2. Warnings and errors issued by `cargo` will be displayed in GitHub UI
|
||||
|
||||
## Inputs
|
||||
|
||||
* `command` (*required*) - Cargo command to run (ex. `check` or `build`)
|
||||
* `toolchain` - Rust toolchain to use (without the `+` sign, ex. `nightly`);\
|
||||
Override or system toolchain will be used if omitted.
|
||||
* `args` - Arguments for the cargo command
|
||||
* `use-cross` - Use [`cross`](https://github.com/rust-embedded/cross) instead of `cargo` (default: `false`)
|
||||
| Name | Required | Description | Type | Default |
|
||||
| ------------| :------: | -------------------------------------------------------------------------| ------ | --------|
|
||||
| `command` | ✓ | Cargo command to run, ex. `check` or `build` | string | |
|
||||
| `toolchain` | | Rust toolchain name to use | string | |
|
||||
| `args` | | Arguments for the cargo command | string | |
|
||||
| `use-cross` | | Use [`cross`](https://github.com/rust-embedded/cross) instead of `cargo` | bool | false |
|
||||
|
||||
## Virtual environments
|
||||
## Toolchain
|
||||
|
||||
Note that `cargo` is not available by default for all [virtual environments](https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions);
|
||||
for example, as for 2019-09-15, `macOS` env is missing it.
|
||||
By default this Action will call whatever `cargo` binary is available
|
||||
in the current [virtual environment](https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions).
|
||||
|
||||
You can use [`actions-rs/toolchain`](https://github.com/actions-rs/toolchain)
|
||||
to install the Rust toolchain with `cargo` included.
|
||||
to install specific Rust toolchain with `cargo` included.
|
||||
|
||||
## Cross
|
||||
## Cross-compilation
|
||||
|
||||
In order to make cross-compilation an easy process,
|
||||
In order to make cross-compile an easy process,
|
||||
this Action can install [cross](https://github.com/rust-embedded/cross)
|
||||
tool on demand if `use-cross` input is enabled; `cross` executable will be invoked
|
||||
then instead of `cargo` automatically.
|
||||
|
||||
All consequent calls of this Action in the same job will use the same `cross` installed.
|
||||
All consequent calls of this Action in the same job
|
||||
with `use-cross: true` input enabled will use the same `cross` installed.
|
||||
|
||||
```yaml
|
||||
on: [push]
|
||||
@ -60,7 +104,7 @@ jobs:
|
||||
name: Linux ARMv7
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
@ -72,3 +116,17 @@ jobs:
|
||||
command: build
|
||||
args: --target armv7-unknown-linux-gnueabihf
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This Action is distributed under the terms of the MIT license, see [LICENSE](https://github.com/actions-rs/toolchain/blob/master/LICENSE) for details.
|
||||
|
||||
## Contribute and support
|
||||
|
||||
Any contributions are welcomed!
|
||||
|
||||
If you want to report a bug or have a feature request,
|
||||
check the [Contributing guide](https://github.com/actions-rs/.github/blob/master/CONTRIBUTING.md).
|
||||
|
||||
You can also support author by funding the ongoing project work,
|
||||
see [Sponsoring](https://actions-rs.github.io/#sponsoring).
|
||||
|
@ -1,32 +1,33 @@
|
||||
import * as input from '../src/input'
|
||||
import * as input from "../src/input";
|
||||
|
||||
const testEnvVars = {
|
||||
INPUT_COMMAND: 'build',
|
||||
INPUT_COMMAND: "build",
|
||||
// There are few unnecessary spaces here to check that args parser works properly
|
||||
INPUT_ARGS: ' --release --target x86_64-unknown-linux-gnu --no-default-features --features unstable ',
|
||||
'INPUT_USE-CROSS': 'true',
|
||||
INPUT_TOOLCHAIN: '+nightly'
|
||||
}
|
||||
INPUT_ARGS:
|
||||
" --release --target x86_64-unknown-linux-gnu --no-default-features --features unstable ",
|
||||
"INPUT_USE-CROSS": "true",
|
||||
INPUT_TOOLCHAIN: "+nightly",
|
||||
};
|
||||
|
||||
describe('actions-rs/check', () => {
|
||||
describe("actions-rs/cargo/input", () => {
|
||||
beforeEach(() => {
|
||||
for (const key in testEnvVars)
|
||||
process.env[key] = testEnvVars[key as keyof typeof testEnvVars]
|
||||
})
|
||||
for (const key in testEnvVars)
|
||||
process.env[key] = testEnvVars[key as keyof typeof testEnvVars];
|
||||
});
|
||||
|
||||
it('Parses action input into cargo input', async () => {
|
||||
const result = input.parse();
|
||||
it("Parses action input into cargo input", () => {
|
||||
const result = input.get();
|
||||
|
||||
expect(result.command).toBe('build');
|
||||
expect(result.command).toBe("build");
|
||||
expect(result.args).toStrictEqual([
|
||||
'--release',
|
||||
'--target',
|
||||
'x86_64-unknown-linux-gnu',
|
||||
'--no-default-features',
|
||||
'--features',
|
||||
'unstable'
|
||||
"--release",
|
||||
"--target",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"unstable",
|
||||
]);
|
||||
expect(result.useCross).toBe(true);
|
||||
expect(result.toolchain).toBe('nightly');
|
||||
expect(result.toolchain).toBe("nightly");
|
||||
});
|
||||
});
|
||||
|
21
dist/.matchers/rust.json
vendored
Normal file
21
dist/.matchers/rust.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "rust",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
|
||||
"severity": 1,
|
||||
"message": 4,
|
||||
"code": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
11
jest.config.json
Normal file
11
jest.config.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"clearMocks": true,
|
||||
"moduleFileExtensions": ["js", "ts"],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": ["**/*.test.ts"],
|
||||
"testRunner": "jest-circus/runner",
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
},
|
||||
"verbose": true
|
||||
}
|
12700
package-lock.json
generated
12700
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rust-cargo",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.3",
|
||||
"private": false,
|
||||
"description": "Run cargo command",
|
||||
"main": "lib/main.js",
|
||||
@ -9,9 +9,12 @@
|
||||
"test": "__tests__"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ncc build src/main.ts --minify",
|
||||
"watch": "ncc build src/main.ts --watch --minify",
|
||||
"test": "jest"
|
||||
"bundle": "cp -r .matchers ./dist/",
|
||||
"build": "rm -rf ./dist/* && ncc build src/main.ts --minify && npm run bundle",
|
||||
"format": "prettier --write 'src/**/*.ts' '__tests__/**/*.ts'",
|
||||
"lint": "tsc --noEmit && eslint 'src/**/*.ts' '__tests__/**/*.ts'",
|
||||
"watch": "rm -rf ./dist/* && ncc build src/main.ts --watch",
|
||||
"test": "jest -c jest.config.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -28,18 +31,24 @@
|
||||
"url": "https://github.com/actions-rs/cargo/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.0.1",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"@actions-rs/core": "0.1.3",
|
||||
"@actions/core": "^1.2.4",
|
||||
"string-argv": "^0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.7.5",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^24.9.0",
|
||||
"ts-jest": "^24.0.2",
|
||||
"typescript": "^3.5.1"
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^15.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||
"@typescript-eslint/parser": "^3.10.1",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.29.0",
|
||||
"eslint-config-prettier": "^7.2.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^27.0.6",
|
||||
"npm-check-updates": "^11.1.9",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.5.6",
|
||||
"typescript": "^4.3.5"
|
||||
}
|
||||
}
|
||||
|
55
src/input.ts
55
src/input.ts
@ -2,58 +2,31 @@
|
||||
* Parse action input into a some proper thing.
|
||||
*/
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
import stringArgv from 'string-argv';
|
||||
|
||||
// Workaround for a GH bug: https://github.com/actions/toolkit/issues/127
|
||||
//
|
||||
// For input `all-features: true` it will generate the `INPUT_ALL-FEATURES: true`
|
||||
// env variable, which looks too weird.
|
||||
// Here we are trying to get proper name `INPUT_NO_DEFAULT_FEATURES` first,
|
||||
// and if it does not exist, trying the `INPUT_NO-DEFAULT-FEATURES`
|
||||
function getInput(name: string): string {
|
||||
const inputFullName = name.replace(/-/g, '_');
|
||||
let value = core.getInput(inputFullName);
|
||||
if (value.length > 0) {
|
||||
return value
|
||||
}
|
||||
|
||||
return core.getInput(name)
|
||||
}
|
||||
|
||||
function getInputBool(name: string): boolean {
|
||||
const value = getInput(name);
|
||||
if (value && (value == 'true' || value == '1')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
import { input } from "@actions-rs/core";
|
||||
|
||||
import stringArgv from "string-argv";
|
||||
|
||||
// Parsed action input
|
||||
export interface Input {
|
||||
command: string,
|
||||
toolchain?: string,
|
||||
args: string[],
|
||||
useCross: boolean,
|
||||
command: string;
|
||||
toolchain?: string;
|
||||
args: string[];
|
||||
useCross: boolean;
|
||||
}
|
||||
|
||||
export function parse(): Input {
|
||||
const command = getInput('command');
|
||||
const args = stringArgv(getInput('args'));
|
||||
let toolchain = getInput('toolchain');
|
||||
if (toolchain.startsWith('+')) {
|
||||
export function get(): Input {
|
||||
const command = input.getInput("command", { required: true });
|
||||
const args = stringArgv(input.getInput("args"));
|
||||
let toolchain = input.getInput("toolchain");
|
||||
if (toolchain.startsWith("+")) {
|
||||
toolchain = toolchain.slice(1);
|
||||
}
|
||||
const useCross = getInputBool('use-cross');
|
||||
const useCross = input.getInputBool("use-cross");
|
||||
|
||||
return {
|
||||
command: command,
|
||||
args: args,
|
||||
useCross: useCross,
|
||||
toolchain: toolchain || undefined
|
||||
}
|
||||
toolchain: toolchain || undefined,
|
||||
};
|
||||
}
|
||||
|
97
src/main.ts
97
src/main.ts
@ -1,86 +1,16 @@
|
||||
const os = require('os');
|
||||
const process = require('process');
|
||||
import path from "path";
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import * as input from './input';
|
||||
|
||||
const CROSS_REV: string = '69b8da7da287055127812c9e4b071756c2b98545';
|
||||
|
||||
// TODO: `core.info` function is not published yet as for `1.0.1` version,
|
||||
// bundling it.
|
||||
function core_info(message: string): void {
|
||||
process.stdout.write(message + os.EOL);
|
||||
}
|
||||
|
||||
async function getCargo(): Promise<string> {
|
||||
try {
|
||||
return await io.which('cargo', true);
|
||||
} catch (error) {
|
||||
core_info('cargo is not installed by default for some virtual environments, \
|
||||
see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions');
|
||||
core_info('To install it, use this action: https://github.com/actions-rs/toolchain');
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getCross(cargoPath: string): Promise<string> {
|
||||
try {
|
||||
return await io.which('cross', true);
|
||||
} catch (error) {
|
||||
core.debug('Unable to find cross, installing it now');
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Somewhat new Rust is required to compile `cross`
|
||||
// (TODO: Not sure what version exactly, should clarify)
|
||||
// but if some action will set an override toolchain before this action called
|
||||
// (ex. `@actions-rs/toolchain` with `toolchain: 1.31.0`)
|
||||
// `cross` compilation will fail.
|
||||
//
|
||||
// In order to skip this problem and install `cross` globally
|
||||
// using the pre-installed system Rust,
|
||||
// we are going to jump to the tmpdir (skipping directory override that way)
|
||||
// install `cross` from there and then jump back.
|
||||
|
||||
const cwd = process.cwd();
|
||||
process.chdir(os.tmpdir());
|
||||
|
||||
try {
|
||||
core.startGroup('Install cross');
|
||||
core.warning('Git version of cross will be installed, \
|
||||
see https://github.com/actions-rs/cargo/issues/1');
|
||||
await exec.exec(cargoPath, [
|
||||
'install',
|
||||
'--rev',
|
||||
CROSS_REV,
|
||||
'--git',
|
||||
'https://github.com/rust-embedded/cross.git'
|
||||
]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} finally {
|
||||
// It is important to chdir back!
|
||||
process.chdir(cwd);
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
// Expecting it to be in PATH already
|
||||
return 'cross';
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const actionInput = input.parse();
|
||||
const cargo = await getCargo();
|
||||
import * as input from "./input";
|
||||
import { Cargo, Cross } from "@actions-rs/core";
|
||||
|
||||
export async function run(actionInput: input.Input): Promise<void> {
|
||||
let program;
|
||||
if (actionInput.useCross) {
|
||||
program = await getCross(cargo);
|
||||
program = await Cross.getOrInstall();
|
||||
} else {
|
||||
program = cargo;
|
||||
program = await Cargo.get();
|
||||
}
|
||||
|
||||
let args: string[] = [];
|
||||
@ -90,15 +20,20 @@ async function run(): Promise<void> {
|
||||
args.push(actionInput.command);
|
||||
args = args.concat(actionInput.args);
|
||||
|
||||
await exec.exec(program, args);
|
||||
await program.call(args);
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const matchersPath = path.join(__dirname, ".matchers");
|
||||
console.log(`::add-matcher::${path.join(matchersPath, "rust.json")}`);
|
||||
|
||||
const actionInput = input.get();
|
||||
|
||||
try {
|
||||
await run();
|
||||
await run(actionInput);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
core.setFailed((<Error>error).message);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
void main();
|
||||
|
7
tsconfig.eslint.json
Normal file
7
tsconfig.eslint.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"__tests__/**/*.ts"
|
||||
]
|
||||
}
|
@ -1,63 +1,31 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
"compilerOptions": {
|
||||
"allowJs": false,
|
||||
"checkJs": false,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"newLine": "LF",
|
||||
"noEmitOnError": true,
|
||||
"noErrorTruncation": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "dist",
|
||||
"pretty": true,
|
||||
"removeComments": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"suppressImplicitAnyIndexErrors": false,
|
||||
"target": "es2018",
|
||||
"declaration": false,
|
||||
"sourceMap": false
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user