Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 553f0f7

Browse files
committed
Release v1.0.5
1 parent 8e14415 commit 553f0f7

17 files changed

+1920
-938
lines changed

.eslintrc.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"project": "./tsconfig.eslint.json"
5+
},
6+
"plugins": ["@typescript-eslint"],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:prettier/recommended",
13+
"prettier",
14+
"prettier/@typescript-eslint"
15+
],
16+
"rules": {
17+
"@typescript-eslint/ban-ts-ignore": "off"
18+
}
19+
}

.github/FUNDING.yml

-3
This file was deleted.

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313

1414
- uses: actions/checkout@v1
1515
- run: npm ci
16+
- run: npm run lint
1617
- run: npm run build
1718
- run: npm run test
1819

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
9+
### Added
10+
11+
- Pass `allow-downgrade` flag to `rustup` if `nightly` toolchain with components requested
12+
713
## [1.0.5] - 2020-01-26
814

915
### Fixed

README.md

+45-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
# `rust-toolchain` Action
22

3+
[![Sponsoring](https://img.shields.io/badge/Support%20it-Say%20%22Thank%20you!%22-blue)](https://actions-rs.github.io/#sponsoring)
34
![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
45
[![Gitter](https://badges.gitter.im/actions-rs/community.svg)](https://gitter.im/actions-rs/community)
6+
![Continuous integration](https://github.com/actions-rs/toolchain/workflows/Continuous%20integration/badge.svg)
7+
![Dependabot enabled](https://api.dependabot.com/badges/status?host=github&repo=actions-rs/toolchain)
58

6-
This GitHub Action installs [Rust toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification).
9+
This GitHub Action installs [Rust toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification)
10+
with [rustup](https://github.com/rust-lang/rustup) help.
711

8-
Optionally it can set installed toolchain as a default and as an override for current directory.
12+
It supports additional targets, components and profiles and handles all
13+
these small papercuts from you.
14+
15+
**Table of Contents**
16+
17+
* [Example workflow](#example-workflow)
18+
* [Inputs](#inputs)
19+
* [Outputs](#outputs)
20+
* [Profiles](#profiles)
21+
* [Components](#components)
22+
* [The toolchain file](#the-toolchain-file)
23+
* [License](#license)
24+
* [Contribute and support](#contribute-and-support)
925

1026
## Example workflow
1127

@@ -25,9 +41,10 @@ jobs:
2541
with:
2642
toolchain: nightly
2743
override: true
44+
components: rustfmt, clippy
2845

2946
# `cargo check` command here will use installed `nightly`
30-
# as it set as an "override" for current directory
47+
# as it is set as an "override" for current directory
3148

3249
- name: Run cargo check
3350
uses: actions-rs/cargo@v1
@@ -115,19 +132,38 @@ to install the minimal set of `nightly` toolchain components with the `rustfmt`
115132
components: rustfmt, clippy
116133
```
117134

118-
Same to the `profile` input, if the installed `rustup` does not supports "components",
135+
In case if `nightly` toolchain is requested and one of the components is missing in
136+
latest `nightly` release, this Action will attempt the downgrade till it find
137+
the most recent `nightly` with all components needed.\
138+
Note that this behavior will work only if the following two conditions apply:
139+
140+
1. `toolchain` input is `nightly` exactly.
141+
2. At least one component is provided in `components` input.
142+
143+
Same to the `profile` input, if installed `rustup` does not supports "components",
119144
it will be automatically upgraded by this Action.
120145

121146
## The toolchain file
122147

123148
This Action supports [toolchain files](https://github.com/rust-lang/rustup#the-toolchain-file),
124149
so it is not necessary to use `toolchain` input anymore.
125150

126-
Input has higher priority, so if you are want to use toolchain file, you need to remove the input from the workflow file.
151+
Input has higher priority, so if you are want to use toolchain file,
152+
you need to remove the input from the workflow file.
153+
154+
If neither `toolchain` input or `rust-toolchain` file are provided,
155+
Action execution will fail.
156+
157+
## License
158+
159+
This Action is distributed under the terms of the MIT license, see [LICENSE](https://github.com/actions-rs/toolchain/blob/master/LICENSE) for details.
160+
161+
## Contribute and support
127162

128-
If neither `toolchain` input or `rust-toolchain` file are provided, Action execution will fail.
163+
Any contributions are welcomed!
129164

130-
## Notes
165+
If you want to report a bug or have a feature request,
166+
check the [Contributing guide](https://github.com/actions-rs/.github/blob/master/CONTRIBUTING.md).
131167

132-
As `rustup` is not installed by default for [macOS environments](https://help.github.com/en/articles/virtual-environments-for-github-actions)
133-
at the moment (2019-09-13), this Action will try its best to install it before any other operations.
168+
You can also support author by funding the ongoing project work,
169+
see [Sponsoring](https://actions-rs.github.io/#sponsoring).

__tests__/args.test.ts

+49-40
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,74 @@
1-
import {toolchain_args} from "../src/args";
2-
import {morph} from "mock-env"
3-
import {sync as tempWriteSync} from "temp-write"
1+
import { getToolchainArgs } from "../src/args";
2+
import { morph } from "mock-env";
3+
import { sync as tempWriteSync } from "temp-write";
44

5-
describe('actions-rs/toolchain', () => {
6-
it('Parses action input into toolchain options', async () => {
7-
let args = morph(() => {
8-
return toolchain_args("./rust-toolchain");
9-
}, {
10-
'INPUT_TOOLCHAIN': 'nightly-2019-04-20',
11-
'INPUT_DEFAULT': 'false',
12-
'INPUT_OVERRIDE': 'true'
13-
});
5+
describe("actions-rs/toolchain", () => {
6+
it("Parses action input into toolchain options", () => {
7+
const args = morph(
8+
() => {
9+
return getToolchainArgs("./rust-toolchain");
10+
},
11+
{
12+
INPUT_TOOLCHAIN: "nightly-2019-04-20",
13+
INPUT_DEFAULT: "false",
14+
INPUT_OVERRIDE: "true",
15+
}
16+
);
1417

15-
expect(args.name).toBe('nightly-2019-04-20');
18+
expect(args.name).toBe("nightly-2019-04-20");
1619
expect(args.default).toBe(false);
1720
expect(args.override).toBe(true);
1821
});
1922

20-
it('uses input variable if rust-toolchain file does not exist', function () {
21-
let args = morph(() => {
22-
return toolchain_args("./rust-toolchain");
23-
}, {
24-
'INPUT_TOOLCHAIN': 'nightly',
25-
});
23+
it("uses input variable if rust-toolchain file does not exist", function () {
24+
const args = morph(
25+
() => {
26+
return getToolchainArgs("./rust-toolchain");
27+
},
28+
{
29+
INPUT_TOOLCHAIN: "nightly",
30+
}
31+
);
2632

27-
expect(args.name).toBe("nightly")
33+
expect(args.name).toBe("nightly");
2834
});
2935

30-
it('toolchain input is required if rust-toolchain does not exist', function () {
31-
expect(() => toolchain_args("./rust-toolchain")).toThrowError()
36+
it("toolchain input is required if rust-toolchain does not exist", function () {
37+
expect(() => getToolchainArgs("./rust-toolchain")).toThrowError();
3238
});
3339

34-
it('prioritizes rust-toolchain file over input variable', function () {
35-
let rustToolchainFile = tempWriteSync("1.39.0");
40+
it("prioritizes rust-toolchain file over input variable", function () {
41+
const rustToolchainFile = tempWriteSync("1.39.0");
3642

37-
let args = morph(() => {
38-
return toolchain_args(rustToolchainFile);
39-
}, {
40-
'INPUT_TOOLCHAIN': 'nightly',
41-
});
43+
const args = morph(
44+
() => {
45+
return getToolchainArgs(rustToolchainFile);
46+
},
47+
{
48+
INPUT_TOOLCHAIN: "nightly",
49+
}
50+
);
4251

43-
expect(args.name).toBe("nightly")
52+
expect(args.name).toBe("nightly");
4453
});
4554

46-
it('uses rust-toolchain file if input does not exist', function () {
47-
let rustToolchainFile = tempWriteSync("1.39.0");
55+
it("uses rust-toolchain file if input does not exist", function () {
56+
const rustToolchainFile = tempWriteSync("1.39.0");
4857

49-
let args = morph(() => {
50-
return toolchain_args(rustToolchainFile);
58+
const args = morph(() => {
59+
return getToolchainArgs(rustToolchainFile);
5160
}, {});
5261

53-
expect(args.name).toBe("1.39.0")
62+
expect(args.name).toBe("1.39.0");
5463
});
5564

56-
it('trims content of the override file', function () {
57-
let rustToolchainFile = tempWriteSync("\n 1.39.0\n\n\n\n");
65+
it("trims content of the override file", function () {
66+
const rustToolchainFile = tempWriteSync("\n 1.39.0\n\n\n\n");
5867

59-
let args = morph(() => {
60-
return toolchain_args(rustToolchainFile);
68+
const args = morph(() => {
69+
return getToolchainArgs(rustToolchainFile);
6170
}, {});
6271

63-
expect(args.name).toBe("1.39.0")
72+
expect(args.name).toBe("1.39.0");
6473
});
6574
});

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest.config.js

-11
This file was deleted.

jest.config.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"clearMocks": true,
3+
"moduleFileExtensions": ["js", "ts"],
4+
"testEnvironment": "node",
5+
"testMatch": ["**/*.test.ts"],
6+
"testRunner": "jest-circus/runner",
7+
"transform": {
8+
"^.+\\.ts$": "ts-jest"
9+
},
10+
"verbose": true
11+
}

0 commit comments

Comments
 (0)