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

Commit

Permalink
Profiles and components support
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Oct 19, 2019
1 parent 74865b8 commit f0a61e6
Show file tree
Hide file tree
Showing 10 changed files with 5,177 additions and 925 deletions.
47 changes: 39 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
name: Continuous integration

on: [pull_request, push]
on: [push]

jobs:
check_pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create npm configuration
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
env:
token: ${{ secrets.GITHUB_TOKEN }}

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

- name: "npm run build"
run: npm run build
install_stable:
runs-on: ubuntu-latest
needs: check_pr
steps:
- uses: actions/checkout@v1
- uses: ./
with:
toolchain: stable

- name: "npm run test"
run: npm run test
install_nightly:
runs-on: ubuntu-latest
needs: check_pr
steps:
- uses: actions/checkout@v1
- uses: ./
with:
profile: minimal
toolchain: nightly
components: rustfmt, clippy

install_stable_in_docker:
runs-on: ubuntu-latest
container: ubuntu:latest # Docker image, not the GitHub Actions VM
needs: check_pr
steps:
# `rustup` will need `curl` or `wget` later
- run: apt-get update && apt-get install -y curl
- uses: actions/checkout@v1
- uses: ./
with:
toolchain: stable
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@actions-rs:registry=https://npm.pkg.github.com
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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-10-19

### Added

- Support for `rustup set profile` command
- Support for `--component` flag for the `rustup toolchain install` command

## [1.0.2] - 2019-10-14

### Changed
Expand Down
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install nightly
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
Expand All @@ -39,19 +39,67 @@ See [additional recipes here](https://github.com/actions-rs/meta).

## Inputs

| Name | Required | Description | Type | Default |
| ------------| :------: | ---------------------------------------------------------------------------------------------------------------------------------------| ------ | --------|
| `toolchain` || [Toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification) name to use, ex. `stable`, `nightly`, `nightly-2019-04-20` | string | |
| `target` | | Additionally install specified target for this toolchain, ex. `x86_64-apple-darwin` | string | |
| `default` | | Set installed toolchain as a default toolchain | bool | false |
| `override` | | Set installed toolchain as an override for the current directory | bool | false |
| Name | Required | Description | Type | Default |
| ------------ | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------| ------ | --------|
| `toolchain` || [Toolchain](https://github.com/rust-lang/rustup.rs#toolchain-specification) name to use, ex. `stable`, `nightly`, `nightly-2019-04-20`, or `1.32.0` | string | |
| `target` | | Additionally install specified target for this toolchain, ex. `x86_64-apple-darwin` | string | |
| `default` | | Set installed toolchain as a default toolchain | bool | false |
| `override` | | Set installed toolchain as an override for the current directory | bool | false |
| `profile` | | Execute `rustup set profile {value}` before installing the toolchain, ex. `minimal` | string | |
| `components` | | Comma-separated list of the additional components to install, ex. `clippy, rustfmt` | string | |

## Profiles

This Action supports rustup [profiles](https://blog.rust-lang.org/2019/10/15/Rustup-1.20.0.html#profiles),
which are can be used to speed up the workflow execution by installing the
minimally required set of components, for example:

```yaml
- name: Install minimal nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
```

This Action will automatically run `rustup self update` if `profile` input is set
and the installed `rustup` version does not supports them.

In order to provide backwards compatibility for `v1` version,
there is no value for `profile` input set by default,
which means that the `default` profile is used by `rustup`
(and that includes `rust-docs`, `clippy` and `rustfmt`).\
You may want to consider using `profile: minimal` to speed up toolchain installation.

## Components

If you are going to install `clippy`, `rustfmt` or any other [rustup component](https://rust-lang.github.io/rustup-components-history/),
it might not be available in latest `nightly` build;
check out the [`actions-rs/components-nightly`](https://github.com/actions-rs/components-nightly) Action,
which makes this process much easier.
This Action supports rustup [components](https://blog.rust-lang.org/2019/10/15/Rustup-1.20.0.html#installing-the-latest-compatible-nightly) too,
and in combination with the [profiles](#profiles) input it allows to install only the needed components:

```yaml
- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt, clippy
```

As an extra perk, `rustup >= 1.20.0` is able to find the most recent `nightly` toolchain
with the requested components available; next example is utilizing this feature
to install the minimal set of `nightly` toolchain components with the `rustfmt` and `clippy` extras:

```yaml
- name: Install minimal nightly with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt, clippy
```

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

## Notes

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ inputs:
override:
description: Set installed toolchain as an override for a directory
default: false
profile:
description: Name of the group of components to be installed for a new toolchain
required: false
components:
description: Comma-separated list of components to be additionally installed for a new toolchain
required: false

runs:
using: 'node12'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

0 comments on commit f0a61e6

Please sign in to comment.