Skip to content

Commit

Permalink
chore: replace ts-standard with eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
baptiste0928 committed Mar 8, 2024
1 parent 64e8b27 commit 25205ab
Show file tree
Hide file tree
Showing 14 changed files with 630 additions and 1,747 deletions.
51 changes: 27 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Check TypeScript files
- name: Check types
run: pnpm run check

- name: Lint with ts-standard
- name: Lint
run: pnpm run lint

- name: Check format
run: pnpm run format:check

- name: Build action
run: pnpm run package

Expand All @@ -53,25 +56,25 @@ jobs:
runner: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install cargo-hack (from crates.io)
uses: ./
with:
crate: cargo-hack
version: ^0.4.4
cache-key: test

- name: Install cargo-sort (from git)
uses: ./
with:
crate: cargo-sort
git: https://github.com/devinr528/cargo-sort
tag: v1.0.9

- name: Print cargo hack version
run: cargo hack --version

- name: Print cargo sort version
run: cargo sort --version
- name: Checkout sources
uses: actions/checkout@v4

- name: Install cargo-hack (from crates.io)
uses: ./
with:
crate: cargo-hack
version: ^0.4.4
cache-key: test

- name: Install cargo-sort (from git)
uses: ./
with:
crate: cargo-sort
git: https://github.com/devinr528/cargo-sort
tag: v1.0.9

- name: Print cargo hack version
run: cargo hack --version

- name: Print cargo sort version
run: cargo sort --version
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
# 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).

## [Unreleased]

### Fixed

- Improve git tag/branch resolution. (issue #22)

## [3.0.0] - 2024-02-01

### Added

- Runner os version is included in the cache key. (issue #21)

### Changed

- **Breaking:** The action now runs on Node.js 20.
- Dependencies have been updated.

## [2.2.0] - 2023-09-07

### Added

- Support alternative registries with the `registry` and `index` input
parameters.

### Changed

- Crate versions are fetched from the sparse index instead of the crates.io
API.

## [2.1.0] - 2023-06-09

### Added

- Git installation is now supported with the `git` input parameter. You can
specify a branch, tag or commit hash.

## [2.0.0] - 2023-03-23

### Added

- Name and version are shown in the cache key. This allow to identify cache
entries in the cache management UI more easily.

### Changed

- **Breaking:** The action now runs on Node.js 16.
- **Breaking:** Versions without semver range (e.g. `1.2.3`) are now considered
as exact versions.
Expand All @@ -43,35 +58,49 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Various code improvements and refactoring.

## [1.3.1] - 2023-02-15

### Fixed

- Use `semver` instead of `compare-versions` to fix version resolution issues.
- Dependencies have been updated. This removes the warning about `set-output`
being deprecated.

## [1.3.0] - 2022-06-14

### Added

- Add `args` input to add additional arguments to the `cargo install` command.

### Deprecated

- `locked` input is deprecated, use the `args` input with `--locked` instead.

## [1.2.0] - 2022-03-16

### Added

- Add `locked` input to add `--locked` argument to `cargo install` command.

### Changed

- Dependencies have been updated.

## [1.1.0] - 2022-01-14

### Added

- Add `cache-key` input to add a custom key to the automatic cache key.

## [1.0.1] - 2022-01-07

### Fixed

- Errors when saving cache no longer cause the workflow to fail.

## [1.0.0] - 2021-11-21

### Added

- Initial release of `cargo-install` action.

[Unreleased]: https://github.com/baptiste0928/cargo-install/compare/v3.0.0...HEAD
Expand Down
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# Cargo install action

![GitHub release (latest by date)](https://img.shields.io/github/v/release/baptiste0928/cargo-install)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![CI](https://github.com/baptiste0928/cargo-install/actions/workflows/ci.yml/badge.svg)](https://github.com/baptiste0928/cargo-install/actions/workflows/ci.yml)

This action enables you to run `cargo install` in your GitHub workflows, and
automatically caches the resulting binaries to speed up subsequent builds.

| ✨ Recent updates: |
| :--- |
| **v3.0:** Run on Node 20 instead of Node 16. |
| **v2.2:** Added support for alternate registries and sparse indexes. |
| **v2.1:** Installing crates from git is now supported. |
| ✨ Recent updates: |
| :-------------------------------------------------------------------------------------------------- |
| **v3.0:** Run on Node 20 instead of Node 16. |
| **v2.2:** Added support for alternate registries and sparse indexes. |
| **v2.1:** Installing crates from git is now supported. |
| **v2.0:** This major update introduces some breaking changes. Read the [changelog] before updating. |

## Features

- Install any Rust binary crate from [crates.io], a git repository or an
alternate registry.
- Automatically cache installed binaries to avoid compiling them each run.
- Keep crates updated, with an optional version range to avoid breakages.
- Works on Linux, Windows and MacOS runners.

## Usage

The following example steps install the [`cargo-hack`] and [`cargo-sort`]
crates. Read [Quickstart for GitHub Actions] to learn more about Actions usage.

Expand All @@ -30,14 +31,14 @@ crates. Read [Quickstart for GitHub Actions] to learn more about Actions usage.
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-hack
version: "^0.5" # You can specify any semver range
version: '^0.5' # You can specify any semver range

- name: Install cargo-sort from git
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-sort
git: https://github.com/devinr528/cargo-sort
tag: v1.0.9 # `branch` and `commit` are also supported
tag: v1.0.9 # `branch` and `commit` are also supported

- name: Run cargo hack
run: cargo hack --version
Expand All @@ -48,7 +49,8 @@ installed. The `--locked` flag is added by default to avoid breakages due to
unexpected dependencies updates.

### Input parameters
- `crate` *(required)*: Name of the crate to install.

- `crate` _(required)_: Name of the crate to install.
- `version`: Version to install (defaults to the latest version). Supports any
semver range. Only used when installing from crates.io, see below for git
installation.
Expand All @@ -60,6 +62,7 @@ unexpected dependencies updates.
invalidate the cache.

#### Git parameters

- `git`: URL of the git repository to install from.
- `branch`: Branch to install from.
- `tag`: Tag to install from.
Expand All @@ -69,6 +72,7 @@ unexpected dependencies updates.
specified, the latest commit of the default branch will be used.

#### Alternate registry parameters

- `registry`: Registry name from the Cargo configuration. See
[Using an alternate registry](https://doc.rust-lang.org/nightly/cargo/reference/registries.html#using-an-alternate-registry)
on the Cargo Book.
Expand All @@ -79,10 +83,12 @@ version range resolution, you'll need to specify an exact version when using
`registry` or a non-sparse `index`.

### Outputs

- `version`: The version of the crate that has been installed.
- `cache-hit`: A boolean indicating whether the crate was restored from cache.

## Caching

Compiled binaries of installed crates are automatically cached. If a cached
version is present when the action is executed, it will be used. This allows the
installation of the crate to be almost instant in most cases.
Expand All @@ -94,19 +100,21 @@ to learn more about caching with GitHub Actions.
<details>
<summary><strong>Cache key details</strong></summary>

The `~/.cargo-install/<crate-name>` folder is cached with a cache key that
follows the following pattern:
The `~/.cargo-install/<crate-name>` folder is cached with a cache key that
follows the following pattern:

```
cargo-install-<crate>-<version or commit>-<hash>
```

```
cargo-install-<crate>-<version or commit>-<hash>
```
The hash is derived from the action job and runner os name, os version and the
installation arguments. The `cache-key` value is added to the hashed string
if provided.

The hash is derived from the action job and runner os name, os version and the
installation arguments. The `cache-key` value is added to the hashed string
if provided.
</details>

## Security

Crates are installed using `cargo install` and the latest version is retrieved
from the [crates.io] sparse index. You can ask to install a specific version by
not using any semver range operator.
Expand All @@ -115,6 +123,7 @@ If using a git repository, the action will use [`git ls-remote`] to retrieve
the commit hash. The repository is cloned by `cargo install`.

## Contributing

There is no particular contribution guidelines, feel free to open a new PR to
improve the code. If you want to introduce a new feature, please create an
issue before.
Expand Down
46 changes: 23 additions & 23 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
name: "cargo-install"
description: "GitHub action for cache-efficient Rust crates installation"
name: 'cargo-install'
description: 'GitHub action for cache-efficient Rust crates installation'
inputs:
# Global input parameters
crate:
description: "Name of the crate to install"
description: 'Name of the crate to install'
required: true
features:
description: "Features of the crate to enable."
description: 'Features of the crate to enable.'
required: false
locked:
description: "Use the crate Cargo.lock if available."
description: 'Use the crate Cargo.lock if available.'
required: false
default: "true"
default: 'true'
args:
description: "Arguments added to the `cargo install` command."
description: 'Arguments added to the `cargo install` command.'
required: false
cache-key:
description: "Additional key added to the automatic cache key."
description: 'Additional key added to the automatic cache key.'
required: false

# Registry installation
version:
description: "Version of the crate to install."
description: 'Version of the crate to install.'
required: true
default: "latest"
default: 'latest'
registry:
description: "Registry to install the crate from."
description: 'Registry to install the crate from.'
required: false
index:
description: "Registry index to install the crate from."
description: 'Registry index to install the crate from.'
required: false

# Git installation
git:
description: "Git repository to install the crate from."
description: 'Git repository to install the crate from.'
required: false
branch:
description: "Branch to install the crate from."
description: 'Branch to install the crate from.'
required: false
tag:
description: "Tag to install the crate from."
description: 'Tag to install the crate from.'
required: false
commit:
description: "Commit to install the crate from."
description: 'Commit to install the crate from.'
required: false
rev: # alias for commit
description: "Commit to install the crate from."
description: 'Commit to install the crate from.'
required: false

outputs:
version:
description: "The version of the crate that has been installed."
description: 'The version of the crate that has been installed.'
cache-hit:
description: "A boolean indicating whether the crate was restored from cache."
description: 'A boolean indicating whether the crate was restored from cache.'
runs:
using: "node20"
main: "dist/index.js"
using: 'node20'
main: 'dist/index.js'
branding:
color: "yellow"
icon: "package"
color: 'yellow'
icon: 'package'
Loading

0 comments on commit 25205ab

Please sign in to comment.