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

Commit

Permalink
Release v1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Mar 24, 2020
1 parent 8e14415 commit b2417cd
Show file tree
Hide file tree
Showing 17 changed files with 1,920 additions and 938 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:

- uses: actions/checkout@v1
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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).

## Unreleased

### Added

- Pass `allow-downgrade` flag to `rustup` if `nightly` toolchain with components requested

## [1.0.5] - 2020-01-26

### Fixed
Expand Down
54 changes: 45 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# `rust-toolchain` Action

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

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

Optionally it can set installed toolchain as a default and as an override for current directory.
It supports additional targets, components and profiles and handles all
these small papercuts from you.

**Table of Contents**

* [Example workflow](#example-workflow)
* [Inputs](#inputs)
* [Outputs](#outputs)
* [Profiles](#profiles)
* [Components](#components)
* [The toolchain file](#the-toolchain-file)
* [License](#license)
* [Contribute and support](#contribute-and-support)

## Example workflow

Expand All @@ -25,9 +41,10 @@ jobs:
with:
toolchain: nightly
override: true
components: rustfmt, clippy

# `cargo check` command here will use installed `nightly`
# as it set as an "override" for current directory
# as it is set as an "override" for current directory

- name: Run cargo check
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -115,19 +132,38 @@ to install the minimal set of `nightly` toolchain components with the `rustfmt`
components: rustfmt, clippy
```

Same to the `profile` input, if the installed `rustup` does not supports "components",
In case if `nightly` toolchain is requested and one of the components is missing in
latest `nightly` release, this Action will attempt the downgrade till it find
the most recent `nightly` with all components needed.\
Note that this behavior will work only if the following two conditions apply:

1. `toolchain` input is `nightly` exactly.
2. At least one component is provided in `components` input.

Same to the `profile` input, if installed `rustup` does not supports "components",
it will be automatically upgraded by this Action.

## The toolchain file

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

Input has higher priority, so if you are want to use toolchain file, you need to remove the input from the workflow file.
Input has higher priority, so if you are want to use toolchain file,
you need to remove the input from the workflow file.

If neither `toolchain` input or `rust-toolchain` file are provided,
Action execution will fail.

## 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

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

## Notes
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).

As `rustup` is not installed by default for [macOS environments](https://help.github.com/en/articles/virtual-environments-for-github-actions)
at the moment (2019-09-13), this Action will try its best to install it before any other operations.
You can also support author by funding the ongoing project work,
see [Sponsoring](https://actions-rs.github.io/#sponsoring).
89 changes: 49 additions & 40 deletions __tests__/args.test.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
import {toolchain_args} from "../src/args";
import {morph} from "mock-env"
import {sync as tempWriteSync} from "temp-write"
import { getToolchainArgs } from "../src/args";
import { morph } from "mock-env";
import { sync as tempWriteSync } from "temp-write";

describe('actions-rs/toolchain', () => {
it('Parses action input into toolchain options', async () => {
let args = morph(() => {
return toolchain_args("./rust-toolchain");
}, {
'INPUT_TOOLCHAIN': 'nightly-2019-04-20',
'INPUT_DEFAULT': 'false',
'INPUT_OVERRIDE': 'true'
});
describe("actions-rs/toolchain", () => {
it("Parses action input into toolchain options", () => {
const args = morph(
() => {
return getToolchainArgs("./rust-toolchain");
},
{
INPUT_TOOLCHAIN: "nightly-2019-04-20",
INPUT_DEFAULT: "false",
INPUT_OVERRIDE: "true",
}
);

expect(args.name).toBe('nightly-2019-04-20');
expect(args.name).toBe("nightly-2019-04-20");
expect(args.default).toBe(false);
expect(args.override).toBe(true);
});

it('uses input variable if rust-toolchain file does not exist', function () {
let args = morph(() => {
return toolchain_args("./rust-toolchain");
}, {
'INPUT_TOOLCHAIN': 'nightly',
});
it("uses input variable if rust-toolchain file does not exist", function () {
const args = morph(
() => {
return getToolchainArgs("./rust-toolchain");
},
{
INPUT_TOOLCHAIN: "nightly",
}
);

expect(args.name).toBe("nightly")
expect(args.name).toBe("nightly");
});

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

it('prioritizes rust-toolchain file over input variable', function () {
let rustToolchainFile = tempWriteSync("1.39.0");
it("prioritizes rust-toolchain file over input variable", function () {
const rustToolchainFile = tempWriteSync("1.39.0");

let args = morph(() => {
return toolchain_args(rustToolchainFile);
}, {
'INPUT_TOOLCHAIN': 'nightly',
});
const args = morph(
() => {
return getToolchainArgs(rustToolchainFile);
},
{
INPUT_TOOLCHAIN: "nightly",
}
);

expect(args.name).toBe("nightly")
expect(args.name).toBe("nightly");
});

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

let args = morph(() => {
return toolchain_args(rustToolchainFile);
const args = morph(() => {
return getToolchainArgs(rustToolchainFile);
}, {});

expect(args.name).toBe("1.39.0")
expect(args.name).toBe("1.39.0");
});

it('trims content of the override file', function () {
let rustToolchainFile = tempWriteSync("\n 1.39.0\n\n\n\n");
it("trims content of the override file", function () {
const rustToolchainFile = tempWriteSync("\n 1.39.0\n\n\n\n");

let args = morph(() => {
return toolchain_args(rustToolchainFile);
const args = morph(() => {
return getToolchainArgs(rustToolchainFile);
}, {});

expect(args.name).toBe("1.39.0")
expect(args.name).toBe("1.39.0");
});
});
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"clearMocks": true,
"moduleFileExtensions": ["js", "ts"],
"testEnvironment": "node",
"testMatch": ["**/*.test.ts"],
"testRunner": "jest-circus/runner",
"transform": {
"^.+\\.ts$": "ts-jest"
},
"verbose": true
}
Loading

0 comments on commit b2417cd

Please sign in to comment.