diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 36b63e4..bcb539f 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -2,8 +2,7 @@ name: Integration on: push: {} schedule: - cron: '0 0 * * *' - + - cron: '0 0 * * *' jobs: test: runs-on: ${{ matrix.os }} @@ -11,11 +10,21 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] rust: [stable, nightly] + include: + - os: macOS-latest + rust: 'stable' + components: 'rustfmt, clippy' steps: - uses: hecrj/setup-rust-action@master with: rust-version: ${{ matrix.rust }} + components: ${{ matrix.components || '' }} - name: Check Cargo availability run: cargo --version - name: Check Rustup default toolchain run: rustup default | grep '${{ matrix.rust }}' + - name: Check rustfmt and clippy are available on MacOS + if: matrix.os == 'macOS-latest' && matrix.rust == 'stable' + run: | + cargo fmt --version + cargo clippy --version diff --git a/action.yml b/action.yml index ef78730..8423267 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ inputs: rust-version: description: 'The toolchain name, such as stable, nightly, or 1.8.0' default: 'stable' + components: + description: 'The toolchain components to install, comma-separated' + default: '' runs: using: 'node12' main: 'lib/main.js' diff --git a/lib/main.js b/lib/main.js index 8a7eb2e..e9543ff 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,10 +22,17 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const version = core.getInput('rust-version'); + const components = core.getInput('components') + .split(',') + .map((component) => component.trim()) + .filter((component) => component.length > 0); if (version) { - yield rustup.install(version); + yield rustup.install(); yield exec.exec('rustup', ['default', version]); yield exec.exec('rustup', ['update', version]); + for (let component of components) { + yield exec.exec('rustup', ['component', 'add', component]); + } } } catch (error) { diff --git a/lib/rustup.js b/lib/rustup.js index 6fa2750..71b7afa 100644 --- a/lib/rustup.js +++ b/lib/rustup.js @@ -22,29 +22,22 @@ const path = __importStar(require("path")); const os = __importStar(require("os")); const fs_1 = require("fs"); let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''; -function install(version) { +function install() { return __awaiter(this, void 0, void 0, function* () { + // `rustup` is already installed on Linux and Windows platforms if (os.platform() == 'darwin') { - let toolPath = yield acquireRust(version); - core.debug('Rust toolchain is cached under ' + toolPath); + let toolPath = yield installOnUnix(); + core.debug('rustup is located under: ' + toolPath); core.addPath(path.join(toolPath, 'bin')); } }); } exports.install = install; -function acquireRust(version) { +function installOnUnix() { return __awaiter(this, void 0, void 0, function* () { - let script; - try { - script = yield toolCache.downloadTool("https://sh.rustup.rs"); - } - catch (error) { - core.debug(error); - throw `Failed to download rustup: ${error}`; - } + let script = yield toolCache.downloadTool("https://sh.rustup.rs"); fs_1.chmodSync(script, '777'); yield exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none']); - let cargo = path.join(process.env['HOME'] || '', '.cargo'); - return yield toolCache.cacheDir(cargo, 'rust', version); + return path.join(process.env['HOME'] || '', '.cargo'); }); } diff --git a/src/main.ts b/src/main.ts index 3b626b2..d3b4159 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,11 +6,19 @@ import * as os from 'os'; async function run() { try { const version = core.getInput('rust-version'); + const components = core.getInput('components') + .split(',') + .map((component) => component.trim()) + .filter((component) => component.length > 0); if(version) { await rustup.install(); await exec.exec('rustup', ['default', version]); await exec.exec('rustup', ['update', version]); + + for(let component of components) { + await exec.exec('rustup', ['component', 'add', component]); + } } } catch (error) { core.setFailed(error.message);